Skip to content

Instantly share code, notes, and snippets.

View mickstevens's full-sized avatar

Mick Stevens mickstevens

View GitHub Profile
<?php
// Set the numbers to call
$numbers = array("<number to call 1>", "<number to call 2>", "<number to call n>");
$number_index = isset($_REQUEST['number_index']) ? $_REQUEST['number_index'] : "0";
$DialCallStatus = isset($_REQUEST['DialCallStatus']) ? $_REQUEST['DialCallStatus'] : "";
header("content-type: text/xml");
// Check the status of the call and
<?php
// From http://ertw.com/blog/2013/11/05/using-an-ip-phone-with-twilio/
// Connect an incoming call to your SIP phone through Twilio
$called = preg_replace('/sip:1?(.*?)@.*/', '{$1}', $_POST['Called']);
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
import zillabyte
twilio_sid = "SID_HERE"
twilio_auth = "AUTH_HERE"
class TwilioEach:
def prepare(self, controller):
# Dictionary of phone numbers subscribed to cities (just for show with small sample, please use a
# REAL source when using a significant number of phone numbers)
import zillabyte
from twilio.rest import TwilioRestClient
def send_text(controller, tup):
# Register twilio client
twilio_client = TwilioRestClient(tup["twilio_sid"], tup["twilio_auth"])
try:
# Send message to recipient and wait 1 second (twilio SMS rate limit)
{
"sparkAccessToken": "",
"sparkDeviceID": "",
"twilioAccountSID": "",
"twilioAuthToken": "",
"toPhoneNumber": "[NUMBER TO CALL]",
"fromPhoneNumber": "[YOUR TWILIO NUMBER]",
"paperTowelTwiml": "[URL TO TWIML FILE. DROPBOX WORKS GREAT]"
}
@mickstevens
mickstevens / call.php
Last active August 29, 2015 14:21 — forked from jonmarkgo/call.php
<?php
require("Services/Twilio.php");
require("database.php");
// require POST request
if ($_SERVER['REQUEST_METHOD'] != "POST") die;
// generate "random" 6-digit verification code
$code = rand(100000, 999999);
<?php
$db_host='dbserver';
$db_name='dbame';
$db_user='dbuser';
$db_passwd='dbpassword';
mysql_connect($db_host, $db_user, $db_passwd)
or die('Could not connect: ' . mysql_error());
mysql_select_db($db_name) or die('Could not select database');
@mickstevens
mickstevens / gist:5f05b0ffa87d4e446a47
Created November 22, 2015 15:14 — forked from coolaj86/gist:2332953
Dimensions for VistaPrint business cards
Standard
Bleed Margin: 90mm x 52mm
Content Ends: 87mm x 49mm
Imperial
Bleed Margin: 3.54in x 2.05in
Content Ends: 3.43in x 1.93in
@mickstevens
mickstevens / README.md
Created January 13, 2016 11:03 — forked from brampersandon/README.md
SOTU.rb: a quick method to tweet and text hot-takes simultaneously

SOTU.rb

My friend was stuck without an internet connection during this year's State of the Union. I wanted to make sure we could all share our hot takes and direct quotes with them, so I made this 'lil distribution channel in the ten minutes before the speech.

I wrote these docs, and this script, in a total of ten minutes. It may be a bit rough. I'll be making updates to simplify and clarify in a few minutes. If you have any questions, leave a comment on the Gist, or get at me on Twitter -- I'm glad to help!

APIs used

For SMS messaging, I used the awesome Twilio SMS APIs. To post to Twitter, I used the one, the only Twitter API.

To use