Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
@RobSpectre
RobSpectre / init.sls
Created August 3, 2013 22:22
Auto-upgrade pip with Salt state
packages:
pkg.installed:
- names:
- python
- python-dev
- python-pip
pip-upgrade:
pip.installed:
- upgrade: True
@RobSpectre
RobSpectre / init.sls
Created August 2, 2013 02:29
/srv/salt/vim/init.sls
vim-deps:
pkg.installed:
- names:
- exuberant-ctags
- require_in:
- pkg: vim
vim-vundle:
git.latest:
- name: git://github.com/gmarik/vundle.git
@RobSpectre
RobSpectre / test_api.py
Created August 1, 2013 15:49
Test an API wrapper using requests.
import unittest
from mock import patch
import mymodule
class APITest(unittest.TestCase):
@patch('requests.get')
def test_wrapped_example(self, MockRequests):
mock_request = MockRequests()
# Set your status code you want to test against
@RobSpectre
RobSpectre / app.py
Created July 10, 2013 03:03
Customize our conference wait room to read the most popular stories today from the New York Times API.
from flask import Flask
from twilio import twiml
# First, we'll add your favorite HTTP client and mine, Requests
import requests
app = Flask(__name__)
# First, we give our app the key we retrieved from the
# New York Times API developer dashboard
app.config['NYTIMES_API_KEY'] = "key_we_registered"
@RobSpectre
RobSpectre / app.py
Last active December 19, 2015 13:28
Adjust Flask app to use custom conference room.
from flask import Flask
from twilio import twiml
app = Flask(__name__)
# Let's adjust this route to create a custom wait
# experience for our conference call.
@app.route('/conference', methods=['POST'])
@RobSpectre
RobSpectre / app.py
Created July 9, 2013 22:19
Flask app creating a Twilio Conference room.
# Import our dependencies
from flask import Flask
from twilio import twiml
# Instantiate our Flask app
app = Flask(__name__)
# Create an endpoint '/conference' to serve as our
@RobSpectre
RobSpectre / app.py
Created June 30, 2013 14:33
Quick example of Flask templating
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
@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(