Skip to content

Instantly share code, notes, and snippets.

@matthewp
matthewp / todos.handlebars
Last active August 26, 2015 13:15
set viewModel property from template
<todos-model get-list="{status='complete'}" ^todos="{value}">
{{#isResolved}}
<li class="todos">...</li>
{{/isResolved}}
</todos-model>
@matthewp
matthewp / README.md
Last active August 26, 2015 19:26
engine-dependencies
var engineDependencies = require("engine-dependencies");

engineDependencies({
  "node": {
    "0.10.x": {
      "zombie": "2.5.1"
    },
 "0.12.x": {
@matthewp
matthewp / weakmap.js
Created April 10, 2014 18:05
WeakMap and private
var privateThings = new WeakMap();
function Private() {
this.data = 'is private';
}
Private.prototype.somePrivateFunction = function() {
this.foo = 'bar';
};
@matthewp
matthewp / sanity.html
Created April 24, 2014 18:53
Sanity check
<html>
<head>
<title>Sanity check</title>
</head>
<body>
<script>
window.runLater = function() {
console.log("Calling runLater");
window.setTimeout(function() {
@matthewp
matthewp / script.js
Created May 26, 2014 21:11
Phantom + Traceur
var page = require('webpage').create();
page.onError = function(msg, trace){
console.log(msg, trace);
};
page.open('http://localhost/phantom_traceur/test.html', function() {
phantom.exit();
});
exports.translate = function(load) {
load.source = 'module.exports = ' + load.source + ';';
};
@matthewp
matthewp / proxy.js
Created September 30, 2014 01:36
Simple proxy in node
var httpProxy = require('http-proxy');
var http = require('http');
var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function(req, res) {
var url = req.url;
console.log(url);
proxy.web(req, res, { target: url });
});
@matthewp
matthewp / metadeps.js
Created November 25, 2014 18:09
meta deps extension
var instantiate = loader.instantiate;
loader.instantiate = function(load){
var loader = this;
var meta = loader.meta[load.name];
var deps = (meta && meta.deps) || [];
if(deps.length) {
var promises = [];
for(var i = 0, len = deps.length; i < len; i++) {
promises.push(loader.import(deps[i]));
@matthewp
matthewp / .vimrc
Created December 12, 2014 14:55
My vimrc
if has('vim_starting')
set nocompatible " Be iMproved
" Required
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
@matthewp
matthewp / retry.js
Created December 15, 2014 14:39
retry deferred
function retry(functionToCall, numberOfTries) {
var dfd = new can.Deferred();
var attempt = function(){
if(numberOfTries) {
functionToCall().then(dfd.resolve, function() {
numberOfTries--;
attempt();
});
return;