January 30, 2009 at 9:10 am
· Filed under Tech
I was unlucky enough to hit a compiler bug, such that Eclipse IDE passes compilation, but it failed on my server using ant with Sun’s compiler. From the bug report it happens to JDK6 and will only be fixed in JDK7, so in the meantime I read of 2 workarounds that work.
1. Up-cast to an Object so that the down-cast become compiler-legal.
(ChildType)(Object)getParentType();
2. Use the Class.cast() method.
ChildType.class.cast( getParentType() );
Permalink
January 29, 2009 at 9:37 am
· Filed under Tech
I thought I logged this, but when I searched I couldn’t find it. I guess I have lots more things I forget to log here. And it shows they’re useful, because I do come back here to search for it.
I often write small driver snippets to test my code in small units, and I need an easy way to configure logging so that I can see the output on my console without running to a file. And here’s the solution:
Logger root = Logger.getRootLogger();
root.addAppender(new ConsoleAppender(
new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
Source: http://robertmaldon.blogspot.com/2007/09/programmatically-configuring-log4j-and.html
Permalink
January 29, 2009 at 9:31 am
· Filed under Tech
I was asked what I did to show the jar files listed in “Deployments by this build” in CC’s build report. I didn’t even publish any artifacts. A quick search shows that CC uses distributables.xsl to filter stuff from the ant log file.
Continuous integration is the next tool you ought to have after source control. It’s funny I had to learn them myself (no school I knew teaches it)…
Source: http://markmail.org/message/4qmotsivebcula4a
Permalink
January 14, 2009 at 11:05 am
· Filed under Tech
I finally took the time to search for some personal encryption while waiting for a long svn merge and commit. I wanted a small tool, preferably a single executable, works on multiple platforms, to encrypt files with keys. GPG initially felt a little too obscure to me, until I found this guide.
In short:
gpg --gen-key
and answer the prompts to generate a key pair. Make sure your remember your passphrase.
gpg -k
to list the keys.
gpg -r [keyname] -e [clearfile]
to encrypt the file using the particular key. By default the output is the same clearfile name with .gpg extension. Use -o option to change it.
gpg -o [clearfile] -d [encryptedfile]
to decrypt the file. -o option is needed here because this command outputs to console by default.
gpg -a -r [keyname] -o [keyfile] --export-secret-keys
to export the secret key. I need the same key on another computer to decrypt the contents. The -a option is synonymous with –armor, which generates a text representation instead of binary.
gpg --import [keyfile]
to import the key on to another computer.
A bonus feature was it actually compresses as it encrypts. I was thinking of manually scripting it to do so.
Permalink
January 8, 2009 at 1:52 pm
· Filed under Tech
A hashtable was created. But the .get() method was never called. Instead, all lookups went through the entrySet iterator. Meaning, you were trying to lookup the KEY from the VALUE.
The put parameters should be reversed.
Permalink