Jordan Glasner glasner

View turbolinks-widget.js
1 2 3
View beforeunload.coffee
1 2 3 4 5 6 7 8 9 10
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
View 10.js
1 2 3 4 5 6 7 8 9 10
MyView = Backbone.View.extend({
el: '#someElement',
events: {
"click #someButton": "clicked"
},
 
clicked: function(e){
e.preventDefault();
alert("I was clicked!");
}
View email - kindle.scpt
1 2 3 4 5 6 7 8 9 10
 
(*
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
View jammit.rake
1 2 3 4 5 6
namespace :jammit do
desc "creates bundles"
task :bundle do
sh "jammit -f"
end
end
View timezone.js
1 2 3 4 5 6 7 8 9
// 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')
}
})
};
View model.rb
1 2 3 4 5 6 7
# 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'
View increment.rb
1 2 3
@model.counter #=> 1
@model.increment(:counter)
@model.counter #=> 2
View ordinalize.rb
1 2
position = 1;
position.ordinalize #=> '1st'
Something went wrong with that request. Please try again.