Nov 112013

I’m back from Rubyconf.

Some people say Ruby is dead. We can probably gloss over Zed Shaw’s famous rant, since it’s from roundabout 2007. My understanding is that the thought came about because of the many new trends in programming languages: first node, then Erlang’s comeback and the birth of Elixir. Evented programming, non-blocking IO, all the fancy buzzwords, and everyone craps on Ruby’s Global Interpreter Lock.

Given the talks at Rubyconf, Ruby is most likely not dead (and our internal rubylist has an ongoing recent conversation about this if you’re curious). There were talks on API design, on fault-tolerant data, on machine-learning, on parallel execution and concurrency, a talk on Raft (an algorithm to obtain consistency)…

Ruby’s ecosystem is certainly doing a lot of hard work to stay current. If you use Rubinius or JRuby, you can leverage a ridiculously powerful library called celluloid, plug in celluloid-io and use reel, a webserver based on celluloid-io. Here’s the quick blurb on celluloid-io: Celluloid::IO provides an event-driven IO system for building fast, scalable network applications that integrates directly with the Celluloid actor library, making it easy to combine both threaded and evented concepts. Celluloid::IO is ideal for servers which handle large numbers of mostly-idle connections, such as Websocket servers or chat/messaging systems.

Oh, and I haven’t mentioned the cherry on top of the cake yet! Opal is a ruby to javascript source-to-source compiler. It also has an implementation of the ruby corelib. It has come a REALLY long way. It passes a large amount of tests from the Ruby specs. You can write jquery with it. You can write CSS with it. In short, it is pretty close to making Ruby into the one-stop-shop for web apps: it allows you to create objects which are representations of what you see on the screen. No more do you have to separate your HTML from your CSS or your Javascript. Check out slide 339 of the Rubyconf presentation to see an example. And feel free to check out the entire presentation, there’s lots of goodies.

In short, Ruby’s doing pretty well.

Feb 022013

More to the point, should Rails die?

Rails brought a lot of great things – it made it dumb easy to package an entire app together. It abstracted the complexity of the storage layer. It created an entire market. Things like Heroku, Railsonfire/codeship and other companies turned a profit by extending the benefits of Rails. And things like Capistrano were born.

Everything that can be automated should be automated.


This has brought great things. And people wrote more tests, and life was good. But then, Rails apps grew, and people realized they had written them badly – because they interleaved their code within Rails, instead of using Rails as a layer and building their code on top of it, carefully segmenting the access points to that layer. Gosh, that sounds like work! Enter things like Avdi Grimm’s Object On Rails. And the Rails community re-learns things that the Java community has suffered through and grown past. Dependency Injection is making a comeback, Ruby-style. People use TDD as an indicator of design smells – if you have to boot up Rails to run your tests, you’re doing something wrong! Although of course SOME tests require the entire Rails stack, but we call these Capybara tests, because “end-to-end” is ugly, and capybaras are much prettier to look at.

And then, on the other hand, you have Sinatra, and Backbone.js, and other things that are focused on doing one thing and doing it well.

Now we have everything that Rails has taught the Ruby world – segment your logic, stay away from expensive code (the only currency here is time, and this is a very important thing to realize). Your TDD loop should be very short – you can watch some of Gary Bernhardt’s screencasts on Destroy All Software to learn mor about this. We have Capistrano, and Capybara. We have RSpec. We have Opal, a Ruby-to-Javascript compiler.

And in case Opal is too weird for you, you’ve got the Backbone.js world, where you have to make all these exact decisions over again.

You’ve got Sinatra, a wonderful “controller”. Sinatra is a great place to put your API and test it. Because that is the only thing Sinatra gives you, you feel the pain every time you add something — you have to add it.

And your storage is now distributed. Imagine … Backbone.js front-end, Sinatra in the middle, and your distributed storage of choice on the other side: Google Drive, Apple Cloud, Dropbox, MediaFire … You pick it, you store to it. Users now carry their data everywhere. Virtually speaking, of course. Gosh, sounds like you’re even reducing costs.


So now, we face the challenge the health world has been trying to solve for over a decade – how do you share information between proprietary systems? After all, the user is the one who’s suffering.

This is an entirely different blog post – how much of “your” data really is yours? How much could be shared? You know.. Like one of those virtual business cards, I suppose. You’d have a JSON object behind a secure server where the user stores THEIR information, and you ask for permission to read that one object.

Jun 112012

If you’re using Devise and rspec on Rails 3, and you want to override a controller, and you end up with an error that makes no sense whatsoever:

“Undefined method ‘name’ for nil:NilClass”, well then, you probably want to add the following line to your tests:

@request.env[“devise.mapping”] = Devise.mappings[:admin]

Yeah… That took me way longer than expected.

On a COMPLETELY UNRELATED SIDE NOTE, pry is pretty cool when you end up having to step through code…

Apr 112012

Here are the things you need to know about using any new font for Rubymine:

  1. It needs to be Unicode
  2. It needs to go into the $JDK_HOME/jre/lib/fonts directory

That is absolutely it. The last thing is the Monaco font, which I have attached for your downloading pleasure. It turns out DejaVu Sans Mono just isn’t as nice — however nice it may be — and Inconsolata XL doesn’t quite do it for me either.

Dec 152009

Open source is wide open: Calling RAKE tasks.

Good to know.

Sep 252009

If you get this error : Mysql::Error: query: not connected: or one just like it, it’s because you need an older DLL.. Which I just happen to have found, because I needed to fix this problem too!


Sep 142009

Just a link:
Something for me to read and digest later when I have time.

Sep 112009

This is known to work on ASE 12.5.1 – you’re welcome to let me know what else worked, I am particularly curious about later versions of Sybase ASE, such as 15.


  1. Sybase PC Client 12.52
  2. The Ruby Sybase  files
  3. gem install activerecord-sybase-adapter -s

Put the Sybase files in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt .

Copy all the DLLs in %SYBASE%\OCS-12_5\dll and put them in %RUBY%\bin (if you are not familiar with Windows notation, this simply means to go where you installed each of Sybase and Ruby and then go to the proper subdirectory). Why all of them? Well, because I’m too lazy to know which ones we -do- need.

Set some environment variables, just to make sure Sybase works fine:

Right-click on My Computer, Properties > Advanced > Environment Variables
If you have full permissions, go ahead and add those as SYSTEM VARIABLES.. Otherwise, well, only for your user (but aren’t you doing this on a server?).

SYBASE=c:\sybase    (where you installed Sybase).

JDBC_HOME=c:\sybase\jConnect-6_0   (again, where you installed Sybase, then the subdirectory).

CLASSPATH=%JDBC_HOME%\classes\jconn3.jar (just make sure that’s the right number).

If you’re going to create a user on your Sybase server for specific Rails usage, it needs to have SELECT permissions on the following : sysobjects, syscolumns, systypes, syscomments.

Edit your %SYBASE%\ini\sql.ini and add the information for your server in there.

Next.. In Rails, the magic will look like this in database.yml :

adapter: sybase
database: <YOUR_DB_HERE>
username: <USERNAME>
password: <PASSWORD>

And that should be pretty much it!

Don’t forget to edit your model if you’re working with legacy data:

class Patient < ActiveRecord::Base
set_table_name "some_odd_name"
set_primary_key "some_primary_key_column"
Sep 042009

Short post to give a link to the HAML plugin for Netbeans:
Download and install

And I get to test my wordpress-livejournal-twitter-facebook crossposting mania!

Sep 022009

If you’ve done any kind of table display in Rails, you’ve probably discovered the useful ‘cycle’ method:


This works after you’ve set two CSS classes between which you want to alternate – in my example, even and odd, because I have such amazing imagination. Come to think of it, to make my code more readable, it should be ‘lightbg’ and ‘darkbg’, or something similar. I’ll fix that.

But yeah – how do you do that in HAML?
Piece of CAKE (in this case, it is not a lie).

%tr{:class => cycle(‘even’, ‘odd’) }

%d bloggers like this: