This file contains 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
#!/usr/bin/env ruby | |
# Copyright (c) 2012 Ulf Schwekendiek (sulf@me.com) | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains 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
_.extend Backbone.Router.prototype, { | |
# load a new fragment, replacing the current history entry with the new fragment | |
# this is used to prevent a back-button-redirect loop | |
redirect:(fragment) -> | |
Backbone.history.redirect(fragment) | |
} | |
_.extend Backbone.History.prototype, { | |
redirect:(fragment) -> | |
frag = (fragment || '').replace(/^#*/, '') |
This file contains 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
class BackboneViewGenerator < Rails::Generators::NamedBase | |
def copy_initializer_file | |
create_file "app/assets/javascripts/desktop/views/#{file_name}.js.coffee", <<-FILE | |
class App.Views.#{class_name} extends App.Views.MetodayView | |
template: -> JST['desktop/templates/#{file_name}'] | |
initialize: -> | |
super | |
$(@el).addClass('#{file_name}') |
This file contains 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
var distance_of_time_in_words, time_ago_in_words; | |
time_ago_in_words = function(from_time, include_seconds) { | |
if (include_seconds != null) { | |
include_seconds; | |
} else { | |
include_seconds = false; | |
}; | |
return App.distance_of_time_in_words(from_time, Date.now(), include_seconds); | |
}; | |
distance_of_time_in_words = function(from_time, to_time, include_seconds) { |
This file contains 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
time_ago_in_words = (from_time, include_seconds) -> | |
include_seconds ?= false | |
App.distance_of_time_in_words(from_time, Date.now(), include_seconds) | |
distance_of_time_in_words = (from_time, to_time, include_seconds) -> | |
include_seconds ?= false | |
to_time ?= 0 | |
distance_in_minutes = Math.round(Math.abs(to_time - from_time) / 60 / 1000) | |
distance_in_seconds = Math.round(Math.abs(to_time - from_time) / 1000) |
This file contains 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
AutoBind = | |
auto_bind: -> | |
funcs = _.functions(@constructor.prototype) | |
protoFuncs = ['auto_bind', 'constructor'].concat( | |
_.functions(Backbone.Collection.prototype), | |
_.functions(Backbone.Model.prototype), | |
_.functions(Backbone.View.prototype)) | |
_.each funcs, (f) => |
This file contains 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
+++++ +++++ initialize counter (cell #0) to 10 | |
[ use loop to set the next four cells to 70/100/30/10 | |
> +++++ ++ add 7 to cell #1 | |
> +++++ +++++ add 10 to cell #2 | |
> +++ add 3 to cell #3 | |
> + add 1 to cell #4 | |
<<<< - decrement counter (cell #0) | |
] | |
> ++ . print 'H' | |
> + . print 'e' |