Skip to content

Instantly share code, notes, and snippets.

View stephenhandley's full-sized avatar
🎾
let

Stephen Handley stephenhandley

🎾
let
View GitHub Profile
@stephenhandley
stephenhandley / substanceware
Created December 11, 2013 06:06
substanceware
/*
* ----------------------------------------------------------------------------
* "THE {$substance}WARE LICENSE" (Revision 69):
* {$author}<{$email}> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy {$author} ${substance} in return.
* ----------------------------------------------------------------------------
*/
var LocalStorageCache = (function () {
function _now() {
return (new Date()).getTime();
}
function _isExpired(json) {
var expired = false;
if (json.hasOwnProperty('ttl')) {
expired = ((json.timestamp + json.ttl) < _now());
<html>
<h1>wordpress dot com</h1>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var location = window.location.href;
var node_app_url = "http://localhost:8000";
var node_path = node_app_url + "?wp_url=" + encodeURIComponent(location);
var iframe = $("<iframe>").attr('src', node_path);
#!/bin/env node
// OpenShift sample Node application
// Get the environment variables we need.
var ipaddr = process.env.OPENSHIFT_INTERNAL_IP;
var port = process.env.OPENSHIFT_INTERNAL_PORT || 8080;
if (typeof ipaddr === "undefined") {
console.warn('No OPENSHIFT_INTERNAL_IP environment variable');
}
@stephenhandley
stephenhandley / Cordova.plist
Created April 28, 2012 08:07
default Cordova 1.6.1 new project plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIWebViewBounce</key>
<true/>
<key>TopActivityIndicator</key>
<string>gray</string>
<key>EnableLocation</key>
<false/>
@stephenhandley
stephenhandley / DelegatingRouter.js
Created March 30, 2012 11:59
modified backbone router to easily delegate handlers
// Modified from from Backbone.Router v 0.9.2
DelegatingRouter = (function() {
var DelegatingRouter = function(args) {
if (!args.delegate) { throw("delegate is required arg to DelegateRouter"); }
if (!args.routes) { throw("routes is required arg to DelegateRouter"); }
Backbone.history || (Backbone.history = new Backbone.History);
_delegate_routes(this, args.delegate, args.routes);
@stephenhandley
stephenhandley / CYOAGame.rb
Created March 29, 2012 10:24
me llamo Beto McLoserville
class CYOAGame
INVALID_CHOICE = "INVALID_CHOICE_aw_fuuuuuck_naw"
ENTER_PROMPT = " ... "
def initialize(events)
@events = events
@input = nil
self.run(:setup_merch)
end
@stephenhandley
stephenhandley / __.traverse.coffee
Created March 29, 2012 08:47
is there a better way of doing mapping an iterator across an object
__.traverse = (obj, iterator, context)->
result = {}
return result unless obj
for k,v of obj
result[k] = iterator.call(context, k, v)
result
{
"this": {
"is": {
"one more": "way",
"that": "json",
"coulda": "woulda",
"be": "indented"
},
"okay": "awesome"
},
{
"this": {
"is": {
"one more": "way",
"that": "json",
"coulda": "woulda",
"be": "indented"
},
"okay": "awesome"
},