Entries from September 2007

Tuesday, September 18th, 2007

Easy XML Generation with Ruby and ERB

Ah, the bracket tax. XML-Situps, whatever you want to call them, if you write any code (especially if you use java) it should be your sworn enemy. The other day I had to create about 40 XML files for some Java Webstart configs. Instead of doing them by hand, I decided to check out the [...]

Monday, September 17th, 2007

Killing a process by name in ubuntu

I have to kill mongrel alot because it’s a flea-bitten mutt.
My usual method was to do a ps -aux | grep mongrel , find the pid and kill it!
Annoying and stupid!
Now I just use the nice pkill tool in ubuntu like so.
pkill mongrel
boom! All bad doggies killed! This probably works on other *nix flavors, but [...]

Friday, September 14th, 2007

Capturing STDERR with ruby backticks

I was writing a ruby script today that ran a linux command for every line in a file. The problem was the backtick operator in ruby only captures stdout, here's a little trick to get stderr as well. (*nix only)

out = `ourlinuxcmd 2>&1`

the 2>&1 bit tells the shell to redirect stderr to stdout
Bookmark to:

Monday, September 10th, 2007

Running rails with mongrel for a specific sub directory

I've started using mongrel for running rails apps with apache2 and mod_proxy , it works like a charm and allows you to run multiple rails apps and mongrel instances on one server.
Your proxy setup looks like this in your httpd.conf or vhost.conf

<VirtualHost *:80>
    ServerName myapp.com
    ServerAlias www.myapp.com
    ProxyPass /myapp http://www.myapp.com:8000/
    ProxyPassReverse [...]

Saturday, September 1st, 2007

♥ HTML Heart Code ♥

Here's how you make a heart in HTML,

&hearts;

Now, stop coming here for that! I'm sick of seeing you in my referral logs!
*Edit - Now i'm #1 in google for this unwillingly! If you're coming here to try out your heart code skills at least click an ad on your way out so I can [...]