MBTI Meme
April 25th, 2008
We were sitting around our office talking about our team and the subject of MBTI came up. We started talking about ourselves and how we should be putting together teams for our various projects and why. I think this is a great thing to consider when staffing a project and will probably serve as an invaluable asset going down the road. That being said, my type is
meaning I am Extroverted, favor intuition, thinking, and perception. The test I took is free and can be found here. What type are you?
Tagging: Rob, Muness, Jason, Joe, and Evan
meaning I am Extroverted, favor intuition, thinking, and perception. The test I took is free and can be found here. What type are you?
Tagging: Rob, Muness, Jason, Joe, and Evan
Announcing Fixture Busters... {dot}com
April 18th, 2008
I have been on a testing / refactoring rampage over the last few months and have learned an awful lot about making tests better. One particular pain point that I have run into is the use of fixtures in people's test suites. A lot of people already know that fixtures are a bad thing, but few people do anything about it. That's all about to change. I am going to start putting up screencasts that show you how to refactor the fixtures right out of your tests! If you have any Rails applications that you want to throw on the fire feel free to email the code to aaron at my domain dot com. Please no client projects, open source code only! I don't want to do your work for you.
You can find the site at http://fixturebusters.com. It will have some super duper styling love and the first screencast up sometime in the next week so stop on over and check it out!
You can find the site at http://fixturebusters.com. It will have some super duper styling love and the first screencast up sometime in the next week so stop on over and check it out!
MPI Ruby - Officially Released
April 17th, 2008
A while ago I annouced that I had updated the seemingly dead MPI Ruby project to work with Ruby 1.8.x. I have been testing things out and have had some very helpful feedback. Things seem to be working well for me so I am announcing the official release of the library. With the recent "release" of GItHub I decided to put the good bits up there. The clone url is:
git://github.com/abedra/mpi-ruby.git
If you are running leopard and have XCode Tools installed, all you have to do is:
$ ./configure
$ make
$ sudo make install
and you should be in happy parallel land. If you don't have the new Apple hotness, you need to install OpenMPI.
Happy high performance parallel computing!
MPI Ruby lesson - Basic Communication
April 17th, 2008
Here is a demonstration of basic communication with MPI Ruby.
This script sets up interprocess communication, sends / receives basic 'hello' messages and determines who the message came from and what status the message was. This is a simple starter example of how to send and receive between processes with MPI. Let's try running it:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
myrank = MPI::Comm::WORLD.rank() csize = MPI::Comm::WORLD.size() if myrank % 2 == 0 then if myrank + 1 != csize then hello = "Hello, I'm #{myrank}, you must be #{myrank+1}" MPI::Comm::WORLD.send(hello, myrank + 1, 0) end else msg, status = MPI::Comm::WORLD.recv(myrank - 1, 0) puts "I'm #{myrank} and this message came from #{status.source} with tag #{status.tag}: '#{msg}'" end |
$ mpirun -np 16 mpi_ruby basic.rb
We get an output similar to this:
I'm 13 and this message came from 12 with tag 0: 'Hello, I'm 12, you must be 13'
I'm 1 and this message came from 0 with tag 0: 'Hello, I'm 0, you must be 1'
I'm 3 and this message came from 2 with tag 0: 'Hello, I'm 2, you must be 3'
I'm 5 and this message came from 4 with tag 0: 'Hello, I'm 4, you must be 5'
I'm 7 and this message came from 6 with tag 0: 'Hello, I'm 6, you must be 7'
I'm 9 and this message came from 8 with tag 0: 'Hello, I'm 8, you must be 9'
I'm 11 and this message came from 10 with tag 0: 'Hello, I'm 10, you must be 11'
I'm 15 and this message came from 14 with tag 0: 'Hello, I'm 14, you must be 15'
cmd line history meme
April 16th, 2008
Rob tagged me
If you're reading this... Tag. You're it!
\m/ ~ $ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
57 cls
57 cd
48 rake
48 ls
42 emacs
35 exit
34 git
21 *****
18 gst
18 cap
\m/ ~ $
If you're reading this... Tag. You're it!
From 0 to Cruisin in One Script!
April 14th, 2008
I put together a script that does a complete cruise control setup on a fresh install of Ubuntu 7.10. All you need to do is run the script and it will setup MySQL, Ruby, Rails, Nginx, Subversion, Git, and the git enabled fork of CruiseControlrb. The script will setup the Nginx virtual host proxy to the cruise control instance along with init scripts for cruise and Nginx. After running this you will be completely cruise controlled!
This script does assume a few things in order to work properly. If you follow these instructions you shouldn't have any problems. These instructions should be followed immediately after installing Ubuntu or building your Ubuntu 7.10 VPS.
Edited on April 14, 2008 to fix svn url and suoders constraints
This script does assume a few things in order to work properly. If you follow these instructions you shouldn't have any problems. These instructions should be followed immediately after installing Ubuntu or building your Ubuntu 7.10 VPS.
% sudo adduser cruise
% sudo apt-get update
% sudo visudo #add cruise user to sudoers file
% sudo su cruise
% cd /home/cruise
% sudo aptitude install subversion
% svn co https://opensource.thinkrelevance.com/svn/system/ubunu/setup
% mv setup/go_cruisin.sh .
% sudo sh go_cruisin.sh
This will take a while to complete depending on your system. I usually use Slicehost for my VPS needs. On a well equipped Slicehost VPS this script usually takes around 10 minutes to complete. This is the first version of this script and I intend to make some more updates and require less user interaction, but I think this is a good start!Edited on April 14, 2008 to fix svn url and suoders constraints
Make sure you lock the doors!
April 10th, 2008
One of the trends that has been making itself much apparent as I do more audits is that people don't put firewalls up on their servers! This is a bad habit to get into. In order to take away some excuses i will post some basic firewall scripts for iptables (linux), and pf (openbsd). The following rulesets will firewall all ports but ssh on port 22, standard web, and SSL web.
Linux
*filter
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/255.0.0.0 -i ! lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j ACCEPT
COMMIT
Copy this script to /etc/iptables.rules and load the ruleset.
% sudo iptables-restore < /etc/iptables.rules
You can make sure your ruleset loaded properly by runnning:
% sudo iptables -L
If all is well then save your ruleset out like so.
% sudo iptables-save > /etc/iptables.rules
If you want the firewall to load when the interface comes up you need to add the following to your network configuration (Debian/Ubuntu based systems) in /etc/network/interfaces right before you define your interface.
pre-up iptables-restore < /etc/iptables.rules
OpenBSD
if="rl0"
set loginterface $if
tcp_services = "{ ssh, www, https }"
set block-policy return
scrub in all
antispoof for $if
block in all
pass out keep state
pass log proto tcp to any port $tcp_services
You can turn pf on my adding the follwing to /etc/rc.conf.local
pf="YES"
You can turn pf on from the command line by typing in the following
% pfctl -e
Emacs js2-mode FTW!
April 9th, 2008
Steve Yegge recently released a javascript mode for emacs. After giving it a try I can say that it's very nice! Stop on over to http://code.google.com/p/js2-mode/ and get yourself a copy. To make your life easier here's how you install it.
Thanks Steve!!!
- Download a copy and save it somewhere in your emacs load directory as js2.el.
- Fire up emacs and run M-x byte-compile-file RE js2.e
- Add the following to your .emacs file
1 2 3 |
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
|
Cruise Control init script
April 8th, 2008
I found some pieces of init scripts for cruise control online today and merged them into a nice init script for any debian / ubuntu based system. You can get the script at
http://opensource.thinkrelevance.com/browser/etc/init/cruise
Once you have the script just modify it and and the correct paths. Once you have things kosher just do the following.
% sudo mv cruise /etc/init.d/
% sudo chmod +x /etc/init.d/cruise
% sudo update-rc.d cruise defaults
This will make the cruise script executable and add it to the startup and shut down sequences. Now your cruise control can survive a reboot!
New nginx binaries for Ubuntu Gutsy
April 8th, 2008
I put up new Ubuntu binaries for 7.10. These are build from the latest stable version (0.5.35). This package will install the init scripts and all so you don't have to. You can get them at
http://opensource.thinkrelevance.com/browser/system/ubuntu/nginx/i386/nginx_0.5.35_i386.deb
http://opensource.thinkrelevance.com/browser/system/ubuntu/nginx/x64/nginx_0.5.35-x64_amd64.deb
Picture me Rollin' (To production)
April 7th, 2008
Last friday Muness pointed out to me a blaring problem with the Ruby version that is packaged with Ubuntu 7.10. It seems as though the packaged version you get with apt is 1.8.6-p36. This is not good, and is certainly not production ready. Now you're thinking to yourself "ok, I will just uninstall the packaged version and compile my own version". I always recommend against that whenever you can avoid it. Using the package manager that comes with your OS is always the best way to handle software for a number of reasons. The most important being updates and fixes are pushed to you and it's easy to update. Since I prefer using this method for installing software I took the liberty of re-packaging ruby for Ubuntu 7.10. I created all the possible ruby packages for both i386 (32-bit) and x64 (64bit intel / amd) versions of Ubuntu. You can grab the tarballs respectively:
http://opensource.thinkrelevance.com/browser/system/ubuntu/ruby/i386/ruby1.8-ubuntu-i386.tar.bz2
http://opensource.thinkrelevance.com/browser/system/ubuntu/ruby/x64/ruby1.8-ubuntu-x64.tar.bz2
Once you have the packages install them like so:
% tar -xvjf ruby1.8-ubuntu-(arch).tar.bz2
% cd debs
% sudo dpkg -i *
This will install all of the packages for you. If you have the other versions installed it will simply replace them with the new hotness. If you don't want all the packages you can pick and choose which ones you want just substituting the * with the full package name. Once you have done this you will have a real production ready version of ruby on your server and can feel a little bit better about your application's run-ability.
Obsidian - It's metastable
April 7th, 2008
I recently released a new gem into the rubyworld. It is a collection of useful code that I use everyday in every app i write. It will range from testing code to useful ruby core extensions and libraries. The relevance team will be contributing to this gem regularly and plan to do at least one release a week to the code. The first library that has been added is the model update tracker.
This library allows you to functionally test updates to models with clearer and more focused intent.
It forces you to have a better understanding of how your Objects interact and let's you demonstrate
that knowledge by putting it in your tests. For example instead of writing a test like so
you would write your test like so
Now if an asset really created multiple other objects such as an asset owner and a location the above
test would fail stating that it expected more to happen. This is where you excercise your deep domain
knowledge muscles and make your new obsidian powered test pass.
You have just done youself a great service. If for some reason you change code that affects your
object model and things fall out of place this test will catch that regression error where the original
assert_difference may not. There are also a whole host of other methods you can use with model update
tracker that provide functionality for updates, deletes, and no_difference assertions.
* assert_models_created(models)
* assert_models_updated(models)
* assert_models_destroyed(models)
* assert_no_models_created
* assert_no_models_destroyed
* assert_no_models_updated
You can install Obsidian via rubyforge.
1 2 3 4 |
assert_difference Asset :count do post :create, :asset => {} end |
1 2 3 4 |
assert_models_created(Asset) do post :create, :asset => {} end |
1 2 3 4 |
assert_models_saved(Asset, AssetOwner, Location) do post: create, :asset => {} end |
* assert_models_created(models)
* assert_models_updated(models)
* assert_models_destroyed(models)
* assert_no_models_created
* assert_no_models_destroyed
* assert_no_models_updated
You can install Obsidian via rubyforge.
sudo gem install obsidian
If you want to "git" the source directly you can grab it over at http://github.com/relevance/obsidian/tree/master/README.txt
No more dynamic languages for me!
April 1st, 2008
That's it, I give up. No more dynamic languages for me anymore! This whole idea of just creating a file and handing it to an interpreter to "assemble" for me. What of my memory management? What of my detailed traceability with gdb? Don't get me started with this whole "metaprogramming" and "DSL" garbage everyone keeps talking about. Who needs magic like that. That's just what it is. Magic voodoo that no one can understand. Seriously, WTF?
I for one am going back to programming in C where I can get all the control I need with the comfort of my precious gcc. I mean come on, why did I waste so much time learning C and make and all the other great tools associated just to dump them for some new craze. Hey Ruby guys, can you tell me what memory address your "object" sits at and how many pages it takes up? Yeah, thought so. I don't need people to collect and take out my trash, I can manage it myself thank you. You dynamic / interpreted language snobs really aren't much on memory hygiene. The funny thing is you refer to the C and UNIX geeks as the long haired, neck bearded dirty hippies and you are the ones who are all like "Ooohh our objects can be anything and respond to anyone" and "You don't need to program that, we can just meta eval it". Your free object love disgusts me.
So I am going to hole up with C, assembler, and edlin so I can once again be happy and comfortable with my programming.
I for one am going back to programming in C where I can get all the control I need with the comfort of my precious gcc. I mean come on, why did I waste so much time learning C and make and all the other great tools associated just to dump them for some new craze. Hey Ruby guys, can you tell me what memory address your "object" sits at and how many pages it takes up? Yeah, thought so. I don't need people to collect and take out my trash, I can manage it myself thank you. You dynamic / interpreted language snobs really aren't much on memory hygiene. The funny thing is you refer to the C and UNIX geeks as the long haired, neck bearded dirty hippies and you are the ones who are all like "Ooohh our objects can be anything and respond to anyone" and "You don't need to program that, we can just meta eval it". Your free object love disgusts me.
So I am going to hole up with C, assembler, and edlin so I can once again be happy and comfortable with my programming.


