Skip to content

Instantly share code, notes, and snippets.

View tristanz's full-sized avatar
💭
Working on Continual

Tristan Zajonc tristanz

💭
Working on Continual
View GitHub Profile
@tristanz
tristanz / gist:635621
Created October 20, 2010 02:05
KnockoutJS in CoffeeScript
I'm trying to make KnockoutJS's dependentObservables work in CoffeeScript. See
http://github.com/SteveSanderson/knockout/wiki/Observables
A typical example is:
var viewModel = {
firstName: ko.observable('Bob'),
lastName: ko.observable('Smith')
};
@tristanz
tristanz / gist:640071
Created October 22, 2010 06:52
Problem binding functions with variables within a template.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://nje.github.com/jquery-tmpl/jquery.tmpl.js"></script>
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-1.1.0.js"></script>
</head>
<body>
<div data-bind="template: 'myTemplate'"></div>
<script id="myTemplate" type="text/html" >
circle.node {
stroke: #fff;
stroke-width: 1.5px;
}
line.link {
stroke: #999;
stroke-opacity: .6;
}
@tristanz
tristanz / matmul.boo
Created October 9, 2011 20:38
Boo vs C# performance
import System
// Written by Attractive Chaos; distributed under the MIT license
// To compile: mcs -optimize+ -out:matmul_v1.run matmul_v1.cs
// Translated from Java with reference to: http://code.wikia.com/wiki/Matrix_multiplication
internal class matmul_v1:
@tristanz
tristanz / modulename.cpp
Created December 28, 2011 03:02
Node Header Module
#include <node.h>
#include "modulename.hpp"
using namespace v8;
void RegisterModule(Handle<Object> target) {
MyObject::Init(target);
}
@tristanz
tristanz / complex.cc
Created February 22, 2012 18:55
Node module in header file
#include <node.h>
#include "complex.hpp"
using namespace v8;
void RegisterModule(Handle<Object> target) {
MyObject::Init(target);
}
NODE_MODULE(complex, RegisterModule);
@tristanz
tristanz / README.md
Created July 31, 2012 06:13 — forked from mbostock/.block
Histogram
(function() {
console.log('cartodb');
var INCLUDE_GMAPS = false ;
var VIZJSON_URL = 'https://sense.cartodb.com/api/v1/viz/15450/viz';
var ACCOUNT_TYPE = "free";
var IS_CUSTOM_INSTALL = false;
var doc = document;
var head = doc.getElementsByTagName('head')[0];
#cloud-config
coreos:
etcd:
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
peers: 172.17.8.101:7001,172.17.8.101:7002
units:
- name: etcd.service
command: start
@tristanz
tristanz / gist:b02ad69cacf768453e47
Created September 6, 2014 22:53
Handle Backspace and Special Characters in Text
applyRewrites = (txt) =>
txt = txt.replace /\r\n/g, "\n"
sofar = ""
remaining = txt
lineBreaks = []
rewritten = false
while m = /[\b\r\n]/.exec(remaining)
switch m[0]
when "\b"
# Handle backspaces. Add everything up to the backspace, then pop off the last character.