Skip to content

Instantly share code, notes, and snippets.

@JamesRyanATX
JamesRyanATX / radio_thermostat.rb
Created January 16, 2012 00:19
Basic Ruby client for 3M's Radio Thermostat
require 'rubygems'
require 'httparty'
require 'json'
# Ruby client for 3M's Radio Thermostat (http://www.radiothermostat.com/)
# James Ryan <fretlessjazz@gmail.com>
# --
#
# Examples:
#
@JamesRyanATX
JamesRyanATX / iam.rb
Created May 16, 2011 21:10
Blacklist distracting websites while working
#!/opt/local/bin/ruby
#
# iam - block distracting websites while working
#
# Examples:
#
# Switch to work mode -- disable distracting websites
# % iam working
#
# Switch to play mode -- enable distracting websites
1000.times { puts "BRIAN CARLSON!" }
@JamesRyanATX
JamesRyanATX / Classical Inheritance in JS
Created April 26, 2011 15:54
Classical Inheritance in JS
TinyOOP = { };
TinyOOP.Class = function(definition) {
var klass = function() {
if (typeof this.initialize !== 'undefined') this.initialize.apply(this, arguments);
}
for (key in TinyOOP.Class.Methods) { klass[key] = TinyOOP.Class.Methods[key]; }
for (key in definition) { klass.prototype[key] = definition[key]; }
return klass;
}
/**
*
* smtpd.js -- an event-driven simple SMTP service for Node.js
*
* smtpd.js fires events at various points in the lifecycle of an SMTP
* connection, and those events are caught by observer functions added via
* SMTPD.Event.observe(). The design is very similar to Prototype.js's
* event observation model.
*
* Observers can also fire custom events, which can be caught by other custom
Array.prototype.hashify = Array.prototype.hashify || function(transform) {
var h = { };
for (var i = 0; i < this.length; i += 1) h[transform(i)] = i;
return h;
};