Verbose Logging

software development with some really amazing hair

T + G I F R

Archives for 6/2009

New Computer

· Posted in Hardware
Well I've have it up and running for a little while now, but finally got around to writing about it. After 5 years in university (coop program), and coming out with an engineering degree, I figured picking myself up a new gaming rig would be pretty hot. Specs (I just copied from my ncix invoice): Intel Core 2 Quad Q9550 Quad Core Processor LGA775 2.83GHZ Yorkfield 1333FSB 12MB ASUS P5N72-T Premium 780i SLI LGA775 ATX DDR2 3PCI-E16 2PCI-E1 2PCI S…

Compile LLVM On Ubuntu

· Posted in Programming
I needed to compile LLVM from scratch since the llvmruby gem needs it compiled with position independent code and the repo version doesn't seem to be, the gem whines compiling, etc, etc. The docs for LLVM don't seem to be that great when it comes to compiling this stuff from scratch, so here's what I did, as one big script chunk. You can probably copy and paste this, but I make no promises that it will work, only that it Works on My Machine. And…

Use Net::SSH With Amazon EC2

· Posted in Programming
I'm writing up some scripts to automate some EC2 setup, and SSH is required. All the examples for Net::SSH show using just a username and password, which is all good, but the Amazon stuff requires a key file. Here's how to do it: Net::SSH.start('my.amazon.hostname.amazonaws.com', 'user', :keys => '/path/to/keypair.pem') { |ssh| … } According to the docs, the :keys named param takes an array of file names of private keys to use for publickey and …

Calculating Age

· Posted in Programming
I found this little snippet on stackoverflow This is a strange way to do it, but if you format the date to yyyymmdd and subtract the date of birth from the current date then drop the last 4 digits you've got the age :) I don't know C#, but i believe this will work in any language. 20080814 - 19800703 = 280111 drop the last 4 digits = 28 All credit goes to ScArcher2 This is just a great little snippet of code, and as an upside, dates in that form…

Debugging Cucumber On Rails

· Posted in Programming
I like frameworks, but sometimes debugging them is more entertaining. I don't know why I didn't think of this method before, but mischa on github has a great little repo showing how you can do it. The README Usage: Add: require 'ruby-debug' require 'cucumber_rails_debug/steps' To features/support/env.rb Then use: Then debug # opens the debugger or Then what # prints out params, url and html Check it out here

Riding Rails With Selenium

· Posted in Programming
Selenium is a suite of tools to automate web app testing across many platforms. Cucumber is a BDD framework that allows you to write things in English (or whatever language you want, really), and have that execute as code. Put those together with webrat and rspec and you have a pretty mean stack to test your ruby on rails web application with. Sort of. I've been having some problems with it, getting it set up, but it's coming along. This isn't a…

Supercharge Wordpress

· Posted in Software
Wordpress is pretty much the blogging engine of choice. It's used by so many people, and has so many plugins and an amazing following, you'd wonder why anybody would use anything else (well there are a number of reasons, but we can talk about that later). Some problems that come with Wordpress, with all that power, is sometimes it's slow. Combine php, lots of plugins, and everything else, and your blog can come to a crawl, especially if you writ…

Parallel Processing In The Real World

· Posted in Editorial
I go to movies. Lots of movies. Usually I get popcorn or a drink. Not always, but usually. What can be counted on, however, is the movie theatre staff ensuring that instead of everybody waiting in a single line, and popping off the top like a queue, we all wait in 3 or 4 separate lines. Why is this? It's stupid. At the Tim Horton's in my building, they do it properly. One big line, 3 tills, and they just call the next person. The line moves so f…

Self Signed SSL Certificates

· Posted in Software
I don't really care, I just want a certificate. Gimme! For my stuff, I just want the SSL for my own personal use. It's not for a variety of random people I don't know, just me, so I don't care. How? openssl req -new -x509 -days 365 -nodes -out out.pem -keyout out.pem

Ruby Regex For Fun And Profit

· Posted in Programming
Regex are always fun, and since regex expressions are first class citizens in ruby, it makes it so much easier. I found this Code Golf question on Stackoverflow and threw together a quick method to do it. I can't take all the credit, since I needed to search a bit to figure out if I could do matching parenthesis in ruby, and found that I could, but only in ruby 1.9, which ruby forum topic showed me. Then a commenter on SO pointed out another opt…

Gtk And Ruby Threading Issues

· Posted in Programming
In one of my classes, we used Ruby and Gtk, but some issues popped up. The most obvious is using a block to do GUI update stuff and the like, from another thread. Things die. Puppies are killed. I found this post on Ruby Forum which fixed the problem. Relevant code. Basically, you call the Gtk.init_thread_protect method first when you start things up, then, whenever you need to do GUI update stuff, just wrap it in a Gtk.thread_protect {} block. …