Skip to content

Instantly share code, notes, and snippets.

@choxi
choxi / jobs_controller_spec.rb
Created April 28, 2011 13:49
Example of a Rails Controller Spec
###################### SPEC ######################
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe JobsController, "#new" do
context "admin" do
before(:each) do
session[:password] = ADMIN_PASSWORD
get :new
end
(master)⚡ % rake assets:precompile --trace ~/code/Bieber
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/roshan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/roshan/.rvm/gems/ruby-1.9.2-p290@holla/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
require 'rubygems'
require 'sinatra'
configure do
require 'redis'
require 'uri'
REDISTOGO_URL = ENV["REDISTOGO_URL"]
uri = URI.parse(REDISTOGO_URL)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end
@choxi
choxi / gist:1833315
Created February 15, 2012 04:50
views/index.haml
!!! 5
%html
%head
%title welcome visitor
%body
%h1 hello there
# This file will be copied to ~/.emscripten if that file doesn't exist. Or, this is that copy.
# IMPORTANT: Edit the *copy* with the right paths!
EMSCRIPTEN_ROOT = os.path.expanduser('~/Dev/emscripten') # this helps projects using emscripten find it
LLVM_ROOT = os.path.expanduser('/usr/local/Cellar/llvm/3.0/bin')
# See below for notes on which JS engine(s) you need
NODE_JS = 'node'
SPIDERMONKEY_ENGINE = [os.path.expanduser('~/Dev/mozilla-central/js/src/js'), '-m', '-n']
require 'spec_helper'
describe "Bookmarks" do
describe "GET /bookmarks" do
context "when user is not logged in" do
it "should redirect a to home" do
get bookmarks_path
response.should redirect_to(root_url)
end
end
namespace :db do
namespace :migrate do
desc "create an empty timestamped migration file"
task :new do
raise "Usage: rake db:migrate:new NAME='create_cohorts'" if ENV["NAME"].nil?
current_migration = Dir.glob("./db/migrate/[0-9]*_*.rb").collect do |file|
File.basename(file).split("_").first.to_i
end.max.to_i
@choxi
choxi / osx_lion_rail_setup.md
Created June 14, 2012 04:03 — forked from jpantuso/osx_lion_rail_setup.md
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, rails, and MySQL

Installation Update

A few of you have been having a lot of trouble with the "Laptop" script that's supposed to install a bunch of tools for you and I apologize for that, there are actually only 2 main tools that you need to have installed. If you haven't already done the developer setup yet, please follow these updated instructions instead:

Note: We'll be checking version numbers to make sure things were installed correctly, it's completely OK if your version number is not exactly the same as the ones I've given as examples below.

OSX Lion

If you're not on OS X Lion, you will need to upgrade to it. I should have mentioned that as an up front prerequisite, so if you do need to upgrade please let me know and I'll refund you $30 to cover the cost of the upgrade.

$modal = $("<div><ul></ul></div>")
$modal.css({
position: "absolute",
height: "500px",
width: "500px",
background: "white",
border: "1px solid gray",
padding: "10%",
margin: "5% 25%"
});
@choxi
choxi / naive_bayes.py
Created October 4, 2016 00:50
Naive Bayes for Natural Language Processing
#------------------------------------------------------------------
#
# Bayes Optimal Classifier
#
# In this quiz we will compute the optimal label for a second missing word in a row
# based on the possible words that could be in the first blank
#
# Finish the procedurce, LaterWords(), below
#