Posts filed under ‘geeky’

log4j properties loading problem + put ivy jar on classpath in ant

I learned a few new tricks recently that I thought are pretty cool.

If you use apache log4j, you can get very frustrated sometimes that it does not log based on what you defined in your log4j.properties file. This is because if your java web application contains other jars that also have log4j.properties, the log4j will use the first log4j.properties on the classpath which most of the times is NOT what you defined for your web app. I never knew a solution to this until recently my coworker was able to use spring to get around it. In your spring context, add
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="org.springframework.util.Log4jConfigurer"/> <property name="targetMethod" value="initLogging" /> <property name="arguments"> <list> <value>log4j.properties</value> </list> </property> </bean>
This will make sure the one you defined for your web app is used.

Also I recently wrote a groovy script in ant. I learned that you can use ivy to cache as instance of a jar and then you can use it in your ant script.
<target name="groovyScript"> <ivy:configure url="http://ivy.rainhail.com/ivyRepository/ivysettings.xml" /> <ivy:resolve conf="ant"/> <ivy:cachepath pathid="cp" conf="ant"/> <taskdef name="groovy" classpathref="cp" classname="org.codehaus.groovy.ant.Groovy"/> <groovy> <!-- your groovy script here --> </groovy> </target>

CSS 3-column layout

Saw this link getting dugg today. Despite a huge CSS fan, I have to agree with one of the comments.

The fact that getting a 3 column layout in CSS is a feat of wonder is an indication that something is terribly wrong with the standard. Building this layout should be obvious, intuitive, and in no need of discussion. This is absolutely trivial with tables — the only difficulty being that CSS zealots are going to crucify you when you put it together 10x faster than they can.

I’m all for the semantic web, but the fact that people still can’t admit that CSS lacks a grid positioning system (allowing you to align content to other parts of the document tree) is why it still lacks such a system. Get off your high horse. Admit that CSS layout is inferior to tables in some cases and needs some revision, and maybe someday life will actually be easier.

MacBook Wheel

Instead of VAIO, I should have gotten the MacBook Wheel.
YouTube Preview Image

What was I thinking………

New year greeting = spyware?!

I got THIS SUCKER last week at work. I haven’t gotten spyware in hmmm like 4 or 5 years. I was really embarrassed that I got it at work so I did not want to ask their IT support for help. I don’t have full admin rights on my work computer so I cannot do a restore. I swear I did not download anything suspicious. At least nothing I know of. I really still have no idea how I got it. So last Friday I was searching all over the place to find a solution. I finally got rid of it using Malwarebytes’ Anti-Malware free version. So if you see weird process like prunnet.exe running in your task manager and you get random popups in both IE and Firefox, you may want to try that free version of Malwarebytes’ Anti-Malware.

Got a new laptop

Christmass gift for myself :) Sony VAIO laptop

sonylaptop1

Specs

processor: 2.26ghz Intel Core2 Duo
display: LCD widescreen display with XBRITE-ECO technology (1600 x 900 resolution)
screen size: 16.4″
system bus: 1066MHz
cache memory: 3MB on die Level 2
RAM: 4GB PC2-6400
hard drive: 320gb
optical drive: Double-layer DVD RW/Blu-ray Disc/CD-RW
weight: 6.4 lbs

(more…)

Java: static declaration of collection

I don’t know if this is a new feature in Java 5 that I did not know before or I just did not know this is possible in Java. But I learned today that you can do static declaration of collection types as below:
public static List<String> supportedCopyPropertyTypes = new ArrayList<String>() { private static final long serialVersionUID = 660145948432567403L; { add("String"); add("BigDecimal"); add("int"); } };

Eclipse run java code easily

Eclipse has a scrapbook function that allows you to run Java code on the fly. Sometimes you just want to test out a simple piece of code without having to create another Java class, execute it in the main method or create a junit to test it out.

For example, today I wanted to make sure I remember integer division in Java correctly. So I simply just want to execute the following piece of code.
int a = 10; int b = 8; int c = 17; System.out.println(a / b); System.out.println(c / b);

In order to do that, create a new Scrapbook page in your project. I just called mine blah.jpage. Then paste the code in there. Highlight the code, right click and select execute or ctrl+U. The results of your execution will then show up in the console. That comes in pretty handy sometimes.

Eclipse Scrapbook

Upside down text with CSS

It’s actually possible to print text upside down using a simple CSS property and works cross-browser today. The property to use is “text-gravity” with a value of “inverse”.

<span style="text-gravity: inverse"> write upside down text </span>

… and this is the result:
ʇxǝʇ uʍop ǝpısdn ǝʇıɹʍ

I’m really surprised to learn that so few people know about this property, and I recommend you to continue reading the W3C specification of text-gravity.

Update: Sorry, I lied :) The above is done with a UTF-8 character generator (see the link the the “specification” above). Amazingly, you can find that most characters have their upside down equivalent somewhere else in the huge Unicode alphabet. Neat trick :)

Custom font

I saw another custom font solution today: typeface

Instead of creating images or using flash just to show your site’s graphic text in the font you want, you can use typeface.js and write in plain HTML and CSS, just as if your visitors had the font installed locally.

A while ago, I blogged about the SIFR 3. And there are many other solutions to render text in fonts that your client’s machine does not have. For example, generating the text as an image. BTW wasn’t there a wordpress plugin that does this? I wasn’t able to find it in my quick search. Can someone enlighten me?

One thing I hate about all these solutions is that you may no longer highlight the text in order to copy its content in all the browsers I know. It just bugs me to no end when expected browser behaviors get changed because you want some fancy fonts for your site.

I wish more browsers would implement the @font-face css rule so maybe then we can get around this issue?

jQuery may just win

I’m still unhappy how I lost the jQuery battle at work. Although I’m not banned from using it but hey this is encouraging! jQuery may just win the javascript framework battle at least in the popularity category.

jQuery

Other frameworks are just not as user friendly IMO.

Page 1 of 3312345»...Last »