Skip to content

Instantly share code, notes, and snippets.

Avatar

Willa Wang willawill

View GitHub Profile
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)
+ first_application.save!
+ second_application = create(:application)
+ second_application.current_application_stage = ApplicationStage.create(hiring_plan_interview_stage: second_stage, application: second_application)
+ second_application.save!
@willawill
willawill / index.md
Last active Aug 31, 2015 — forked from rstacruz/index.md
Rails models cheatsheet
View index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to
has_one
@willawill
willawill / capybara.md
Last active Aug 28, 2015 — forked from steveclarke/capybara.md
RSpec Matchers
View capybara.md

Capybara

save_and_open_page

Matchers

have_button(locator)
View karma.conf.coffee
module.exports = (config) ->
config.set({
# 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
willawill / gulpfile.coffee
Created Jun 4, 2014
gulpfile.coffee with Karma
View gulpfile.coffee
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 = Plivo::RestAPI.new("#{ENV['PLIVO_AUTH_ID']}", "#{ENV['PLIVO_AUTH_TOKEN']}").make_call(parameters)
end
post '/ivrs/:id/play' do
View gist:4533965
def build_response(from, commands)
response = Plivo::Response.new
commands.map do |c|
case c[:cmd]
when :reject
response.addHangup(reason: 'busy')
when :ivr
response.addHangup(reason: 'busy')
dial = response.addDial(callerId: from)
dial.addNumber(c[:to])
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
willawill / gist:4076771
Created Nov 15, 2012
Haml indentation.
View gist:4076771
#asks
%h2= "ASKS"
-@campaign.asks.each do |ask|
=haml :ask, locals: {ask: ask, type: ask.class.typesym}
-if @campaign.asks.select{|n| n.triggered_ask && n.triggered_ask == ask}.empty?
%form{action: "/campaign/#{@campaign.id}/broadcast}", method: "post"}
%button{type: 'submit'} Launch the Ask
%form{action: "/campaign/#{@campaign.id}/add_new_ask", method: 'get'}
%button Add new ask
@willawill
willawill / lockit.sh
Created Aug 21, 2012 — forked from quad/lockit.sh
Achtung: a not very nice hotdog
View lockit.sh
#!/bin/sh
#
# 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
You can’t perform that action at this time.