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
| _validate: function(attrs, options) { | |
| if (options.silent || !this.validate) return true; | |
| attrs = _.extend({}, this.attributes, attrs); | |
| var error = this.validate(attrs, options); | |
| if (!error) return true; | |
| if (options && options.error) { | |
| options.error(this, error, options); | |
| } else { | |
| this.trigger('error', this, error, options); | |
| } |
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 SomeProtocol | |
| class NotImplementedError < StandardError | |
| end | |
| def implement_me | |
| raise NotImplementedError | |
| 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
| class SomeBackgroundJob | |
| @queue = :whatever | |
| def self.perform(model_id) | |
| model = Model.find(model_id) | |
| model.do_a_thing | |
| 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
| Zaarly.NativeEventRouter = function() { | |
| return { | |
| 'ok.click' : 'nagivate.editProfile', | |
| 'exit.click' : 'webview.close' | |
| } | |
| } |
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
| object :user do | |
| object :profile do | |
| object :nested do | |
| attributes :property | |
| end | |
| 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
| class SomeMiddleware | |
| HOSTNAME = `hostname`.chomp.freeze | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| if HOSTNAME == 'app1' | |
| status, headers, body = @app.call(env) |
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
| # This class is responsible API parameter type coercion and defaults. | |
| class ListingSearchParam | |
| APPROVED = [:query, :latlng, :box, :sort, :limit, :page, :category_ids, :fulfilled] | |
| def self.parse(opts = {}) | |
| new(opts).parse | |
| end | |
| def initialize(opts = {}) | |
| @errors = ActiveModel::Errors.new(self) |
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
| #!bash | |
| # | |
| # bash completion support for core Git. | |
| # | |
| # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
| # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
| # Distributed under the GNU General Public License, version 2.0. | |
| # | |
| # The contained completion routines provide support for completing: | |
| # |
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
| users = _.map(users, function (i) { {i['month']: i['count']} }) // Uncaught SyntaxError: Unexpected token : |
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
| (defn count-reduce | |
| [memo obj] | |
| (let [key (str (year obj) "/" (month obj))] | |
| (if (get memo key) | |
| (merge memo {key (inc (get memo key))}) | |
| (merge memo {key 1})))) | |
| (str | |
| (reduce count-reduce {} | |
| (map coerce-date |