This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Node Static Server using Express | |
var express = require('express'), | |
app = express(); | |
app.use(express.static(__dirname)); | |
app.listen(9000); | |
console.log("Listening on 9000"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//each accepts an array of functions that return a promise | |
$.Deferred.serialize = function(fns) { | |
if(!$.isArray(fns) || fns.length === 0) | |
return $.Deferred().resolve().promise(); | |
var pipeline = fns[0](), c = 1, l = fns.length; | |
for(;c < l;c++) | |
pipeline = pipeline.pipe(fns[c]); | |
return pipeline; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom tasks | |
grunt.registerMultiTask('css2js', 'Convert CSS to JS.', function() { | |
var name = this.target, | |
src = grunt.file.expandFiles( this.data.file ), | |
dest = src + '.js'; | |
grunt.log.writeln("Converting: '" + src + "' to JavaScript"); | |
var css = fs.readFileSync(src).toString(); | |
if(!css) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Explaination: | |
// start with the empty set | |
// extract the head element | |
// copy each element in the set with the current head element appended | |
// recurse | |
var combinations = function(set) { | |
return (function acc(xs, set) { | |
var x = xs[0]; | |
if(typeof x === "undefined") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set PATH /usr/local/bin $PATH | |
function fish_greeting | |
end | |
function fish_prompt | |
set_color cyan | |
echo -n $USER | |
echo -n ' ' | |
set_color $fish_color_cwd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: node_js | |
node_js: | |
- 0.8 | |
before_script: | |
- phantomjs --version | |
script: cake test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glob = require "glob-manifest" | |
async = require "async" | |
_ = require "lodash" | |
class IncludesRun | |
#types of buildable files | |
templates: | |
js: _.template '<script src="<%= src %>"></script>' | |
css: _.template '<link rel="stylesheet" href="<%= src %>"/>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('crypto'); | |
function guid() { | |
return crypto.randomBytes(6).toString('hex'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Object create with object extension | |
function inherit(parent, object) { | |
function F(){} | |
F.prototype = parent | |
return $.extend(new F(), object); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var visited = [], type, str; | |
var visit = function(val, path) { | |
if(!path) path = ''; | |
if(visited.indexOf(val) >= 0) return; | |
visited.push(val); | |
type = typeof val; | |
str = type !== 'function' ? val : '*'; | |
OlderNewer