Skip to content

Instantly share code, notes, and snippets.

View jonmarkgo's full-sized avatar
🎓
preparing the MLH Fellowship

Jonathan Gottfried jonmarkgo

🎓
preparing the MLH Fellowship
View GitHub Profile
var http = require('http'),
sys = require('sys'),
nodeStatic = require('node-static');
faye = require('faye'),
url = require('url');
function LiveStats(options) {
if (! (this instanceof arguments.callee)) {
return new arguments.callee(arguments);
var http = require('http'),
sys = require('sys'),
nodeStatic = require('node-static');
var server = http.createServer(function(request, response) {
var file = new nodeStatic.Server('./public', {
cache: false
});
request.addListener('end', function() {
file.serve(request, response);
heroku create --stack cedar
git push heroku master
git init
git add .
git commit -am "Initial commit"
@jonmarkgo
jonmarkgo / index.erb
Created August 7, 2012 20:47
outleterb
<h1><%= msg %></h1>
<form action="/control/" method="POST">
<select name="Body">
<option value="on">Turn On</option>
<option value="off">Turn Off</option>
</select>
<br /><input type="submit" />
</form>
@jonmarkgo
jonmarkgo / gist:3289141
Created August 7, 2012 20:45
outletserver3
get '/' do
erb :index, :locals => {:msg => "Control the Outlet"}
end
@jonmarkgo
jonmarkgo / gist:3289137
Created August 7, 2012 20:44
outletserver2
post '/control/?' do
output = "Message transmitted" #sms/html output message
#try to trigger a pusher event based on the Body of the incoming SMS or submitted form
begin
Pusher['robot_channel'].trigger('powersms', {:command => params['Body'].downcase})
rescue Pusher::Error => e
output = "Failed: #{e.message}"
end
#if the web form was submitted, render our erb template
@jonmarkgo
jonmarkgo / gist:3289081
Created August 7, 2012 20:39
outletserver1
require 'sinatra'
require 'twilio-ruby'
require 'pusher'
configure do
Pusher.app_id = ENV['PUSHER_APP_ID']
Pusher.key = ENV['PUSHER_KEY']
Pusher.secret = ENV['PUSHER_SECRET']
end
@jonmarkgo
jonmarkgo / Procfile
Created August 7, 2012 20:39
Procfile
web: bundle exec ruby twilio-power-outlet.rb -p $PORT
@jonmarkgo
jonmarkgo / Gemfile
Created August 7, 2012 20:38
Gemfile
source :rubygems
gem 'sinatra'
gem 'pusher'
gem 'twilio-ruby'