This file contains hidden or 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
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) |
This file contains hidden or 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
// 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){""}'); | |
}); |
This file contains hidden or 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 obj = {}, ordered = []; | |
$.get("jquery.min.js", function( src ) { | |
src.replace(/[^\w]|\d/gi, '').split('').forEach(function( c ) { | |
obj[ c ] ? ++obj[ c ] : ( obj[ c ] = 1 ) | |
}); |
This file contains hidden or 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
// 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 | |
}; |
This file contains hidden or 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
// 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 |
This file contains hidden or 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 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) { |
This file contains hidden or 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 ArrayExtender = function (a) { | |
var counter = 0; | |
for (var i in a) { | |
if (a.hasOwnProperty(i)) { | |
this[i] = a[i]; | |
++counter; | |
} | |
} | |
this.length = counter; |
This file contains hidden or 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
Conditionals | |
( false :) | |
console.log "if" | |
:( true ) | |
console.log "else if" | |
:() | |
console.log "else" | |
This file contains hidden or 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
<!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 |
This file contains hidden or 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
// 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; | |
} |