Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
@RobSpectre
RobSpectre / map.html
Created June 29, 2013 20:51
An example of dropping a marker on a Google Map with a fuzzy address.
<!DOCTYPE html>
<html lang="en">
<title>Rob's Awesome Map</title>
<head>
<script
src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<style>
html, body, #map-canvas {
margin: 0;
padding: 0;
@RobSpectre
RobSpectre / app.rb
Created June 12, 2013 11:56
Call Queue That Calls Out To Agent For The First Caller. I *think* this works, but I'm not a Rubyist so may have some n00b gaffes.
require 'rubygems'
require 'sinatra'
require 'twilio-ruby'
# Endpoint for the call-in line that your customers call.
post '/caller' do
Twilio::TwiML::Response.new do |r|
r.Enqueue 'Customer Queue', :waitUrl => '/wait'
end.text
end
<?php
// Documentation is here: https://twilio-php.readthedocs.org/en/latest/
require_once('auth.php');
require_once('Services/Twilio.php');
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
$message = $client->account->sms_messages->create(
@RobSpectre
RobSpectre / app.py
Created March 13, 2013 16:14
Hacker Hotline by area of interest
@app.route('/caller', methods=['POST'])
def caller():
response = twiml.Response()
response.play("/static/sounds/intro.mp3")
with response.gather(numDigits=1, action='/handle-key', method='POST') as g:
g.say("Please press 0 for PHP, 1 for Java, 2 for C, C++, or Objective C, 3 for Ruby, 4 for Javascript or Jay Query, 5 for Python, 6 for dot Net, 7 for HTML or CSS, 8 for SQL, or 9 for other")
response.pause()
response.redirect('/caller')
return str(response)
@RobSpectre
RobSpectre / gather.xml
Created November 21, 2012 15:57
Press * at any time for voicemail.
<Response>
<Gather action="handler.php">
<Say>Press 1 to do some stuff.</Say>
<Say>Press 2 to do some more stuff.</Say>
<Say>Press star to leave a voice message</Say>
</Gather>
</Response>
@RobSpectre
RobSpectre / messages.py
Created September 27, 2012 19:09
Get the last n number of Sms Messages
from twilio.rest import TwilioRestClient
ACCOUNT_SID = 'ACxxxxxxxxxxxxxxxxx'
AUTH_TOKEN = 'yyyyyyyyyyyyyyyyyyyy'
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
messages = client.sms.messages.list()
for msg in messages:
@RobSpectre
RobSpectre / catch.rb
Created September 13, 2012 21:20
Example of catching Twilio REST exceptions in Ruby - sketch, I don't actually know how this works.
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'
# put your own credentials here
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
@RobSpectre
RobSpectre / notification.py
Created August 18, 2012 15:55
Example of a Twilio Proactive Notification in Python
from twilio.rest import TwilioRestClient
ACCOUNT_SID = "ACxxxxx"
AUTH_TOKEN = "yyyyyyyy"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
client.sms.messages.create(from_="+15556667777", to="+15558675309", body="Reminder: Harley Manning will be signing copies of his new book at the Commonwealth Club Thursday at 6 p.m.")
@RobSpectre
RobSpectre / script.py
Created August 7, 2012 21:59
Karaoke Lyrics
from twilio.rest import TwilioRestClient
ACCOUNT_SID = "ACxxxxxxxxxxxx"
AUTH_TOKEN = "yyyyyyyyyyyyyyy"
APP_SID = "APzzzzzzzzzzzzzzzz"
CALLER_ID = "+15556667777"
KARAOKE_NUMBER = "+15558675309"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
@RobSpectre
RobSpectre / app.py
Created August 7, 2012 21:58
Karaoke Music
import flask
from twilio import twiml
app = flask.Flask(__name__)
@app.route('/tunes', methods=['POST'])
def tunes():
response = twiml.Response()
response.play('http://example.com/tastytunes.mp3')
return str(response)