Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
Getting up and running with OS X, Textmate & Scheme
===================================================
SCHEME
======
I ran across two implementations of Scheme which appear to work well with OS X.
mit-scheme & PLT Scheme.
I was able to install mit-scheme from darwin ports ( sudo port install mit-scheme)
@rwaldron
rwaldron / ba-ghettotmpl.js
Created June 11, 2011 14:25 — forked from cowboy/ba-ghettotmpl.js
Ghetto fabulous templating system. More ghetto than fabulous.
// Ghetto fabulous template system for replacing values in strings. If {{.foo}}
// or {{.bar[0].baz}} is encountered (leading dot), attempt to access properties
// of data object like `data.foo` or `data.bar[0].baz`. Alternately, if {{foo}}
// or {{bar("baz")}} is encountered (no leading dot), simply evaluate `foo` or
// `bar("baz")`. If an error occurs, return empty string. @rworth++
function ghettoTmpl(data, str) {
return (str + '').replace(/\{\{((\.)?.*?)\}\}/g, function(_, str, dot) {
return eval('try{' + (dot ? 'data' : '') + str + '}catch(e){""}');
});
@rwaldron
rwaldron / charCounts.js
Created June 16, 2011 03:33 — forked from ralphholzmann/charCounts.js
Paste this in the console at ralphholzmann.com to see the char distribution
var obj = {}, ordered = [];
$.get("jquery.min.js", function( src ) {
src.replace(/[^\w]|\d/gi, '').split('').forEach(function( c ) {
obj[ c ] ? ++obj[ c ] : ( obj[ c ] = 1 )
});
@rwaldron
rwaldron / client.js
Created June 16, 2011 14:03 — forked from louisremi/client.js
Friends Timeline snippets
// Create an EventSource object,
// passing it the URL of the server sccript
var evtSrc = new EventSource( "server.php" ),
// Setup event types, provide explicit values if nec.
eventTypes = {
message: "status",
checkin: 1,
forward: 1,
direct: 1
};
// Popcorn Instance Methods
var p = Popcorn( "#video" )
p.play()
// Play the video (Native "pass through" method)
// Returns the Popcorn instance object
p.load()
// Load the video (Native "pass through" method)
// Returns the Popcorn instance object
var fs = require('fs'),
sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
checkBalanceFile(req, res);
}).listen(8000);
function checkBalanceFile(req, res) {
fs.stat("balance", function(err) {
@rwaldron
rwaldron / ArrayExtender.js
Created July 15, 2011 03:46 — forked from leobalter/ArrayExtender.js
Array Extender. Creates an Array subclass. Doing so you won't override or mess with Array's own prototype
var ArrayExtender = function (a) {
var counter = 0;
for (var i in a) {
if (a.hasOwnProperty(i)) {
this[i] = a[i];
++counter;
}
}
this.length = counter;
@rwaldron
rwaldron / gist:1084725
Created July 15, 2011 13:48 — forked from angus-c/gist:1081818
BS ≈ BreakfastScript
Conditionals
( false :)
console.log "if"
:( true )
console.log "else if"
:()
console.log "else"
@rwaldron
rwaldron / popcorn-youtube.html
Created July 16, 2011 03:06 — forked from brettgaylor/popcorn-youtube.html
Popcorn YouTube Example
<!doctype html>
<html>
<head>
<script src="http://popcornjs.org/code/dist/popcorn-complete.min.js"></script>
<script>
// ensure the web page (DOM) has loaded
document.addEventListener("DOMContentLoaded", function () {
// Create a popcorn instance by calling the Youtube player plugin
@rwaldron
rwaldron / fn arrEach and objEach
Created July 25, 2011 16:14 — forked from 1Marc/fn arrEach and objEach
"But $.each is slow!" ..use fn arrEach and objEach then!!
// arrEach and objEach plugins
// code under MIT license by Marc Grabanski http://marcgrabanski.com
// jsperf tests: http://jsperf.com/each-vs-fn-arreach-and-objeach
$.arrEach = function(arr, cb){
for (var i = 0, item; item = arr[i]; ++i) {
cb.apply(item, [i, item]);
}
return arr;
}