Category: Computing

March 17th, 2011

Ruby Without Beer

On Thursday evening I went to my first Toronto Ruby Brigade meetup, and thoroughly enjoyed three talks on Ruby covering testing, Ruby’s object model, and some Ruby “gotchas”. I’m looking forward to the next meetup.

This year I have given up alcohol for lent, with the exception of Sundays, so I didn’t head out and socialize afterwards.

November 12th, 2010

Seven Languages in Seven Weeks

Seven Languages in Seven Weeks from the Pragmatic Programmers is in print, so it’s time to allocate some time play with them.

Yesterday and today are the first couple of days of Ruby – luckily I already know Ruby a bit (!) so the time I put in to switch from cinderella to “raw” homebrew and rvm hasn’t dented the schedule too much.

Whether the seven weeks will happen sequentially I don’t know, for the sake of amusement I’ll put the code up on github.

October 27th, 2010

Inspirations from an Open Plan Office

October 11th, 2010

A Fun Family Outing

A few weeks ago Jeff Potter swung through Toronto doing a “do it yourself” tour promoting his book Cooking for Geeks. This post is a wholehearted recommendation for the book.

Cooking for Geeks cover

Cooking for Geels

My wife and daughter are both into cooking, and I enjoy eating, so it seemed like a good excuse to support an O’Reilly author and have an evening out with the family. The event was early in the evening at Camaraderie a small shared coworkign facility conveniently located on my way home from work.

There was a good sized crowd there, and Jeff gave an entertaining and informative presentation. To say too much about the content would spoil the fun of reading the book – the main novelty to me was the sous-vide technique.

Cooking seems to be a sweet spot for people who enjoy hacking hardware and have a scientific approach to cooking – we just have to be careful to understand what needs to be done to avoid growing unpleasant bugs, or letting them generate lots of unpleasant toxins.

The book itself is a good read with a variety of recipes, interviews, kitchen tips, suggestions for equipment procurement and modification, experimets to get started with, as well as explanations of some of the mechanisms at work in the kitchen. It is well worth the investment in time and money.

September 26th, 2010

Cinderella and Story Telling – Have a Point!

This is a story about a well intentioned but unskilled blog writer. Let’s call him Mike. He started blogging to learn about writing amongst other things.

Today’s lesson is to remember to have a point for each post if the post is meant to impart some useful nugget of wisdom. Some posts are less focused narratives, in this case the point of the post is to tell a story. For both kinds of post having an understanding of “the point” makes it easier to write and review the post, and might make the post more useful to readers, including himself. As an example:

Recently he wanted to tell a colleague how he had installed rvm on his mac. “No problem,” he thought “I’ve blogged about it, so I’ll be able to figure it out.” Alas no. Digging around in the blog posts revealed a mass of confusing detail which was not that enlightening in retrospect.

It might have help to outline the post:

  • What was the point?
    • To describe setting up up a development environment on a Mac which allowed for running rvm without requiring administrator access (with the concomitant risk of messing up the system).
  • What was the solution?
    • Install cider, now called cinderella, which itself installs homebrew and rvm all under ~/Developer.
  • Were there any problems?
    • Minor speedbump in the initial install from the cinderella (née cider) site instructions. He needed to add himself to the staff group using dseditgroup -o edit -u mike -p -a mike -t user staff
  • Is this likely to be reference material?
    • Hmmm, maybe he needs to add a page about his OS X development environment, rather than posts…

If he had thought “What is the point of this post?” and “If someone comes to this post in a few months will is be useful to them?” before hitting the Publish button then the post might have been a lot more useful. Maybe he’ll keep these points in mind when posting in future.

The point of this post was to record something I learned about writing on my blog. Maybe it will help me write better entries in the future.

August 29th, 2010

Slimming Down

A couple of things have happened recently which have highlighted ways I can slim things down a bit in terms of the number of things I need to keep track of and change the way I behave.

Thanks to homebrew, rvm, and MacVim I was well on my way to eliminating my use of VirtualBox for doing some of my own “tinkering” using a recent Ubuntu Linux as a familiar environment (I don’t have anything against Linux, it’s just less hassle for me not to have to start up a virtual machine to do some development…)

Ad a recent Toronto Perl Mongers meeting someone asked me about the modules I mentioned in a talk earlier this year and wondered if he could see the code. This had a cascade of effects:

  1. I put the code on GitHub so he could see it.
  2. I installed perlbrew and perl-5.12.1 on my Mac so I could start installing modules without breaking the system perl.
  3. I started updating some of the things I wanted to fix, but somehow hadn’t got around to fixing.
  4. I started goofing around with other Perl modules gratuitiously – for example using Moose to add a couple of attributes to a class despite its apparent ugliness, or common::sense rather than strict and warnings.

It’s amazing how the thought of other people’s eyes on my code are better motivators than my own diligence.

As the Toronto Perl Mongers web site generator was the only project of consequence I was doing on mu Linux VM I finally got to delete the old Linux VM and am now working in a pure OS X environment.

Using Moose has started slimming down my modules, as much of the boiler plate code seems to vanish.

My home tinkering environment has slimmed down, but I suspect the pitcher of beer and chicken fingers at the Perl Mongers meeting has caused some equal and opposite reaction in me!

August 7th, 2010

map_by_method and awsome_print

I have been playing with some of the gems I installed for my rvm rubies, and the first couple I have looked at are pretty simple – map_by_method and awsome_print.

My trivial code snippet is here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby

# Trivial class with name and gender methods
class Person
  attr_reader :name, :gender

  def initialize(name, gender)
    @name, @gender = name, gender
  end
end

require 'rubygems'
require 'map_by_method'
require 'ap'

people = [ Person.new('Mike', 'M'), Person.new('Derek', 'M')  ]
ap people.map_by_name
ap people.map_by_name_and_gender

Other blog posts about these gems include http://rpheath.com/posts/246-map-by-method-gem and http://www.rubyinside.com/awesome_print-a-new-pretty-printer-for-your-ruby-objects-3208.html

July 24th, 2010

cider, rvm, and homebrew

The rails installed by cider is a rails 3 beta. As I want to play with some of the examples for rails 2 I thought I should get the most recent ruby 1.8.7 and try to use rvm’s gem sets to get myself a rails 2 world set up

brew install `brew outdated`
rvm install ruby-1.8.7-p299
rvm --default ruby-1.8.7-p299

Was my first step to this, but when I tried irb this is what I saw:

ratdog:~ mike$ irb
no such file to load -- map_by_method
ruby-1.8.7-p299 > q

The cause of this was my ~/.irbrc which had been set up, and which has a whole bundle of useful gems added into it. Most of these are worth a post by themselves, but the suspects were:

  • map_by_method
  • what_methods
  • awesome_print
  • net-http-spy
  • hirb
  • looksee
  • wirble
  • sketches

I set up an rvm gemset and started installing gems:

rvm gemset create rails238
rvm ruby-1.8.7-p299@rails238
gem install map_by_method what_methods awesome_print net-http-spy hirb looksee wirble sketches
gem install rails -v 2.3.8
rvm --default ruby-1.8.7-p299@rails238

All appeared to go well, until I tried navigating to a demo appliction and look at the environment on the default splash screen, which complained about a missing sqlite3 gem. The sqlite3 gem wanted at least ruby-1.9.1 installed, so it was time to install another Ruby.

The ruby-1.9.1-p429 had a problem with gems, but a quick trip to Yahoo! revealed this message, so it was time to install another ruby!

rvm install ruby-1.9.1-p378
rvm use ruby-1.9.1-p378 --default
rvm gemset create rails238
rvm use ruby-1.9.1-p378@rails238 --default
gem install map_by_method what_methods awesome_print net-http-spy hirb looksee wirble sketches
gem install rails -v 2.3.8
gem install sqlite3

Now I can get to work playing with rails! The great thing is that I haven’t compromised my system Ruby, thanks to cider, rvm, and homebrew.

July 14th, 2010

More New Toys

In an effort to get away from using Linux virtual machines on my Mac I am playing with perlbrew so that I can have multiple versions of Perl installed the way rvm lets me do with Ruby.

There seem to be more tools appearing for Perl to help maintain multiple versions of Perl and a controlled subset of CPAN on a system, and now I just need the time and inclination to play with them…

June 29th, 2010

Time to Learn Some More Tools

For a while now I have been put off programming by my daytime experiences, but a recent Ruby5 podcast has whetted my appetite for fun again.

The great thing I found was that the initial install didn’t quite go smoothly…

[Tue, 29 Jun 2010 07:42:01 -0400] INFO: Starting Chef Solo Run
[Tue, 29 Jun 2010 07:42:11 -0400] INFO: Replacing the run_list with ["homebrew", "homebrew::dbs", "homebrew::misc", "ruby", "ruby::irbrc", "ruby::rails", "ruby::sinatra", "node"] from JSON
[Tue, 29 Jun 2010 07:42:12 -0400] INFO: Setting group to 20 for template[/Users/mike/.cider.profile]
[Tue, 29 Jun 2010 07:42:12 -0400] ERROR: template[/Users/mike/.cider.profile] (/Users/mike/.rvm/gems/ruby-1.8.7-p299/gems/chef-0.8.16/lib/chef/mixin/recipe_definition_dsl_core.rb line 59) had an error:
Operation not permitted - /Users/mike/.cider.profile
/Users/mike/.rvm/gems/ruby-1.8.7-p299/gems/chef-0.8.16/bin/../lib/chef/provider/file.rb:118:in `chown'

… so now I have a chance to use rdebug on a real issue, and maybe get to learn something about OS X and the Ruby setup. I’m looking forward to learning more about Cider, and maybe having some fun again.

After a little fooling around with rdebug I decided that the most expedient thing to do was add myself to group 20 and see if Cider would install OK. A quick Yahoo search for adding a user to a group in OS X Snow Leopard led me to this post, and with a quick

dseditgroup -o edit -u mike -p -a mike -t user staff

The install seems to be progressing…

1 July 2010:

My goal was to leave the Snow Leopard install of Ruby alone, and see if I could get the entire thing set up without using sudo. Unfortunately that meant I had to install rvm (from tarball as OS X doesn’t have a git by default) and an rvm ruby to get going. When it tried to install the ~/Developer/… rvm it fell over.

So… use sudo to get cider installed as part of the OS X install and see what it does!

2 July 2010:

It looks like it’s more than just my Ruby which will get dusted off soon, Cider uses RVM which allows multiple rubies and gemsets, and Homebrew to manage installed software on OS X. I ought to know at least what all the programs and gems installed by Cider are, and maybe learn a few of them:

ratdog:~ mike$ brew list
ack		libevent	node		redis		wget
ctags		markdown	npm		rlwrap
fortune		memcached	postgresql	rpg
git		mongodb		proctools	sqlite
kiwi		mysql		readline	tig
ratdog:~ mike$ rvm list

rvm rubies

=> ruby-1.8.7-p248 [ x86_64 ]
ratdog:~ mike$ gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.0.beta3, 2.3.8)
actionpack (3.0.0.beta3, 2.3.8)
activemodel (3.0.0.beta3)
activerecord (3.0.0.beta3, 2.3.8)
activeresource (3.0.0.beta3, 2.3.8)
activesupport (3.0.0.beta3, 2.3.8)
arel (0.3.3)
awesome_print (0.2.1)
builder (2.1.2)
bundler (0.9.26)
configuration (1.1.0)
engineyard (0.3.2)
erubis (2.6.6)
escape (0.0.4)
heroku (1.9.9)
highline (1.5.2)
hirb (0.3.2)
i18n (0.3.7)
json (1.4.3)
json_pure (1.4.3)
launchy (0.3.5)
looksee (0.2.1)
mail (2.2.5)
map_by_method (0.8.3)
memcache-client (1.8.3)
mime-types (1.16)
net-http-spy (0.2.1)
polyglot (0.3.1)
rack (1.1.0)
rack-mount (0.6.6)
rack-test (0.5.4)
rails (3.0.0.beta3, 2.3.8)
railties (3.0.0.beta3)
rake (0.8.7)
rdoc (2.5.8)
rest-client (1.5.1, 1.4.2)
sinatra (1.0)
sketches (0.1.1)
termios (0.9.4)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.7)
treetop (1.4.8)
tzinfo (0.3.22)
what_methods (1.0.1)
wirble (0.1.3)