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
| module MakeTimeAgoable | |
| extend ActiveSupport::Concern | |
| included do | |
| # code goes here that should be run on the actual include | |
| # or just leave it blank. no one cares. where's my cake? | |
| end | |
| module ClassMethods | |
| attr_reader :_time_agoable |
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
| require 'rubygems' | |
| require 'bundler' | |
| Bundler.require | |
| require './app1' | |
| require './app2' | |
| map '/app1' do | |
| run App1 |
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
| /** | |
| * PaceCar makes it easy to test how fast (or slow) you js runs | |
| * | |
| * Example Usage: | |
| * | |
| * // get a PaceCar ready | |
| * var p = new PaceCar(); | |
| * // start your engines | |
| * p.start(); | |
| * // some sample code you want to test performance of. |
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
| def add(a, b) | |
| a + b | |
| end | |
| def say(what, *people) | |
| people.each { |person| puts "#{person}: #{what}" } | |
| end | |
| say "Hello!", "Bob", "Alice" | |
| # Bob: Hello! |
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
| module Sencha | |
| module NestedListMenu | |
| class << self | |
| # Sencha Touch nested list menu requires json in the form of: | |
| # | |
| # {"text": "some identifier", | |
| # "children": ["text": "child identifier", "other": "info", "leaf": "true"], | |
| # [ ... ] | |
| # }, | |
| # { ... } |
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
| /** | |
| * Application helpers | |
| * requires Underscore.js | |
| */ | |
| var ApplicationHelpers = { | |
| /** | |
| * Railsify object's keys to play nice with default Rails controller setup. | |
| * Rails default controller setup expects params submitted via PUT / POST as: | |
| * | |
| * (POST) {'my_model[attr1]' : 'value1', ... etc. } |
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
| var ApplicationHelpers = { | |
| /** | |
| * Note: requires Underscore.js | |
| * | |
| * Enable a (sencha touch) form to have a link between | |
| * model and form (ie. MyModel.some_attribute <=> textfield.some_attribute) | |
| * AND allow for POST / PUT submission in the rails-friendly namespaced format | |
| * (ie. {my_model[some_attribute] : "some value"}). | |
| * | |
| * To get above behavior, treate model and forms in normal fashion and use |
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
| // requires Underscore.js | |
| var helpers = { | |
| // Takes object and converts key / values to a sentence | |
| // | |
| // Sample usage: | |
| // | |
| // obj = {"this" : "is good", "that" : "is bad", "those" : "are great"} | |
| // | |
| // helpers.to_sentence(obj) | |
| // # "this is good, that is bad, and those are great" |
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
| module Avatarable | |
| extend ActiveSupport::Concern | |
| GRAVATAR_IMAGE_BASE_URL = 'http://www.gravatar.com/avatar/' | |
| GRAVATAR_IMAGE_DEFAULT_SIZE = '32' | |
| DEFAULT_URL = 'http://your-awesome-domain.com/images/your-awesome-default-image.png' | |
| # Avatarable assumes the class (or other module) that includes this module has an email attribute | |
| # if the email attribute is named something other than email, use alias_attribute to map it to email | |
| # alias_attribute :email, :your_email_attribute |
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
| class AvatarImage | |
| GRAVATAR_IMAGE_BASE_URL = 'http://www.gravatar.com/avatar/' | |
| GRAVATAR_IMAGE_DEFAULT_SIZE = '32' | |
| DEFAULT_URL = 'http://your-awesome-domain.com/images/your-awesome-default-image.png' | |
| attr_accessor :email | |
| def self.default_url | |
| DEFAULT_URL | |
| end |