A well written article on JavaWorld that explains how to effectively use the Runtime.exec() method. It really saved me a lot of time.
Javascript getElementById() Shortcut
Do you love the wonderful javascript dollar shortcut $('myId') but cannot use jQuery or Prototype? Don’t worry, you can define your custom shortcut for the too long document.getElementById() function:
1 2 3 | |
Now you can sobstitute this:
1
| |
with this:
1
| |
Obviously you don’t get all the bells and whistles that you would get using jQuery, but it’s a start.
Get Location Coordinates Using Google Maps
This is a simple tutorial on finding location’s coordinates using Google Maps APIs.
First of all you need to signup for a Google Maps API key, otherwise your script will not work. When you are done, start building a simple form with three fields: one for the location and the others for coordinates display.
1 2 3 4 5 6 7 8 9 10 | |
Now, we need to define the getCoordinates() function: this function must read the value of the address field, check if it’s valid and get its coordinates. To get coordinates we’ll use the GClientGeocoder class and its method getLatLng(address:String, callback:function):
Sends a request to Google servers to geocode the specified address. If the address was successfully located, the user-specified callback function is invoked with a GLatLng point. Otherwise, the callback function is given a null point. In case of ambiguous addresses, only the point for the best match is passed to the callback function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Compact Font Styles
This is a simple tip that can help you reduce your style sheet size. Take a look at this CSS portion:
1 2 3 4 5 6 7 8 | |
All these properties can be condensed into a one row expression using this syntax:
1
| |
See the example below:
1 2 3 | |
Just remember that this syntax will only function if you specify both font-size and font-family.
Remove Leading Zeroes in XSL
A useful XSL template for removing leading zeros
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Just insert it into your XSL file and use it as usual:
1 2 3 | |
Zipped Folder Backup
A simple bash script that zips a folder and sets the archive name to the current date.
#!/bin/bash
# Archive name structure: ddMMYYYY_HHmmss.zip
archiveName=`date +%d%m%Y_%H%M%S`.zip
folderName=MyFolder
zip -r $archiveName $folderName
Install OpenOffice 3.1 on Ubuntu
These are the steps to install OpenOffice 3.1 on Ubuntu. First of all download OpenOffice 3.1 from the official web site. When you’re done, follow these steps:
1. Remove previous version
sudo apt-get remove openoffice*.*
2. Remove settings folder This will remove ALL your OpenOffice settings
rm ~/.openoffice.org -rf
3. Expand the archive
tar -xvzf OOo_3.1.0_LinuxIntel_install_en-US_deb.tar.gz
4. Setup
cd OOO310_m11_native_packed-4_en-US.9399/DEBS/
sudo dpkg -i *.deb
5. Setup desktop integration
cd desktop-integration
sudo dpkg -i openoffice.org3.1-debian-menus_3.1-9393_all.deb
Java Tail
A java implementation of the Unix tail command. This is a small customization of the java tail class created by Luigi Viggiano. I’ve just added some controls and added the update time parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
This is also a Gist. Check it out!
VMWare and Linux
If you install VMware on linux you may find that some keys (up/down keys, home key, etc…) don’t work in the guest operating system. You need to create a config file inside the .vmware folder in your home directory and paste this text info the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Install Sun JDK on Linux
I’ve tested this procedure on Fedora 10 and Ubuntu 9.04 but it should work on other distributions too.
First of all download the latest JDK package from the SUN page: be sure to download the bin file and not the rpm.
From now on you’ll need to run commands using sudo.
Move the package to /opt/ and make it executable.
1 2 3 4 5 6 7 | |
Now start the installation and follow the onscreen instructions
1
| |
When the installation is done you’ll need to set the JAVA_HOME enviroment variable and add java executable to the system pah.
Open the file /etc/profile and add the following lines
1 2 3 4 5 6 7 | |
Now add a symbolic link for the java command
1
| |
Log off and log in back and you’re done.