Skip to content
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
MyView = Backbone.View.extend({
el: '#someElement',
events: {
"click #someButton": "clicked"
},
clicked: function(e){
e.preventDefault();
alert("I was clicked!");
}
(*
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
namespace :jammit do
desc "creates bundles"
task :bundle do
sh "jammit -f"
end
end
// 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')
}
})
};
# 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'
@model.counter #=> 1
@model.increment(:counter)
@model.counter #=> 2
position = 1;
position.ordinalize #=> '1st'
Something went wrong with that request. Please try again.