Skip to content

Instantly share code, notes, and snippets.

@EndangeredMassa
EndangeredMassa / .bashrc
Last active October 6, 2015 08:48
Tmux Setup
alias tm="~/.tmux/tmux.sh"
@EndangeredMassa
EndangeredMassa / backbone_render.coffee
Created June 18, 2012 19:14
JavaScript Testing Best Practices: Part 2
view = Backbone.View.extend
initialize:
@render()
render:
$el.html('<div class="content">fun times</div>')
@EndangeredMassa
EndangeredMassa / auto_init.coffee
Created June 18, 2012 18:55
JavaScript Testing Best Practices: Part 1
OrderSystem =
init: ->
$('#container').append('<div id="order-system" />')
# init is included at the end of the file
OrderSystem.init()
it 'OrderSystem init works', ->
OrderSystem.init() # now called twice
--type-add=css=.sass,.scss
--type-set=haml=.haml
--type-add=ruby=.haml,.rake
--type-add=js=.mustache
--type-set=coffee=.coffee
--type-add=objc=.pch
--type-set=xcode=.pbxproj,.pbxuser,.perspectivev3
--type-set=ragel=.rl
--type-set=nib=.xib
--type-set=plist=.plist
@EndangeredMassa
EndangeredMassa / grooveshark.com.js
Created June 13, 2012 15:10
Grooveshark ease of use
// Config
var userName = 'endangeredmassa';
// Utils
function waitsFor(condition, callback){
if (condition())
callback();
else
setTimeout(function(){
@EndangeredMassa
EndangeredMassa / backbone_zepto_spec.coffee
Created April 25, 2012 15:51
Trying to get Zepto to trigger backbone events without attaching to the DOM
# using coffeescript and jasmine, but the idea should be clear
# if this runs on jquery, all tests pass; if it runs on zepto (RC1 or 0.8), only the second spec passes
it 'fails: triggers event on nested element', ->
$div = $('<div><div class="close"></div></div>')
notified = false
$div.on 'click', ->
notified = true
$div.find('.close').trigger('click')
waitsFor -> notified
@EndangeredMassa
EndangeredMassa / bootstrap.coffee
Created April 22, 2012 06:00
Jasmine and RequireJS
TEST_ENV = (typeof window['jasmine'] == 'object')
prefix = if TEST_ENV then '/public' else ''
require.config
baseUrl: prefix
@EndangeredMassa
EndangeredMassa / hidey.coffee
Created March 28, 2012 22:10
A command-line script to strip out display:none declarations to include in your test runners
#!/usr/bin/env coffee
CSSOM = require 'cssom'
fs = require 'fs'
if process.argv.length != 4
console.log('Usage: ./hidey inputFile outputFile')
return
fileName = process.argv[2]
@EndangeredMassa
EndangeredMassa / some_spec.js
Created March 27, 2012 15:19
Overwrite Jasmine's describe method for requirejs support
describe 'test some stuff', ['SomeModule'], ->
it 'testing something', ->
@SomeModule.act()