Skip to content

Instantly share code, notes, and snippets.

View gist:824bff4b6a6d0e5a17af
it "sorts the applications by the stage" do
+ first_stage = create(:phone_interview_stage, :hiring_plan => hiring_plan)
+ second_stage = create(:face_to_face_stage, :hiring_plan => hiring_plan)
+ first_application = create(:application)
+ first_application.current_application_stage = ApplicationStage.create(hiring_plan_interview_stage: first_stage, application: first_application)
+ second_application = create(:application)
+ second_application.current_application_stage = ApplicationStage.create(hiring_plan_interview_stage: second_stage, application: second_application)
willawill /
Last active August 31, 2015 14:53 — forked from rstacruz/
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User




willawill /
Last active August 28, 2015 14:01 — forked from steveclarke/
RSpec Matchers




willawill /
Created June 4, 2014 19:54
module.exports = (config) ->
# base path, that will be used to resolve files and exclude
basePath: '../'
frameworks: ['jasmine', 'mocha', 'chai'],
files: [
{pattern: 'app/**/*.js', included: true, served: true, watched: false}
{pattern: 'tests/**/*.js', included: true, served: true, watched: false}
willawill /
Created June 4, 2014 19:53 with Karma
gulp = require 'gulp'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
compass = require 'gulp-compass'
connect = require 'gulp-connect'
cached = require 'gulp-cached'
clean = require 'gulp-clean'
rjs = require 'gulp-requirejs'
karma = require('karma').server
karmaRunner = require('karma').runner
View gist:4543312
post '/ivrs/:id/trigger' do
p "here #{params}"
parameters = {to: params[:To],
from: params[:From],
answer_url: "#{ENV['SERVER_NAME']}/ivrs/#{params[:id]}/play",
res ="#{ENV['PLIVO_AUTH_ID']}", "#{ENV['PLIVO_AUTH_TOKEN']}").make_call(parameters)
post '/ivrs/:id/play' do
View gist:4533965
def build_response(from, commands)
response = do |c|
case c[:cmd]
when :reject
response.addHangup(reason: 'busy')
when :ivr
response.addHangup(reason: 'busy')
dial = response.addDial(callerId: from)
View gist:4502730
There are three questions I have.
1. Is it a good practice to massage the data when save it back to the database?
In my case, my params passed back from view looks like {"auto_text"=>"When the wheels come down?", "keyoption"=>{"1"=>{"key"=>"1", "option"=>"2"}}}
and I will break hashes and straighten it to a String which is the :read_text property in Ivr.
I am thinking if I should let Ivr has the key:option pair as it is, and generate the String when needed.
Then I can do presence validation and update later.
2. With Struct way, I don't know how to put it in my model.
3. With long string way, I don't know how to generate and assign back to the property.
willawill / gist:4076771
Created November 15, 2012 05:07
Haml indentation.
View gist:4076771
%h2= "ASKS"
-@campaign.asks.each do |ask|
=haml :ask, locals: {ask: ask, type: ask.class.typesym}
-if{|n| n.triggered_ask && n.triggered_ask == ask}.empty?
%form{action: "/campaign/#{}/broadcast}", method: "post"}
%button{type: 'submit'} Launch the Ask
%form{action: "/campaign/#{}/add_new_ask", method: 'get'}
%button Add new ask
willawill /
Created August 21, 2012 10:44 — forked from quad/
Achtung: a not very nice hotdog
# We have a few repeat customers here at the TWU 27 hotdog shack.
# They've decided it's FUN to visit our stand.
# So, we've cooked up something a little special for our valued customers.
set -e