Skip to content

Instantly share code, notes, and snippets.

View jacwright's full-sized avatar
👨‍💻
Working on Dabble

Jacob Wright jacwright

👨‍💻
Working on Dabble
View GitHub Profile
@jacwright
jacwright / post-commit
Created March 11, 2016 07:17
For Chip, copy docs to jekyll website
#!/bin/sh
#
# Copies the docs over to the website repository and commits it
folder_name=${PWD##*/}
LAYOUT_PREFIX='---\r\nlayout: default\r\n---\r\n\r\n'
mkdir -p "../chip-js.github.io/docs/$folder_name"
if [ -d "docs" ]; then
@jacwright
jacwright / Model.js
Created December 10, 2015 17:56
Constructor that returns a new constructor
function Model() {
var constructor = function(props) {
Object.keys(props).forEach(function(key) {
this[key] = props[key];
}, this);
};
constructor.prototype = Object.create(Model.prototype);
constructor.prototype.constructor = constructor;
return constructor;
@jacwright
jacwright / class.js
Created November 19, 2015 20:51
Fix class.extend to support class.static and removes mixins
function Class() {}
Class.extend = extend;
module.exports = Class;
function extend(Subclass, prototype) {
// Support no constructor
if (typeof Subclass !== 'function') {
prototype = Subclass;
var SuperClass = this;
Subclass = function() {
@jacwright
jacwright / bindings.coffee
Created April 28, 2015 15:51
Aliases existing chip bindings to use [*], (*), and {*}
# Add aliases for the bindings to use brackets, e.g. bind-value becomes [value]
chip.Binding.bindings.slice().forEach (binding) ->
name = binding.name
return if name.indexOf('-*') >= 0
if binding.name.indexOf('bind-') is 0 || binding.name.indexOf('attr-') is 0
name = '[' + name.replace(/^(bind|attr)-/, '') + ']'
chip.binding name, binding.priority, binding.handler
else if binding.name.indexOf('on-') is 0
name = '(' + name.replace(/^on-/, '') + ')'
// Required modules.
var cradle = require('cradle');
var util = require('util');
var http = require('http');
// Config.
var config = require('./config');
// Create a new HTTP server to accept Postmark POSTs.
http.createServer(function(req, res) {