Skip to content

Instantly share code, notes, and snippets.

View wilmoore's full-sized avatar

Wil (₩) Moore III wilmoore

View GitHub Profile
@wilmoore
wilmoore / limitations.md
Created April 30, 2012 17:24
YUI Resources for TDD/BDD w/ YUI3 Test

YUI3 Test Limitations

  • YUI3 Test does not support Data Providers for Parameterized Testing. You are welcome to use the extremely hacky solution that I came up with.
  • Because checking for failures (errors/exceptions) must be defined as a separate hash by name, you end up with a lot of duplication and potential for errors if you forget to rename the item in the "error" hash after renaming the test method.
  • Because checking for failures (errors/exceptions) must be defined as a separate hash by name, you lose the ability to dynamically check for errors/exceptions.
@wilmoore
wilmoore / tests.html
Created April 30, 2012 21:47
YUI3 Test Skeleton Setup: for testing your YUI3 powered modules
<!doctype html>
<html>
<title>Test Console</title>
<body class="yui3-skin-sam">
<div id="test-console"></div>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
<script src="tests.js"></script>
</body>
</html>
@wilmoore
wilmoore / sinatra.sh
Created May 2, 2012 23:03
Contributing to Ruby-based projects should always be this easy
# Obtain the project (assumes you've forked it)
% cd ~/projects
% git clone [email protected]:wilmoore/sinatra.git && cd sinatra
% bundle install
# Run Tests
% bundle exec rake test
@cowboy
cowboy / tab-indent-rant.js
Created May 3, 2012 19:18
JavaScript: tab indents
// Coders, if your goal is to align foo and bar, using a <tab> character is
// incorrect. If your goal, however, is to create an additional level of
// indentation, then go you. Either way, with a tab size other than 4, this
// looks like shit.
var foo = 1,
bar = 2;
@haschek
haschek / .jshintrc
Created May 4, 2012 16:08
JSHint Configuration, Strict Edition
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@wilmoore
wilmoore / butterflymachine.js
Last active October 5, 2015 00:17 — forked from tjstebbing/butterflymachine.js
Butterfly state machine ( http://harkablog.com/dynamic-state-machines.html ) in javascript
#!/usr/bin/node
/* butterfly state machine */
var Egg = function(species) {
this.species = species;
console.log("An egg");
this.hatch = function() {
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@wilmoore
wilmoore / RECAP.md
Created June 1, 2012 19:57
'Hello, world': Programming languages quiz

Score: 17/20

The languages I missed were:

  • Haskell - I'm a little surprised I missed this but I'm not terribly worried about it
  • Cobol - I am very surprised I missed this one. The PROGRAM-ID keyword is a dead giveaway. Even worse was the review comments at the end for this question read "Once you've seen Cobol code, you can never forget it". Well, crap...I guess I must be dense.
  • Fortran - Not surprised at all. I don't recall every reviewing a Fortran program in my life.

Further observations:

@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@wilmoore
wilmoore / word-reverse.js
Created June 16, 2012 04:37
Accept a string, tokenize into words (delimited by spaces), output words with reversed characters, words stay in original order
function wordify(string) {
var index = 0;
var word = '';
var words = [];
var end = string.length - 1;
while(string[index] !== undefined) {
word += /^\s/.test(string[index]) ? '' : string[index];
if (/\s/.test(string[index]) || index === end) {