This file contains 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
# "Guess the number" mini-project | |
# By Kelly Hale, 3/12/14 | |
# input will come from buttons and an input field in simplegui | |
# all output for the game will be printed in the console | |
import simplegui | |
import random | |
import math |
This file contains 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
// A simple JS mergesort, per Wikipedia's pseudocode | |
// http://en.wikipedia.org/wiki/Mergesort | |
// by K.R. Hale | |
var mergeSort = function(array) { | |
//base case | |
if (array.length <= 1) return array; | |
//recursive case | |
var middle = Math.floor(array.length / 2); |
This file contains 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
// A recreation of the native JS string method | |
// Accepts as many string arguments as you can feed it, returns concatenated string | |
// K.R. Hale | |
var concat = function() { | |
var result = ""; | |
for(var i = 0; i < arguments.length; i++) { | |
result += arguments[i]; | |
} | |
return result; |
This file contains 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
// early experiments with node had mysterious double requests | |
// turned out these were for the stoopid favicon | |
// here's how to short-circuit those requests | |
// and stop seeing 404 errors in your client console | |
var http = require('http'); | |
http.createServer(function (q, r) { | |
// control for favicon |
This file contains 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 makeLinkedList = function(){ | |
var list = {}; | |
list.head = null; | |
list.tail = null; | |
list.addToTail = function(value){ | |
var newNode = makeNode(value); | |
if (!list.head) { | |
list.head = newNode; | |
} |
This file contains 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
// PROMPT ONE: | |
var getUserComments = function(callback) { | |
// pretend this performs some async operation like an Ajax call | |
var commentCount = 50; | |
callback({ comments: commentCount }); | |
}; | |
var User = { | |
fullName: 'Joe Shmoe', |
This file contains 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
/* | |
How to use: | |
- Set up Twilio: | |
You will need a Twilio account and a Twilio phone number. All in all this should run you | |
about $1. Details here: https://www.twilio.com/docs/sms/quickstart/node | |
You'll want to save your new Twilio # into your phone contacts and set to favorite so it can wake you up | |
if you're using DND. | |
- Find the sensor you want to monitor: |