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
<form id="google-voice" action="https://clients4.google.com/voice/embed/webButtonConnect" method="post"> | |
<input type="hidden" name="phone_call[buttonId]" value="<YOUR API KEY>" /> | |
<input type="hidden" name="phone_call[showCallerNumber]" value="1" /> | |
<ul> | |
<li> | |
<label>Your Name</label> | |
<input type="text" name="phone_call[callerNumber]" /> | |
</li> |
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
class PhoneCallsController < ApplicationController | |
def create | |
http = Net::HTTP.new('clients4.google.com', 443) | |
http.use_ssl = true | |
path = '/voice/embed/webButtonConnect' | |
request_params = params[:phone_call].map { |k, v| "#{ CGI.escape(k) }=#{ CGI.escape(v) }" }.join("&") | |
request_headers = {} | |
resp, data = http.post(path, request_params, request_headers) |
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
# Rakefile | |
desc "Create new color swatches" | |
task :swatches do | |
require "yaml" | |
YAML.load_file("swatches.yml").each do |name, color| | |
p "Creating: #{name} (#{color}) => images/colors/#{name}.png" | |
%x[ convert -size 16x16 xc:white -draw "stroke #666666 fill white rectangle 0,0 15,15" -draw "stroke white fill #{color} rectangle 1,1 14,14" "images/colors/#{name}.png" ] | |
end |
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
$ rake swatches | |
"Creating: white (#FFFFFF) => images/colors/white.png" | |
"Creating: navy (#304264) => images/colors/navy.png" | |
"Creating: black (#0F0F0F) => images/colors/black.png" | |
"Creating: forest_green (#2E5234) => images/colors/forest_green.png" | |
"Creating: blue (#3055A0) => images/colors/blue.png" | |
"Creating: orange (#DA7A2D) => images/colors/orange.png" | |
"Creating: green (#4D8756) => images/colors/green.png" | |
"Creating: brick (#6F0028) => images/colors/brick.png" |
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
class Metric | |
include MongoMapper::Document | |
key :timestamps, Array | |
key :action, String | |
def self.track(action) | |
collection.update( | |
{ :action => action }, | |
{ "$push" => { :timestamps => Time.now }}, |
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
# | |
# Here, we query all JobSeekers where any of their "desired | |
# specializations" match any of the job's "required specializations" | |
# AND any of their "desired positions" match any of the job's...etc | |
# | |
# We also only want JobSeekers who have NOT accepted this job. | |
# | |
# And we do a fulltext keyword search too, just for fun. | |
# |
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
Delivered-To: starr@chromahq.com | |
Received: by 10.52.174.78 with SMTP id bq14csp20270vdc; | |
Sat, 28 Apr 2012 10:31:46 -0700 (PDT) | |
Received: by 10.216.135.225 with SMTP id u75mr8769804wei.97.1335634305296; | |
Sat, 28 Apr 2012 10:31:45 -0700 (PDT) | |
Return-Path: <mandujano.david@yahoo.com> | |
Received: from nm7-vm0.bullet.mail.ird.yahoo.com (nm7-vm0.bullet.mail.ird.yahoo.com. [77.238.189.222]) | |
by mx.google.com with SMTP id ei5si7755970wid.4.2012.04.28.10.31.44; | |
Sat, 28 Apr 2012 10:31:45 -0700 (PDT) | |
Received-SPF: pass (google.com: best guess record for domain of mandujano.david@yahoo.com designates 77.238.189.222 as permitted sender) client-ip=77.238.189.222; |
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
Honeybadger.configure do |config| | |
# Will send session["sensitive_key"] = "FILTERED" to Honeybadger | |
config.params_filters << "sensitive_key" | |
end |
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
# First, you define an email receiver class | |
class EmailReceiver < Incoming::Strategies::CloudMailin | |
def receive(mail) | |
puts %(Got message from #{mail.to.first} with subject "#{mail.subject}") | |
end | |
end | |
# Then you feed it a Rack::Request object. And you're done. | |
req = Rack::Request.new(env) | |
result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com with subject "hello world" |
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
# app/controllers/emails_controller.rb | |
class EmailsController < ActionController::Base | |
def create | |
if EmailToSmsReceiver.receive(request) | |
render :json => { :status => 'ok' } | |
else | |
render :json => { :status => 'rejected' }, :status => 403 | |
end | |
end | |
end |