Tag: Ruby

Brew Install Qt4 and Ruby Bindings

March 15, 2011 » Consume, Geek

The Ruby gem for Qt4 bindings, appropriately called qtbindings, do not build by default with brew installed Qt4 libs.

There is a quick fix, but it’s hidden in the issues on github. Essentially you just need to symlink the brew headers to an expected location.

$ for DIR in /usr/local/Cellar/qt/4.7.1/lib/*.framework; do ln -s $DIR/Headers ${DIR%%/lib/*}/include/$(basename $DIR .framework); done

After that is run, gem install qtbindings runs like a champ.

Tags: , ,

Learning Ruby: Unpacking Arrays

October 25, 2010 » Geek

So, about a week or go I dove back into Ruby out of necessity. The Twitter daemon I had written in Python for Confurrent was chronically ill. My socket would block and eat 100% CPU and it seemed like nobody knew how to work around it, least of all me.

So I pulled out Ruby. I’ve only ever done any real Ruby work with Rails, when I wrote ThirtyDayList to learn the tech.

One thing I will note is that learning Rails basics does not teach you Ruby, or at least not enough Ruby to be useful. However, writing my Twitter daemon has made me confident in Ruby, and I like it a lot more now than after the Rails experiment.

The daemon was quick to write, using Tweetstream, and I only ran into one roadblock, which was all my fault.

See, I wanted to use the track method, which takes an unlimited and variable set of arguments (like *args in Python) but I had my arguments in an array. I could not figure out how to pass those on correctly, and even bust into the gem and started adding code to get it to work.

I finally realized that there is no way that there isn’t a built-in for this and I went back to Googling. A short while later I found a short post from detailing exactly what I should be doing.

Evidently you can use the asterisk to unpack an array for this. Super easy, but I feel silly for not finding that sooner. The pitfalls of unfocused autodidactism.

The Wrong Way

predicates = [ 'a', 'b', 'c' ]
@client.track( predicates )
# Tracks 'abc'

The Right Way

predicates = [ 'a', 'b', 'c' ]
@client.track( *predicates )
# Tracks 'a,b,c'


December 11, 2009 » Geek

I just pushed out my first Ruby on Rails application a few days ago, and the shakedown cruise is going well.

You can check it out at ThirtyDayList.com if you want. There are still some features I want to add and it needs to be DRY’d out, but I’m happy with it.

I used the book Rails for PHP Developers which was pretty good and brought me up to speed without much fuss.

I have to say, I’m really digging Ruby and I’m really digging Rails. It’s nice to not really have to worry about all your database stuff, ActiveModel takes care of the hard parts.

Tags: ,

MySQL & Ruby on Debian (sidux)

May 21, 2009 » Geek

I’ve started learning Ruby on Rails, and I needed the mysql driver. Should be simple,
right? Just gem install mysql or something?

It wasn’t.

[email protected]:~# gem install mysql
Building native extensions.  This could take a while...                                                                              
ERROR:  Error installing mysql:                                                                                                      
        ERROR: Failed to build gem native extension.                                                                                 

/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
        from extconf.rb:1                                          

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out
[email protected]:~#

Once tangled mess of Google, Debian, and Ruby later, I found a bug report and a solution (for me at least).

Debian Bug 373843 – Long story short, you need ruby1.8-dev or, it appears, libmysql-ruby.