Prev PageNext Page
How to Fix Line Wrap Bug in iPython Terminal on OS X Mavericks
There is annoying line wrap issue present after installing iPython on OS X Mavericks for the first time. The issue has to do with readline being missing. To fix the problem uninstall iPython, install readline and then install iPython. pip uninstall ip...
Written by Sean Behan on 10/26/2013
Change the Default Controller Name in Rails Functional Tests
Rails will infer the controller you want to test from the class name of the test case. For example... class PeopleControllerTest < ActionController::TestCase end will test the app/controllers/people_controller.rb. To change this is trivial. Us...
Written by Sean Behan on 10/23/2013
How to Use RVM and POW with Ruby 2.0.0
In your project's root directory add a .ruby-version file and add the ruby version to the file ruby-2.0.0-p247 Next source RVM in the .powrc file, also in your project's root directory. source "$rvm_path/scripts/rvm" rvm use `cat .ruby-versio...
Written by Sean Behan on 10/19/2013
A Couple of Usefule Snippets When Working with Textmate
Here is the snippet f path/to/directory 'search string' | open_in_mate This snippet (technically 2 snippets) will recursively scan the contents of files in a directory and then open all the files it finds in Textmate. It's useful on large projec...
Written by Sean Behan on 10/18/2013
How To Pipe To A Ruby Command Line Application
You need to read from STDIN rather than parse command line arguments. while $stdin.gets puts $_ end
Written by Sean Behan on 10/17/2013
How To Write Your Own Time Comparison Function in Ruby Like time_ago_in_words Without Rails
# time_ago_in_words(Time.now, 1.day.ago) # => 1 day # time_ago_in_words(Time.now, 1.hour.ago) # => 1 hour def time_ago_in_words(t1, t2) s = t1.to_i - t2.to_i # distance between t1 and t2 in seconds resolution = if s > 29030400 # seco...
Written by Sean Behan on 10/17/2013
How to Boot Up Multiple Sinatra Applications at the Same Time with Foreman
Foreman is a process management gem for ruby applications. It is used in combination with a Procfile for configuration instructions. A typical Procfile looks something like this [name] : [script to execute] Example Rack application Procfile ...
Written by Sean Behan on 10/15/2013
How to Render Partials with an Underscore in Sinatra
Sinatra doesn't have a method for rendering partials. It defers to the template language of your choice. For instance, if you're using ERB, it's as simple as erb :'path/to/partial' Rails has a nice convention of using an underscore to mark file...
Written by Sean Behan on 10/13/2013
How to Split a Large File Into Smaller Files on OSX or Unix
Use the split command. split -l 1000 name-of-file output/directory You can set the number of lines (the "-l" flag) to split on and also the location of where the split files should be saved. Note, the output directory must already exists....
Written by Sean Behan on 10/08/2013
How To Remove Duplicates From a Table with Postgres
Let's create a table that will hold some dummy data. > create table fruits (id serial primary key, name varchar, color varchar); > insert into fruits (name, color) values ('apple', 'red'); > insert into fruits (name, color) values ('ap...
Written by Sean Behan on 10/08/2013
Prev PageNext Page