Monthly ArchiveNovember 2007
Coding Wytze on 27 Nov 2007
From bytes to hex
When creating checksums or generating keys it might be helpful sometimes to represent the key/checksum as a hexadecimal string value. The key is most of the times a byte array which will need conversion. You can convert it with the following code (java 1.5+)
public String toHexString(byte[] b){ StringBuilder sb = new StringBuilder(); for( byte hexByte : b ){ sb.append(Integer.toHexString(hexByte & 0xFF).toUpperCase()); } return sb.toString(); }
By using the 0xFF with a bitwise AND operator we ensure that the byte to be converted is unsigned.
Coding Wytze on 13 Nov 2007
Appfuse 2 helps lazy people being lazy
Ok, let’s agree to this one: You are lazy. Some things in life help you being lazy. Why develop your own maven templates for instance when the appfuse guys already built them? That’s right, you’re nuts if you build your own.
Just have a look at there site to see what the possibilities are: appfuse
General Wytze on 05 Nov 2007
Sending commands to detached screens
For running Azureus headless on my linux machine I use screen so it runs in a separate screen.
The command to do this is the following:
screen -d -m -S azureus su -p azureus -c "/opt/azureus/azureus.sh"
This will create a detached screen with the name “azureus” which will run the command “su -p azureus -c “/opt/azureus/azureus.sh”
To send a command to this detached screen we can use the following command structure: (Which I use to tidily close the process)
screen -S azureus -p 0 -X eval 'stuff quit\015'
-p 0 tells screen to use window 0 on the specified screen. Using the eval function makes sure the \015 char will be evaluated back into an enter character. The stuff command is used to fill the input buffer of the screen program.
After this the command “quit” is sent to the azureus client which will cause it to quit and close the attached screen.