Google
 
Web unafbapune.blogspot.com

Friday, March 31, 2006

 

Ant built-in properties

A nice Ant target to print out all the Ant's built-in properties:
<target name="echo" >
<echo message="os.name: ${os.name}" />
<echo message="basdir: ${basedir}" />
<!-- absolute path of the build file. -->
<echo message="ant.file: ${ant.file}" />
<!-- path to executing ant's root directory. -->
<echo message="ant.home: ${ant.home}" />
<echo message="ant.version: ${ant.version}" />
<echo message="ant.project.name: ${ant.project.name}" />
<echo message="ant.java.version: ${ant.java.version}" />
<!-- System properties. -->
<echo message="user.home: ${user.home}" />
<echo message="user.name: ${user.name}" />
<echo message="java.home: ${java.home}" />
</target>
Originally found here.

Sunday, March 19, 2006

 

int to bytes

Here is a fun quiz: What is the best possible way (fastest with least memory) to convert an int to a byte array (of size 4) in big endian in Java ? ie.
public static byte[] toBigEndianBytes(int i) {
// ??
}
It turns out the code below is the best I've found so far:
public static byte[] toBigEndianBytes(int i) {
return new byte[] {
(byte)(i >>> 24),
(byte)(i >>> 16),
(byte)(i >>> 8),
(byte)i
};
}
Can you think of a better one ?

Update on 21Mar06: Interesting class to look at java.nio.Bits.
Update on 29Mar06: Paul Brown has more details.

Saturday, March 11, 2006

 

Backup.sh

A simple little script that does the backup for me to a remote machine:
backup.sh
---------
filename=`date +%y%m%d`-`date +%H%M%S`-xyz-projects.tar
echo $filename
tar cf $filename ProjectXyz*
gzip $filename
scp $filename.gz hchar.desktop:/home/hchar/backup/
rm $filename.gz

Monday, March 06, 2006

 

Windows Subversioned

Just got SVN server running on Windows. So far so good! I installed both the TortoiseSVN and SVN server using the SVN 1-Click Setup.

It's not obvious how to specify the SVN URL. For example, if the SVN repository is created at C:\svnrepos, the URL will be
file:///C:/svnrepos
I then imported my Java project to it from Eclipse 3.1.2 via the Subclipse plugin. My project is now actually under dual version control by SVN and P4 :)

To remote access it, the SVN URL is simply:
svn://myhostname
Pretty neat.

Update on 12Mar06: just upgraded my svn client to TortoiseSVN 1.3.2 and svn server to SVN 1.3.0 on Windows. I didn't uninstall the previous subversion (both client and server), but I needed to manually disable the SVNService before I could install SVN 1.3.0 without failure.

I've used subversion seriously only for a week. Love it so far. In fact, I've disabled my CVSNT service (although not yet uninstalled). There is even utility to convert existing CVS repository to SVN. So I am not looking back.

This page is powered by Blogger. Isn't yours?