This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('page:load', function() { | |
GrooveWidget.add(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sleep = (duration) -> | |
milliseconds = -> new Date().getTime() | |
start = milliseconds() | |
runningFor = milliseconds() - start | |
while runningFor < duration | |
runningFor = milliseconds() - start | |
$('div') # has to actually do something for it to work | |
window.addEventListener 'beforeunload', (e) -> | |
# make *sync* ajax call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyView = Backbone.View.extend({ | |
el: '#someElement', | |
events: { | |
"click #someButton": "clicked" | |
}, | |
clicked: function(e){ | |
e.preventDefault(); | |
alert("I was clicked!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Add this file to /Library/Scripts/Folder Action Scripts/ | |
A slightly modified version.. | |
Murphy Mac | |
see http://murphymac.com/files-mailed-magically-when-dropped-in-a-finder-folder/ for more information. | |
*) | |
on adding folder items to Kindle after receiving theAddedItems |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :jammit do | |
desc "creates bundles" | |
task :bundle do | |
sh "jammit -f" | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run on <select> | |
$.fn.timeZone = function() { | |
return this.extend({ | |
selectUserTimezone: function(){ | |
var timeZone = (new Date().getTimezoneOffset() / 60) + ':00'; // => '5:00' | |
this.find("option:contains(" + timeZone + "):first").attr('selected', 'selected') | |
} | |
}) | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your model | |
has_many :widgets | |
accepts_nested_attributes_for :widgets | |
# @model = Model.new ({:widget_attributes => [{:name => 'one'},{:name => 'two'}] }) | |
# @model.widgets[0].name #=> 'one' | |
# @model.widgets[1].name #=> 'two' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model.counter #=> 1 | |
@model.increment(:counter) | |
@model.counter #=> 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
position = 1; | |
position.ordinalize #=> '1st' |