Skip to content

Instantly share code, notes, and snippets.

View killtheliterate's full-sized avatar

Garrett Dawson killtheliterate

View GitHub Profile
module Data.PhoneBook where
import Data.List
import Data.Maybe
import Control.Plus (empty)
type Entry = { firstName :: String, lastName :: String, phone :: String }
type PhoneBook = List Entry
var uh = function() {
var closed = 'hi';
return {
foo: function() {
console.log(closed);
}
};
};
countTheWordSup('sup hi hey up up hi sup hellowww'); // 2
var countTheWordSup = counter('sup');
var counter = function(wordToCount) {
return function(findIn) { // an closure, a closure.
return findIn.match(new RegExp(wordToCount, 'g')).length;
}
}
var counter = function(wordToCount, findIn) {
return findIn.match(new RegExp(wordToCount, 'g')).length;
};
'these are some words that i want to search for a thing, and i am searching, yea, searching'.match(new RegExp('thing')).length;
(function(first) {
return function(second) { // this function is a closure, as it closes around its containing scope
return first + second;
}
}(1)(1));
@killtheliterate
killtheliterate / gist:62ff5163f3633b694a64
Last active August 29, 2015 14:02
git hook recommendations

Git hooks to validate code style

This recommendation is motivated by the fact that a common code style will reduce extraneous git diffs caused by formatting differences. The git log will be more parseable.

A pre-commit hook is the appropriate hook to use for validating code changes before committing. We can use a precommit hook to:

  • Validate JavaScript with jshint: example
  • Validate white space usage: example
  • Run staged files through js-beautify, in verify-only mode
function voff() {
DATVM=`VBoxManage list runningvms | awk '{gsub(/"/, "", $1); print $1}'`
VBoxManage controlvm $DATVM poweroff
}