Houen's Blog

Thoughts on life, startups, tech & code

How to get current time in Java

I always forget how to get the current time in my timezone in Java. Here’s what I found to be the easiest way to do so:

Date now = Calendar.getInstance().getTime();

And if you want it in a different timezone:

Date now = Calendar.getInstance(TimeZone.getTimeZone("Europe/London")).getTime();

There it is. Super simple once you actually remember it ­čśÇ Enjoy! (more…)

Kill program Mac OS X terminal command line

Kill program Mac OSX terminal can sometimes be necessary

Kill program Mac OS X terminal

Even though OS X is a pleasure to work with, we have all had a program or process freeze up. It won’t quit by using “Force quit”. What do you do now? Fortunately, this can be solved quite easily.┬áTo kill program Mac OS X ┬áterminal on Leopard / Snow leopard / Lion do the following commands:

Get the ID of the program

ps -A | grep [name of program you want to close]

Kill the program

This will give you the number of the processes found (if any). Now just close them with this command (more…)

Rails 3 Magic Migrations

I Always forget what the Magic Migrations (migration generator names that automatically populate the migration with code) in Rails 3 are, so I thought I’d scratch my own itch and post them here for me (okay, and others) to find: (more…)

Get email about new posts

Get the latest posts delivered to your mailbox: