Skip to content

Instantly share code, notes, and snippets.

View marshallswain's full-sized avatar
😄

Marshall Thompson marshallswain

😄
View GitHub Profile
@marshallswain
marshallswain / firemap.js
Created April 3, 2014 22:05
CanJS Firebase Map. Pass in a firebase snapshot and get a can.Map that syncs with Firebase when an attribute is updated.
'use strict';
var FireMap = can.Map.extend({
'setup':function(snapshot){
this.new = true;
// Get the data from the snapshot.
var data = snapshot.val();
// Save the fb ref with it.
var each = function(arr, cb){
var i = 0, len = arr.length;
for(; i < len; i++) {
if(cb(arr[i]) === false) {
return;
}
}
};
var baseImport = System.import;
@marshallswain
marshallswain / gist:2ff968cbeef8817e789b
Created May 11, 2015 16:52
Errors with DocumentJS in package.json
Marshalls-MacBook-Pro:funcunit-test marshallthompson$ steal-tools build
OPENING: /Users/marshallthompson/Sites/funcunit-test/package.json!npm
WARN: Could not find dojo/dojo in node_modules. Ignoring.
WARN: Could not find yui/yui in node_modules. Ignoring.
WARN: Could not find mootools/mootools in node_modules. Ignoring.
WARN: Could not find zepto/zepto in node_modules. Ignoring.
WARN: Could not find steal-qunit/steal-qunit in node_modules. Ignoring.
WARN: Could not find steal-qunit in node_modules. Ignoring.

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.

@marshallswain
marshallswain / layout.mustache
Last active August 29, 2015 14:21
DocumentJS layout with menu
<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js ie lt-ie9 lt-ie8 lt-ie7" lang="en">
<![endif]-->
<!--[if IE 7]>
<html class="no-js ie lt-ie9 lt-ie8" lang="en">
<![endif]-->
<!--[if IE 8]>
<html class="no-js ie lt-ie9" lang="en">
@marshallswain
marshallswain / nginx.conf
Created May 27, 2015 05:05
NginX minimal virtual host configuration for StriderCI
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@marshallswain
marshallswain / live-binding-opt-out.js
Created July 5, 2015 21:36
Live Binding Opt Out Helper
// Opt out of live binding by not using the property's compute.
// Usage: {{~ 'propName'}}
can.stache.registerHelper('~', function(prop, options) {
return options.context[prop];
});
@marshallswain
marshallswain / validation.stache
Last active September 22, 2015 21:34
Validation Ideas
viewModel = {
// Added implicitly
validation: {
comment: [],
username: {
required: "Username is required."
}
}
@marshallswain
marshallswain / gist:5420924
Created April 19, 2013 15:03
Line to simplify ExpressJS logger output.
this.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' })); this.use(express.favicon());
@marshallswain
marshallswain / server.js
Last active December 16, 2015 10:29
Server.js file for LocomotiveJS.
var locomotive = require('locomotive'),
env = process.env.NODE_ENV || 'development',
port = process.argv[2] || process.env.PORT || 3000,
address = '0.0.0.0';
console.log(process.argv);
locomotive.boot(__dirname, env, function(err, server) {
if (err) { throw err; }
server.listen(port, address, function() {