Skip to content

Instantly share code, notes, and snippets.

View mattmakai's full-sized avatar
💭
bit.ly/fspython

Matt Makai mattmakai

💭
bit.ly/fspython
View GitHub Profile
@mattmakai
mattmakai / it-support.js
Last active July 10, 2017 17:11
IT Support Line
// Code for Twilio Functions (https://www.twilio.com/functions) that builds an automated speech recognition IT support desk.
// Read the companion blog post (https://www.twilio.com/blog/2017/07/building-the-it-crowd-answering-machine-using-twilio-functions.html) for full explanations.
/**************** Version 1 ******************/
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say({ voice: 'man', language: 'en-gb' }, 'Welcome to the IT support hotline. Sorry, we are currently closed. We don not have any open hours.');
callback(null, twiml);
};
@mattmakai
mattmakai / sendsms.py
Created May 1, 2017 20:52
Send a Twilio SMS using Python 3.6 stdlib
import base64
import json
import os
import urllib
from urllib import request, parse
TWILIO_SMS_URL = "https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json"
@mattmakai
mattmakai / app.py
Created November 18, 2016 20:21
Starter Bottle app with a single route
import bottle
from bottle import route, run, Response
app = bottle.default_app()
@route('/')
def index():
"""Returns standard text response to show app is working."""
" enable syntax highlighting
syntax enable
" show line numbers
set number
" set tabs to have 4 spaces
set ts=4
" indent when moving to the next line while writing code
@mattmakai
mattmakai / reply-sms-bottle-app.py
Created June 5, 2016 16:50
A simple Bottle web app for replying to SMS based on incoming HTTP POST requests from Twilio
from bottle import (post, request, response, route, run, )
from twilio import twiml
@route('/')
def check_app():
# returns a simple string stating the app is working
return "It works!"
@mattmakai
mattmakai / app.py
Created May 30, 2016 18:13
Simple Python & Flask app to respond to incoming SMS text messages
from flask import Flask, Response, request
from twilio import twiml
app = Flask(__name__)
@app.route("/")
def check_app():
# returns a simple string stating the app is working
@mattmakai
mattmakai / gist:e8f7f384f3a9a22639a2
Created January 24, 2015 22:15
My simple .vimrc configuration file
syntax on
set ts=4
set autoindent
set expandtab
set shiftwidth=4
let python_highlight_all = 1
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>Thanks for your text message!</Message>
</Response>
@mattmakai
mattmakai / gist:f9521e275efd2a1688f5
Last active August 29, 2015 14:04
lockdown root and use SSH keypairs for deployer
from os import environ
from fabric.api import *
from fabric.context_managers import cd
from fabric.contrib.files import sed
"""
Fabric file to upload public/private keys to remote servers
and set up non-root users. Also prevents SSH-ing in with the
root user. Fill in the following blank fields then run this
Fabric script with "fab bootstrap_ansible".
@mattmakai
mattmakai / gist:7569535
Created November 20, 2013 19:34
Example for using a fixtures variable in a Django test case.
class TestSignUp(TestCase):
fixtures = ['core-fixtures.json',]
def testShowSignUp(self):
response = self.client.get('/sign-up/')
self.assertContains(response, 'Sign Up', status_code=200)
def testSignUpSubmit(self):
self.assertEqual(0, len(User.objects.all()))
response = self.client.post('/sign-up/', {'first_name': 'John', \