Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
@RobSpectre
RobSpectre / anonymous_sms.php
Created September 21, 2013 20:09
Quick example of anonymizing SMS in PHP
<?php
$users = array("+15556667777", "+15556667778");
require_once('auth.php');
require_once('Services/Twilio.php');
$body = $_REQUEST['Body'];
$from = $_REQUEST['From'];
@RobSpectre
RobSpectre / error
Last active December 23, 2015 02:19
host.brooklynhacker.com:
Data failed to compile:
----------
Pillar failed to render with the following messages:
----------
Rendering SLS 'mysql' failed, render error:
found undefined alias 'Bxxxxxxxxxxxxxxxxxxxxxxxxxxx'
in "<unicode string>", line 2, column 18:
root_password: *Bxxxxxxxxxxxxxxxxxxxxxxx ...
@RobSpectre
RobSpectre / app.py
Created September 7, 2013 21:23
Pseudo code example of gather with python
from flask import Flask
from flask import request
from twilio import twiml
app = Flask(__name__)
@app.route('/gather', methods=['POST'])
def gather():
response = twiml.Response()
@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__":