Skip to content

Instantly share code, notes, and snippets.

@fivetanley
fivetanley / factory.js
Created October 1, 2012 05:38
factory_spec.js
var constructors = {
StreaminfoBlock : require( './streaminfo_block' )
, PaddingBlock : require( './padding_block' )
, ApplicationBlock : require( './application_block' )
, VorbisCommentBlock : require( './vorbis_comment_block' )
, CuesheetBlock : require( './cuesheet_block' )
, PictureBlock : require( './picture_block' )
}
, constructorKeys = Object.keys( constructors )
@fivetanley
fivetanley / string_calculator_spec.coffee
Created October 4, 2012 03:01
yo yo software craftsmanship
expect = require( 'chai' ).expect
StringCalculator =
add: (numbers)->
if !numbers or numbers.length == 1 then return Number numbers
negativeMatcher = /-(\d)/g
if (negativeNumbers = numbers.match( negativeMatcher ))?
throw new Error 'negatives not allowed. negatives: ' + negativeNumbers
result = 0
delimiters = [ new RegExp('\n', 'g') ]
class Foo
# no need to do the assigning to the new object, coffee will do it for you
constructor: ( @instanceVar1 = 'bang', @instanceVar2 = 'baz' ) ->
@fivetanley
fivetanley / DegreesOfSeparationSearchForm.feature
Created October 11, 2012 05:54
Degrees of Separation using cucumber to drive the development
Feature: Degrees of Separation Search Form
The first thing users see on the page is a search form with two boxes.
One of the boxes represents the OriginAccount, that is, the Twitter account
from which to start the search to the DestinationAccount, the Twitter account
we are trying to connect the OriginAccount to using only followers of the
OriginAccount (and their followers).
Scenario: Starting a Degrees of Separation Calculation
Given I am on the site's main page
credentials = stub()
twitter = stub()
describe "Twitter, wrapper for ntwitter", ->
# just declare an undefined variable so it can get picked up later
# with closure scope.
# other alternative i can think of: twitter = "" # empty string or other val
# e.g. what I want is just a `var twitter;`
{twitter} = {}
require [
"jquery",
"media_comments",
"vendor/swfobject/swfobject",
"jqueryui/dialog",
"jquery.doc_previews",
], ($, _mediaComments, swfobject, _docPreviews ) ->
# Submission Preview for media recording links
$(".play_media_recording_link").click (event) ->
@fivetanley
fivetanley / lolqunit.coffee
Last active December 9, 2015 21:59
Lol qunit
class Test
constructor: (@description,@body,@context) ->
run: =>
test.call @context, @description, => @body.call @context
class Suite
capitalize = (string) ->
string[0].toUpperCase() + string.slice(1)
@fivetanley
fivetanley / 0-readme.md
Last active December 11, 2015 19:08 — forked from burke/0-readme.md

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

ruby-1.9.3-p392 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p392 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

## Puts a big annoying arrow in your window when you're not scrolled down, like a dummy
#
scrollAlert = $("<div id='scrolldown-arrow'>⬇</div>")
showing = false
body = $ document.body
win = $ window
doc = $ document