Archive for the ‘Ruby’ Category

Programming Language Rankings

January 10th, 2012 No comments

The Tiobe index is total rubbish. But it’s worse than useless. It’s actually harmful. As Tyler Cowen mentioned in his TED Talk, “Be suspicious of stories”, feeling like you know what’s going on is way worse than admitting you don’t have a clue:

The most dangerous people are those that have been taught some financial literacy

Undoubtedly, there are people out there choosing careers and technologies based on the information age’s “divining by chicken bones”.  Tiobe is based on search engine hits for goodness sake. In the uber-democratic-everyone’s-a-technical-blogger web, of what is “talking about a language” a good indicator? Here is a primary one: that the language and its tools are not sufficient to support development. In other words, the Niobe Index (i.e. search engine results) is inversely proportional to language quality, as seen below:

Since the equation above is obviously scientific (because it seems “mathy” and nerdy), it must be true. Furthermore (another great smart-people word), if one believes in (yes, like Santa Claus) the Niobe index (which can only be believed because it superficially seems scientific), one must believe my equation, which creates a paradox (another great science-y term).

In a live, open, dynamic environment (like Smalltalk*), the programmer has at their fingertips most of the things they would otherwise be forced to search the internet for, which is succinctly described by Torsten Bergmann. Also, working in a low level language, like C++ (e.g. manual memory management), guarantees search engine love. I used to need a Safari Books membership just to make sure I didn’t shoot myself in the foot.

Further reading:

* I am not pushing Smalltalk. In fact, I can’t wait until someone invents something better (hint, cough; VPRI).

Categories: Programming, Ruby, Smalltalk Tags:

Cocoa Smalltalk App

December 20th, 2011 No comments

For a while, I’ve been thinking about using MacRuby for native UIs and multiple windows in Pharo on the Mac. I uploaded a proof of concept to . It has a simple Cocoa UI that uses http to get a value (the current time) from a running Pharo image and displays it in a text field. See the discussion on the Pharo mailing list.

Categories: Mac, Pharo, Programming, Ruby, Smalltalk, Xcode Tags:

MacRuby outlets don’t appear in Interface Builder (fixed)

December 20th, 2011 No comments

Xcode 4.1 had a bug where IB did not recognize outlets in MacRuby classes. It is corrected in Xcode 4.2. However, if you upgrade to 4.2, you must then reinstall MacRuby for MacRuby outlets to start working again.

See this StackOverflow thread for the more information.

Categories: Ruby, Xcode Tags:

Love poor technology for simple tasks

April 25th, 2011 No comments
I Have a Dream

If I had my way, I would never leave my Smalltalk image.

It’s not just the Smalltalk language (although I do enjoy the Zen-like minimal syntax, and keyword arguments flow off the keyboard like conversational speech). The real gold is the live, open environment, and control over everything in my system, almost down to the metal.

Reality Sets In (but it’s not so bad this time)

Yet sometimes, for a quick and dirty throwaway script, a tool symbolizing poor design is perfect.

For example, I wanted to change the artist info of a batch of tracks in iTunes. In less? time than it would have taken me to google a solution, I had whipped up an AppleScript (yes, ouch) in AppleScript Editor (double ouch):

tell application "iTunes"
	set wrongName to ""
	set rightName to ""
	set track_list to tracks of playlist "Music" of source "Library" whose artist is wrongName
	repeat with t in track_list
		set artist of t to rightName
	end repeat
end tell

Yes, I could have used rb-appscript to script from Ruby, which I usually do. But, AE gave me easy access to iTunes’ scripting dictionary, a nice little “Run” button, and an output pane. For this tiny script, I was done before I started to suffocate from being outside the oxygen of my live, open Smalltalk image.

So, thank you Apple, for creating the infuriating AppleScript language, to be written with the puny AppleScript Editor, and for not even making many of your own applications scriptable ([cough] even while evangelizing scriptability to Mac devs in your docs. Today, I was grateful for it all. Editing info on hundreds of tracks was much quicker than writing this post about it :)

Categories: Applescript, Programming, Ruby, Smalltalk Tags:

Adding Quicklook support for Ruby files with different/no extensions (e.g. rake files)

March 4th, 2010 No comments

1. Download the excellent qlcolorcode bundle from Google Code

2. Add the following line to QLColorCode.qlgenerator/Contents/Info.plist:

So that it looks like this:
3. In QLColorCode.qlgenerator/Contents/Resources/, add (and customize) the highlighted code, which you can get at github:
4. Oops!  Forgot, you may have to sudo touch /path/to/QLColorCode.qlgenerator for changes to take effect
Categories: Mac, Ruby Tags: , ,

Quicklook any plain-text file e.g. HAML or ERB

March 3rd, 2010 No comments

I’m often jumping from file to file in Rails, so I really wanted Quicklook support for my template files.  Unfortunately, the suggestions I found online were confusing and incomplete.

Here’s a really easy way to get it done – but no syntax highlighting :(

1. Show the contents of TextEdit’s package

2. Open Info.plist in a text editor… like TextEdit, perhaps… hmm…
3. Anyway, add the following snippet (find the code on github):

Put it just before the following section:

4. Customize
  • UTTypeDescription - put in description of your choice (although you probably don’t need to)
  • UTTypeIdentifier – apparently (and this is what was missing from other descriptions), you just make something up here
  • public.filename-extension – add as many extensions as you want to map to this file type
5. Gloat

Categories: Mac, Rails, Uncategorized Tags: , , ,

Rails text_field_with_auto_complete and Formtastic

March 1st, 2010 No comments

Formtastic is an awesome gem to make form creation easy and fun. Rails built-in autocompletion feature is also easy to use and a great service to users. However, they don’t play well together out of the box…

As you can see, the popup auto-complete menu and controls that follow are all jumbled up.  Luckily, the fix is very simple (after spending hours yelling at the computer, lol).  In formtastic_changes.css, add the following (get from github):

And everything’s right as rain…

Categories: Rails Tags: , ,

Reload Rails server to recognize plugins

March 1st, 2010 No comments

I’ve been following the excellent videos at, but many times (especially after loading plugins or changing my layout files), I wouldn’t get the result from the video. What I found was that I needed to restart the Rails server to have the changes take effect. I remember for sure this happened while implementing the auto_complete text_field functionality.

Categories: Ruby Tags: , ,

Autospec with custom directory/file names

January 17th, 2010 No comments

Autotest is a great time-saver when doing BDD (or TDD for the less-enlightened, lol).  Autospec seemlessly integrates Rspec.  However, if you don’t use the expected “spec/*_spec.rb” structure, autotest will not find your specs – or examples, as I call them.

It is very easy to use whatever structure you want using the following steps:

Telling Autotest to use Rspec as the test runner

The first thing you want to happen is for Autotest to use Rspec as the test runner.  This usually happens automatically using autospec, which tests for the presence of the spec directory.  Since we do not want a spec directory, we must tell explicitly tell Autotest to do this.  So:

Step 1: in your project directory create a file autotest/discover.rb with the following line:

Autotest.add_discovery { "rspec" }

Teaching Autotest about our custom directory structure

In order to do this, we have two options.  If we want to use the same structure for all our projects, we can put a file in our home directory, otherwise we can add custom files to each project directory.

Step 2: create a file .autotest with the following code:

class Autotest::Rspec < Autotest remove_method :consolidate_failures def consolidate_failures(failed) filters = new_hash_of_arrays failed.each do |spec, trace| if trace =~ /\n(\.\/)?(.*example\.rb):[\d]+:/ filters[$2] << spec end end return filters end remove_method :add_options_if_present def add_options_if_present # :nodoc: File.exist?("examples/spec.opts") ? "-O examples/spec.opts " : "" end end Autotest.add_hook(:initialize) {|at| %w{.git .svn .hg .swp .DS_Store ._* tmp}.each do |exception| at.add_exception(exception) end at.clear_mappings # take out the default (test/test*rb) at.add_mapping(%r%^(examples|third_party)/.*_example.rb$%) { |filename, _| filename } at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["examples/#{m[1]}_example.rb"] } at.add_mapping(%r%^examples/(example_helper|shared/.*)\.rb$%) { at.files_matching %r%^(examples|third_party)/.*_example\.rb$% } #nil }

Let’s take it piece by piece:

def consolidate_failures(failed)
  filters = new_hash_of_arrays
  failed.each do |spec, trace|
    if trace =~ /\n(\.\/)?(.*example\.rb):[\d]+:/
      filters[$2] << spec
  return filters

This method tells Autotest which test files have failed by pulling the file names out of the test output. Since autospec looks for *_spec.rb files, it will not find our custom files. I use *_example.rb filenames, so you should replace that part of the regex with whatever you use.

def add_options_if_present # :nodoc:
    File.exist?("examples/spec.opts") ? "-O examples/spec.opts " : ""

This method tells Rspec where to find an option file. Again, replace the details with whatever you use.

In Autotest.add_hook(:initialize):

  %w{.git .svn .hg .swp .DS_Store ._* tmp}.each do |exception|

This tells Autotest to ignore certain files that are irrelevent to testing


This tells Autotest not to use any other mappings i.e. the default test/test*rb, or Rspec’s spec/*_spec.rb

at.add_mapping(%r%^(examples|third_party)/.*_example.rb$%) { |filename, _|
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
at.add_mapping(%r%^examples/(example_helper|shared/.*)\.rb$%) {
  at.files_matching %r%^(examples|third_party)/.*_example\.rb$%

This is the meat of the customization. It tells Autospec, based on which files have changed, which tests to run. Replace my regexes with your custom matches.

The end

Once you have added both these files, running autospec from your project directory will work as it should!

Ruby, Vim, and Windows

December 11th, 2009 2 comments

It is unbelievably easy to create a wicked setup, although I spent half a day googling to narrow it down to the exsentials:


  1. Ruby with the One-click installer.
  2. Vim’s self-installing Windows executable (this comes with many customizations you read about online, and ruby support, included)
  3. snipMate, a plug-in that automatically expands common Ruby constructs (e.g. you type ‘cla<tab>,’ which becomes class…end with placeholders!)
  4. AutoComplPop (must have!!!), an autocomplete plugin very much like Xcode’s – start typing and a popup list of completion options appears.  superTab, another plug-in that allows you to use tab to auto-complete Ruby code
  5. wombat, a great color scheme

Global configurations

Add the following settings to /path/to/vim/_vimrc.

note: the autocomplete menu colors, and vim’s default font are disgusting, hence the changes.

Ruby-specific Configurations

In the vimrc above, the following is added:

  • the first line sets up superTabs to look in the right place for Ruby completions (I use AutoComplPop now, see above)
  • adds line numbers to several source code file types
  • changes the ridiculous 8-space tabs to 2

That’s it!  Happy coding :)

Categories: Programming, Ruby Tags: , ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip