Skip to content

Instantly share code, notes, and snippets.

View tbranyen's full-sized avatar

Tim Branyen tbranyen

View GitHub Profile
var forEach = function(list, callback) {
return Array.prototype.forEach.call(list, callback);
};
@tbranyen
tbranyen / handlebars.object_helpers.js
Created September 26, 2012 18:18 — forked from strathmeyer/handlebars.object_helpers.js
Handlebars.js helpers to iterate over objects
// HELPER: #key_value
//
// Usage: {{#key_value obj}} Key: {{key}} // Value: {{value}} {{/key_value}}
//
// Iterate over an object, setting 'key' and 'value' for each property in
// the object.
Handlebars.registerHelper("key_value", function(obj, options) {
var buffer = "",
key;
//This is the line from the stack-trace that's causing the error:
//backbone.js L39
if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
@tbranyen
tbranyen / templatejs.js
Created February 23, 2012 21:39 — forked from jonathantneal/templatejs.js
templatejs.js
// TemplateJS v3.1.1 MIT/GPL2 @jon_neal
(function (global) {
function escapeJS (str) {
return str.replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
}
function TemplateWalk (instance, str) {
// check for the opening and closer strings
var indexOpener = str.indexOf(instance.chars.open);
var indexCloser = str.indexOf(instance.chars.close);
@tbranyen
tbranyen / application.js
Created November 13, 2011 17:14 — forked from iros/application.js
BackboneTraining-require.js
// Define whatever global space vars you might need.
var mbta = {
// application configuration parameters
app : {
server : "http://backbonetraining.bocoup.com:8000"
},
// application data
data : {
// station collection
lines : null
// Initially zero. When decremented to zero, fires callback
function semaphore( callback ) {
var fn = callback,
count = 0;
return {
increment: function() {
count++;
},
decrement: function() {
if( count > 0 ) {
@tbranyen
tbranyen / foo1.js
Created April 27, 2011 18:39 — forked from remy/foo1.js
(function () {
// export the API, but also create a global called "foo"
foo = module.exports = function (s) {
console.log('foo1 (global): ' + s);
};
})();
if request.method == 'GET':
id = request.GET['id']
tagging = Images.objects.get(id=id)
tags = Tag.objects.usage_for_model(tagging, counts=True)
usageNum = [{"tag": tagfreq.name, "count": tagfreq.count} for tagfreq in tags]
dump = simplejson.dumps(usageNum)
message = dump
$.getJSON('/tags/',
{
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detect Credit Card Type</title>
<style type="text/css">
#cards, #statuses {
padding-left: 5px;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detect Credit Card Type</title>
</head>
<body>