Skip to content

Instantly share code, notes, and snippets.

View marshallswain's full-sized avatar
😄

Marshall Thompson marshallswain

😄
View GitHub Profile
@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 / 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">

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 / 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.
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 / 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.
@marshallswain
marshallswain / country-codes.json
Last active January 1, 2016 17:29
List of ISO 3166 Two-character Country Codes
[
{"code", "AF", "name", "AFGHANISTAN"},
{"code", "AX", "name", "ÅLAND ISLANDS"},
{"code", "AL", "name", "ALBANIA"},
{"code", "DZ", "name", "ALGERIA"},
{"code", "AS", "name", "AMERICAN SAMOA"},
{"code", "AD", "name", "ANDORRA"},
{"code", "AO", "name", "ANGOLA"},
{"code", "AI", "name", "ANGUILLA"},
{"code", "AQ", "name", "ANTARCTICA"},
@marshallswain
marshallswain / forever-start.js
Created December 29, 2013 00:55
Deployd custom start script and forever-monitor examples Install Deployd locally using npm install deployd --save. Then npm install forever-monitor --save.
var forever = require('forever-monitor');
var child = new (forever.Monitor)('server.js', {
max: 10,
silent: true,
options: []
});
child.on('exit', function () {
console.log('Your server has exited after 3 restarts');
@marshallswain
marshallswain / camelCase.js
Created December 26, 2013 02:47
camelCase a string. Originally found here: http://valschuman.blogspot.com/2012/08/javascript-camelcase-function.html?view=flipcard Thank you, Val Schuman;
Wrote a function to CamelCase a string in JavaScript. Because, AFAIK, CamelCasing applies only to programming, the function makes sure the string conforms to a legal variable name standard, removing all illegal characters, as well as making sure the string starts with a letter (not a number or an underscore.)
You can add the function to the String object prototype:
String.prototype.toCamelCase = function() {
// remove all characters that should not be in a variable name
// as well underscores an numbers from the beginning of the string
var s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
// uppercase letters preceeded by a hyphen or a space
s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function(a,b,c) {
@marshallswain
marshallswain / firebase.list.js
Created December 23, 2013 08:21
Firebase CanJS LIst Controller
var FirebaseListController = can.Control.extend({
defaults: {
// The main Firebase URL, including the trailing slash.
baseURL: 'https://bchm.firebaseIO.com/',
// The location of the list of data in Firebase.
location: "test_list",
// The HTML attribute that should be added to a template element in the list.
// It will need to be unique and will contain a single value, like an id, not a class.
// unused because I can't get can.Mustache to work with it right now. Keeps printing __!!__
// firebaseKeyName: "data-firebasekey",