Skip to content

Instantly share code, notes, and snippets.

View mheadd's full-sized avatar

Mark Headd mheadd

View GitHub Profile
@mheadd
mheadd / line-break-sms.php
Created May 18, 2011 16:50
Simple PHP script for SMSified that puts a line break in the SMS message.
<?php
// Include the SMSifed class.
require 'path/to/smsified.class.php';
// SMSified Account settings.
$username = "username";
$password = "password";
$senderAddress = "9999999999";
@mheadd
mheadd / multi-sms-messages.js
Created May 18, 2011 19:31
Send multiple SMS messages through SMSified using Node.js
var sys = require('sys');
var smsified = require('smsified');
var config = require('./config');
var messages = new Array('I love Node.js', 'I love Node.js even more', 'I love Node.js the mostest')
for(var i=0; i<messages.length; i++) {
var sms = new SMSified(config.credentials.username, config.credentials.password);
var options = {senderAddress: '4076541234', address: '16867541234', message: messages[i]};
sms.sendMessage(options, function(result) {
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 7 columns, instead of 8 in line 1.
State,Location,City,Zip,Longitude,Latitude,Description
Pennsylvania,Broad & South,Broad & South Sts.,Philadelphia,,-75.1652166666667,39.943725,"S Broad St & South St, Philadelphia, PA 19147"
Pennsylvania,Catasauqua,Pin St. (btwn Front St. & Railroad St.),Philadelphia,,-75.1436833333333,39.942875
Pennsylvania,Cecil B. Moore,Cecil B. Moore Ave. (btwn. Broad St. and Park Walk),Philadelphia,,-75.1576944444444,39.9785833333333,"N Broad St & Cecil B Moore Ave, Philadelphia, PA 19122"
Pennsylvania,Chestnut Hill Farmers Market,Corner of Germantown and Southampton Avenues,Philadelphia,19147,-75.2032012939453,40.073486328125
Pennsylvania,Clark Park Farmers' Market,43rd Street & Baltimore Avenue,Philadelphia,,-75.2094888888889,39.9494583333333,"Baltimore Ave & S 43rd St, Philadelphia, PA 19104"
Pennsylvania,Cliveden Park,Chew Ave. & Johnson St.,Philadelphia,,-75.1761166666667,40.0521833333333,"Chew Ave & E Johnson St, Philadelphia, PA 19119"
Pennsylvania,Dutch Country Farmers Market,2031 Cottman Avenue,Philadelphia,1914
@mheadd
mheadd / CouchDB-Parser.js
Created May 23, 2011 15:15
A CSV file with address, coordinates and description for all polling places in City of Philadelphia
var csv = require('./lib/csv');
var sys = require('sys');
var cradle = require('cradle');
var couchHost = 'http://127.0.0.1';
// Create connection to CouchDB instance.
var db = new (cradle.Connection)(couchHost, 5984).database('phl_polling_places');
// Iterate over rows in CSV and create object to insert into CouchDB.
@mheadd
mheadd / index.php
Created May 27, 2011 19:50
PHP script and CouchDB design document elements for an SMS management system
<?php
// Include required classes.
require 'classes/sag/Sag.php';
require 'classes/smsified/inbound.class.php';
require 'classes/smsified/smsified.class.php';
// Extend InboundMessage class.
class SMSMessage extends InboundMessage {
public function __construct($json) {
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd"
version="1.0" xml:lang="en-US" mode="voice dtmf" root="main">
<rule id="main" scope="public">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
@mheadd
mheadd / SNAP-Locations.csv
Created June 4, 2011 18:44
SNAP Locations in Philadelphia, PA
STORE_NAME longitude latitude ADDRESS CITY STATE ZIP5 zip4
Juliano's Deli Inc. #4 -74.973444952 40.0844016203 4015 Fairdale Rd Philadelphia PA 19154 3609
Juliano's Deli Inc #6 -75.0927498788 40.0522319612 6605 Rising Sun Ave Philadelphia PA 19111 4651
Juliano's Deli Inc. #2 -75.0310460907 40.1038646303 842 RED LION RD Philadelphia PA 19115
Misnik's Deli -75.1047648211 39.9862846768 2530 E Allegheny Ave Philadelphia PA 19134 5111
7 Days Food Market -75.1793963482 39.9934126624 2462 N 29th St Philadelphia PA 19132 3020
Has Has Market -75.1460796752 40.0315925206 5035 N Broad St Philadelphia PA 19141 2232
The New Wilson's Meats, Inc. -75.0977056526 39.9942456054 2325 E Venango St Philadelphia PA 19134 4622
Jo Jo Grocery Store -75.227895648 39.9260610669 2401 S 62nd St Philadelphia PA 19142 3216
Hojin Inc T/a Wiccaco Market -75.1499827328 39.9384947042 776 S 4th St Philadelphia PA 19147 3122
function getSql($max,$type,$lat,$lon) {
GLOBAL $round, $limit, $crime_types;
$sql = "SELECT BLOCKSITEADDRESS, OFFENSE, REPORTDATETIME, ROUND(((ACOS( SIN($lat * PI()/180 ) * SIN(LATITUDE * PI()/180 ) + COS($lat * PI()/180 ) * COS(LATITUDE * PI()/180 ) * COS(($lon - LONGITUDE) * PI()/180))*180/PI())*60*1.1515),$round) AS DISTANCE FROM crime_incidents_2008 ";
if($type > 0) {
$sql .= 'WHERE OFFENSE = \''.$crime_types[$type].'\' ';
}
$sql .= "HAVING distance <= $max ORDER BY DISTANCE ASC LIMIT 0 , $limit";
return $sql;
}
@mheadd
mheadd / find-my-library.php
Created June 5, 2011 19:36
A Tropo application that finds library locations in NY City. Uses NYC Datamine info imported to CouchHDB.
<?php
/**
* Find My Library - an IM (and SMS, and Twitter, and Phone) application that finds
* library locations in NYC.
*
* @copyright 2011 Mark J. Headd (http://www.voiceingov.org)
* @author Mark Headd
*/
<grammar xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" version="1.0" xml:lang="en-US" root="main">
<rule id="main" scope="public">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>