This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
heroku create --stack cedar | |
git push heroku master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git init | |
git add . | |
git commit -am "Initial commit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/' do | |
erb :index, :locals => {:msg => "Control the Outlet"} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: bundle exec ruby twilio-power-outlet.rb -p $PORT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'sinatra' | |
gem 'pusher' | |
gem 'twilio-ruby' |