Skip to content

Instantly share code, notes, and snippets.

View jonathanhculver's full-sized avatar

Jon Culver jonathanhculver

View GitHub Profile
@jonathanhculver
jonathanhculver / changeLight.ino
Created June 24, 2013 03:23
/* changes the light or reports its status */
/* changes the light or reports its status */
String changeLight(int val) {
/* turn light on */
if(val== 1) {
digitalWrite(pin, HIGH);
lightStatus = "on";
/* turn light off */
} else if(val==0) {
digitalWrite(pin, LOW);
lightStatus = "off";
void printWebResponse(WiFiClient client, String lightStatus) {
Serial.println();
// so the http request has ended and we can send a reply
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Access-Control-Allow-Origin: *");
client.println("Content-Type: text/html");
client.println();
client.println("{\"status\":\""+lightStatus+"\"}");
}
@jonathanhculver
jonathanhculver / wifiJS.js
Created June 24, 2013 03:34
wifi lamp JS
window.onload = function() {
/* ip address of arduino */
var URL = "00.0.0.0";
var lightDiv = $('#lightbulbContainer');
/* find out current state of the light and adjust the UI accordingly */
$.ajax({
type: "GET",
url: URL+"/led=-1"
@jonathanhculver
jonathanhculver / Default.sublime-theme
Created July 13, 2013 21:36
Dark theme (twilight) for sublime text folder sidebar. Click Browse Packages and add file named "Default.sublime-theme" to Packages/User
[
{
"class": "sidebar_container",
// right border
"layer0.tint": [84,84,84],
"layer0.opacity": 1.0,
"layer0.draw_center": false,
"layer0.inner_margin": [0, 0, 1, 0],
"content_margin": [0, 0, 1, 0]
},
@jonathanhculver
jonathanhculver / sms.rb
Created August 16, 2013 00:04
Send text messages to an array of phone numbers
toArray = []
$smsToken = ''
$phoneNumber = ''
get '/text' do
toArray.each do |element|
callSmsScript("Hi", element)
sleep(5)
end
@jonathanhculver
jonathanhculver / voice.rb
Created August 16, 2013 00:08
a simple voice menu
post '/voice.json' do
t = Tropo::Generator.new
t.ask :name => 'digit',
:timeout => 60,
:say => {:value => "Hello! What year were you born?"},
:choices => {:value => "[4 DIGITS]"}
t.on :event => 'continue', :next => '/continue.json'
@jonathanhculver
jonathanhculver / index.html
Last active December 22, 2015 02:49
webrtc html for webcam
<video id="videoInput" width="640px" height="480px" autoplay></video>
<img id="img" src="" style="display: none" />
<canvas width="440px" height="580px" style="display:none;"></canvas>
@jonathanhculver
jonathanhculver / stream.js
Created September 1, 2013 18:20
javascript for webrtc webcam stream
window.onload = function() {
var video = document.querySelector('video');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
var localMediaStream = null;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
@jonathanhculver
jonathanhculver / snapshot.js
Created September 1, 2013 18:23
webrtc snapshot from webcam
function snapshot() {
if (localMediaStream) {
var img = document.querySelector('img');
/* draws the image to the canvas */
ctx.drawImage(video, 0, 0);
/* loads the img to the hidden img tag */
img.src = canvas.toDataURL('image/webp');
img.style.display= "block";
}
}
@jonathanhculver
jonathanhculver / contacts.rb
Created January 15, 2014 02:54
iterating through a vcf file to add a field
load 'vpim-13.11.11/lib/vpim/vcard.rb'
#read file as string
address_book = File.open('contacts.vcf')
contents = address_book.read
#load contacts
original = Vpim::Vcard.decode(contents)
#create new file