Prev PageNext Page
Testing current_user and Sessions with Sinatra and Rack Test
Assume you have your standard Sinatra application. # app.rb require 'sinatra' configure do enable :sessions end get '/' do if session[:user_id] "OK" else raise "NOT OK!" end end To test this you need to make a re...
Written by Sean Behan on 08/22/2013
How To Use Rake to Run Your Test Suite with Sinatra
If you're using Sinatra and you want to use rake to run your test suite, you will need to create a Rakefile and put this in it. require 'rake/testtask' task :default do ENV['RACK_ENV'] = 'test' Rake::Task['test'].invoke end Rake::Test...
Written by Sean Behan on 08/22/2013
Pretty Formatted JSON from the Command Line
Sometimes you want to see JSON from the command line. I'm sure there are better tools for the job, but here is a little snippet you can throw in your ~/.bash_profile. function json { curl -s "$1" | python -mjson.tool; } Usage json https://g...
Written by Sean Behan on 08/21/2013
Deploying Wordpress on Heroku
> This post is out of date - Heroku officially supports PHP now w/ buildpacks Heroku runs Apache version 2.2.22 PHP version 5.3.10 Deploying Wordpress to Heroku requires that you throw the Wordpress source into a Git repository. So download th...
Written by Sean Behan on 03/02/2017
The Best Video About How to Make Money Online
This is one of my favorite videos on the internet. It is what got me interested in Rails and made me work toward the goal of running my own business and hopefully soon, launch my own products. ...
Written by Sean Behan on 06/25/2012
Installing Ruby with RVM without Xcode using CLANG
I am not using the full Xcode package on my laptop. Instead I'm using the command line tools, offered by Apple as a separate and much smaller install. I haven't had too many issues, aside from not being able to use the FileMerge program that ships with ...
Written by Sean Behan on 06/24/2012
How To Export A MySQL Database to JSON, CSV and XML with Ruby and the ActiveRecord Gem
It's trivial to export data from a mysql database with Ruby and ActiveRecord. All you have to do is establish a connection and define a class that represents the table. require 'rubygems' require 'active_record' ActiveRecord::Base.establish_con...
Written by Sean Behan on 06/23/2012
How To Add A Route With A Forward Slash in Params with Rails 3 Application
Use an asterisk in the pattern to match for everything after it. In the example below, date will be available in the params hash as params[:date]. SPB::Application.routes.draw do # http://example.com/calendar/2007/10 # params[:date] => "2007/1...
Written by Sean Behan on 06/22/2012
How to Add Additional Sub Directories to the Default Rails Test:Unit File Structure
# Edit Rakefile in project root # # Add a new rake test task... E.g., rake test:lib, below everything else in that file... # Alternatively, add a task in lib/tasks/ directory and plop in the same code namespace :test do desc "Test lib source" ...
Written by Sean Behan on 06/17/2012
How to Create a Date Time Snippet in Sublime Text 2 (Dynamic Signature with Time Stamp)
You'll have to create a new plugin. From the menu bar select Tools > New Plugin Copy the Python script from the signature.py file. Remember to replace your email address (it's example.com). Save the file, signature.py, is fine. Next open up Prefer...
Written by Sean Behan on 06/17/2012
Prev PageNext Page