Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
#Make stuff happy
(window.TestDouble = {}).Views = {}
JST = "backbone/templates/inquiry": ->
class TestDouble.Views.InquiryView extends Backbone.View
template: JST["backbone/templates/inquiry"]
categories: [
"build an application",
"receive training",
window.MapPoint = Backbone.Model.extend({
initialize: function(attrs,options){
this.location = options.location;
},
locationDescription: function(){
var lat = this.location.get('lat'),
lng = this.location.get('lng');
return "("+lat+","+lng+")";
}
SecretTreasure = (config) ->
somethingWasTyped: ->
if $('.secret').val() == config.secret
$('.treasure').removeClass('hidden')
/Users/justin/.rvm/gems/[email protected]/gems/jasmine-headless-webkit-0.8.0/lib/jasmine/headless.rb:3: uninitialized constant Jasmine (NameError)
from /Users/justin/.rvm/gems/[email protected]/gems/jasmine-headless-webkit-0.8.0/lib/jasmine-headless-webkit.rb:1:in `require'
from /Users/justin/.rvm/gems/[email protected]/gems/jasmine-headless-webkit-0.8.0/lib/jasmine-headless-webkit.rb:1
from /Users/justin/.rvm/gems/[email protected]/gems/jasmine-headless-webkit-0.8.0/bin/jasmine-headless-webkit:7:in `require'
from /Users/justin/.rvm/gems/[email protected]/gems/jasmine-headless-webkit-0.8.0/bin/jasmine-headless-webkit:7
from /Users/justin/.rvm/gems/[email protected]/bin/jasmine-headless-webkit:19:in `load'
from /Users/justin/.rvm/gems/[email protected]/bin/jasmine-headless-webkit:19
@searls
searls / bigtime.js
Created December 2, 2011 17:42
Bookmarklet to plug in harvest CSV exports to BigTime
var jquerify = function(callback) {
//ripped from karl: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet/
var el=document.createElement('div'),
b=document.getElementsByTagName('body')[0],
otherlib=false,
msg='';
el.style.position='fixed';
el.style.height='32px';
el.style.width='220px';
el.style.marginLeft='-110px';
↪ master(ahead)[dirty] tmp ≈ git clone https://github.com/ottobar/coderetreat_javascript_template.git
Cloning into coderetreat_javascript_template...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 17 (delta 0), reused 17 (delta 0)
Unpacking objects: 100% (17/17), done.
↪ master(ahead)[dirty] tmp ≈ cd coderetreat_javascript_template/
↪ master coderetreat_javascript_template ≈ bundle
class window.Sudoku
constructor: (board) ->
@board = board
solve: ->
[]
column: (index) ->
(cell for cell,cellIndex in @board when cellIndex % 9 == index)
@searls
searls / eco_backbone_annoyance.js
Created December 8, 2011 19:16
An annoyance when using eco and you pass it a backbone model, you must bind Model#escape yourself.
//This is a template generated by eco
var ecoTemplate = function (__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
expect($.fn.ajax).toHaveBeenCalledWith({
url: "/1/3/3"
success: jasmine.any(Function);
});
//....
var callback = $.fn.ajax.mostRecentCall.args[0].success
//then you can write tests directly against the callback handler.
@searls
searls / findAllValuesThat.coffee
Created January 17, 2012 03:11
recursively find all values that pass a truth test
foo = {}
bar = {}
baz = {}
o =
z: foo
foo:
a: bar
b: 3
z:
lah: baz