A Noted Path

Personal blog of Theodore Nguyen-Cao

Options:

Archive for March, 2008

I’ve been dealing with Daylight Savings Time issues at work.  It’s a pain.  I found out Hawaii and Puerto Rico don’t observe DST the hard way.  It came to a surprise to me that Wordpress that does not support Daylight Savings Time handling at all.  I posted my last post and realized the time stamp [...]

Ruby: ! versus not operator

I was writing some code in an erb template that looked like this:

<% if @user && not @user.errors.empty? -%>
#do stuff
<% end -%>
This resulted in a syntax error. Huh? What’s wrong with this?
Turns out it’s an outstanding Core Ruby bug.
As shown in the ticket if we have a method foo

def foo(parameter)
puts parameter.to_s
end
using the ! [...]

I wanted to delete some .svn folders that didn’t go away when I disconnected from a repository but couldn’t see them in Finder. So I needed to show hidden files. Here’s how to do it.
Open up Terminal

>> defaults write com.apple.finder AppleShowAllFiles TRUE
>> killall Finder

Replace TRUE with FALSE to hide them again.

addthis_url [...]

DSL for UML Diagrams?

Domain-specific languages are becoming more and more popular.  I across websequencediagram.com which really illustrates the power of building DSLs to tackle very specific problems.  I don’t spend my time creating many UML sequence diagrams now a days but if I ever have to, I’ll be remembering this web app.

addthis_url = [...]

MacBook Pro - Where’s my delete key?

I’ve had my MacBook Pro for a couple of months now and I’ve officially switched over to a MBP at work as well.  All this time I have been working without a delete key.  That thing labeled ‘delete’ on my keyboard is really what I have known in the past as a ‘backspace’ key.  Naturally, [...]

Google TechTalk: Linus Torvalds on git

I came across this Google TechTalk with Linus Torvalds on git. I’ve never seen or heard Torvalds speak before. He certainly has a good sense of humor…or arrogance :).

It’s been almost a year since this tech talk and I still really haven’t seen large adoption of git. However after some painful experiences with [...]

Breaking Java Habits: Ruby increment/decrement operators

My background in C++ and Java has instilled in me some programming habits that don’t play nice in Ruby. When I want to increment or decrement a number, my fingers instinctively go to ‘++’ and ‘−−’.
Unfortunately, this syntax is not supported by Ruby. As a language design choice, Ruby opted to not support [...]

Java WTF: Reflection API and Annotations

I got some exposure to custom Java 5 Annotations today and came across a noobie mistake.
Here’s my annotation:

public @interface Annotated {
}
Pretty simple, right?
Here’s a test class that uses the annotation:

import java.lang.annotation.Annotation;

@Annotated
public class Main {
public static void main(String[] args) throws Exception {
for(Annotation ann: Main.class.getAnnotations()) [...]

Java WTF: Calendar vs Date

I’ve been doing some date math at work and I came across something I thought was wack.
Check this out:

Calendar cal1 = Calendar.getInstance();
Thread.sleep(500);
Calendar cal2 = Calendar.getInstance();
Thread.sleep(500);
Date now = new Date();

System.out.println(cal1.before(cal2));
System.out.println(cal1.before(now));
What do you think this snippet prints (It compiles, I promise!)?
Looking at the code, it shows that we are getting three snapshots in time, waiting half a [...]

Hacks, Tricks, and Techniques

I’m reading Out Of Their Minds - The Lives and Discoveries of 15 Great Computer Scientists by Dennis Shasha and Cathy Lazere.  I’m almost half way through but I just read an awesome quote that I wanted to share:
In the culture of computer science, an idea that works in one situation is called a [...]