⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% this module models a typical manager/worker pattern, where manager may spawn a large number of workers | |
%% required behaviour: | |
%% | |
%% 1) manager must log unexpected worker exits | |
%% | |
%% - manager must trap exits in init function -> 'process_flag(trap_exit, true)' | |
%% - workers must be spawned with spawn_link | |
%% - worker exit messages are handled by manager handle_info handler [where they can be logged etc] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(stopwatch). | |
-behaviour(gen_server). | |
%% Server API | |
-export([start_link/0, stop/0]). | |
%% Client API | |
-export([start_timer/0, stop_timer/0, read_timer/0]). | |
%% gen_server callbacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/racc | |
# -*- encoding: utf-8 -*- Lapis Racc Parser Class | |
# Andy Brown <[email protected]> [April, 12, 2010] | |
/* This is a BNF style parser generator grammar for the | |
* Lapis Language to be used by racc. Racc is a tool | |
* much like Yacc or Bison implemented for Ruby. | |
* | |
* Racc will parse this file and create a lapis.tab.rb | |
* file that contains a Parser class with a do_parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Discover the contribution status of a user for all their watched repos: owner, collaborator, or watcher | |
# Returns JSON { "repo" => { ... }, "owner" => is project owner?, "collaborator" => has collaborator access? } | |
# | |
# Returns either Array of JSON above; or streams each JSON result as discovered (--stream flag) | |
# | |
# Usage: | |
# | |
# Save to file github_user_collaborations.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:.unshift('~/rufus/rufus-tokyo/lib') | |
require 'benchmark' | |
require 'rubygems' | |
require 'faker' | |
require 'date' | |
# | |
# the data | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% File : recomendations.erl | |
%%% Author : Russell Brown <[email protected]> | |
%%% Description : The first chapter of Programming Collective Inteligence, but in elrang, like. | |
%%% Created : 15 Jun 2009 by Russell Brown <[email protected]> | |
-module(recomendations). | |
-compile(export_all). | |
%% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Network.Socket | |
import System.Environment | |
import Control.Concurrent | |
import Control.Monad | |
-- Port number to listen on | |
listenPort :: PortNumber | |
listenPort = 3000 |