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
#! /bin/bash | |
CWD=`pwd` | |
printUsage() { | |
echo "gitr - Git for multiple repositories made easy!" | |
echo -e "Usage: gitr <branch|status|push|pull|fetch|merge|stash|checkout [options] [arguments]> [--repos <repo>...] [--gitr-base <path>]" | |
} | |
println() { | |
echo "$1" |
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
// inspired when reading https://leanpub.com/understandinges6/read#leanpub-auto-define-tags | |
// this is the behavior that template tags may interweave literals and subsitutions arrays | |
var interweave = (a, b) => { | |
let min = Math.min(a.length, b.length); | |
return Array.apply(null, Array(min)).reduce((result, value, index) => { | |
result.push(a[index], b[index]); | |
return result; | |
}, []).concat((a.length > min ? a : b).slice(min)); | |
}; |
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
describe("toBoolean", function() { | |
var toBool = toBoolean; | |
it("should return true for all objects", function() { | |
expect(toBool({})).toBe(true); | |
expect(toBool([])).toBe(true); | |
}); | |
it("should return false for falsy values", function() { |
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
describe("isPrimitive", function() { | |
it("should return true for primitive values", function() { | |
expect(isPrimitive(0)).toBe(true); | |
expect(isPrimitive('')).toBe(true); | |
expect(isPrimitive(false)).toBe(true); | |
expect(isPrimitive(null)).toBe(true); | |
expect(isPrimitive(undefined)).toBe(true); | |
expect(isPrimitive(NaN)).toBe(true); | |
}); |
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
function* generatorFunction() { | |
// ... | |
} | |
let iterator = generatorFunction(); | |
// for-of loop | |
for (let k of iterator) { | |
// ... | |
} |
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 mongoose = require('mongoose'); | |
var db; | |
var connect = module.exports = function () { | |
mongoose.connect('mongodb://localhost/events'); | |
db = mongoose.connection; | |
db.on('error', function(err) { | |
console.error('Error', err); | |
}); | |
db.once('open', function() { |
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
function format(num, fmt) { | |
if (isNaN(Number(num))) { | |
throw new TypeError('Not a number'); | |
} | |
if (typeof fmt.scale == 'number') { | |
num = Number(num).toFixed(fmt.scale); | |
} | |
num = String(num).replace('.', fmt.outDecSep||'.'); | |
var regexp = /(\d+)(\d{3})/; | |
while(regexp.test(num)) { |
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
$(function() { | |
var tplts = Object.create(null), importLinks = $('link[rel="import"]'); | |
// load all imported templates | |
importLinks.each(function(idx, elem) { | |
$.get(elem.href, function(data) { | |
var view = elem.getAttribute('href'); | |
tplts[view] = data; | |
if (Object.keys(tplts).length == importLinks.length) { | |
// all are loaded | |
console.info("all templates are loaded:", tplts); |
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
validGuess = (sudoku, x, y, value) -> | |
row = sudoku[y] | |
column = row[x] for row in sudoku | |
cube = (sudoku[~~(y/3) + i][~~(x/3) + j] for i in [0..2] for j in [0..2]).reduce (result, curr) -> result.concat(curr) | |
value not in [].concat row, column, cube | |
guess = (sudoku, x, y, value) -> | |
sudoku[y][x] = value if validGuess sudoku, x, y, value | |
# sudoku = genValidSudoku() |
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
<!doctype html> | |
<html> | |
<head> | |
<style type="text/css"> | |
#tbl1 { | |
table-layout: fixed; | |
width: 500px; | |
border-collapse: separate; | |
border-spacing: 0; | |
border: 1px solid #afafaf; |