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 Song | |
| include MongoMapper::Document | |
| plugin Grip | |
| attachment :mp3 | |
| key :title, String | |
| key :artist, String | |
| key :album, String | |
| key :genre, String |
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 SongsController < ApplicationController | |
| def index | |
| @songs = Song.all(:destroyed_at => nil) | |
| @totals = load_totals(@songs) | |
| end | |
| def new | |
| @song = Song.new | |
| render :layout => false |
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 Event | |
| include MongoMapper::Document | |
| include MultiParameterAttributes | |
| key :name, String, :required => true | |
| key :start_date, Date, :required => true | |
| key :start_time, Time, :required => true | |
| 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 Job < CouchRestBase | |
| include Delayed::Backend::Base | |
| use_database :delayed_job | |
| property :priority | |
| property :attempts | |
| property :handler | |
| property :run_at | |
| property :locked_at | |
| property :locked_by |
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
| /* Trivial keyboard input layout to english switcher by Alexander V. Zhouravlev. | |
| * Compile it with gcc -framework Carbon -o SwitchToEnglish SwitchToEnglish.m */ | |
| #import <Carbon/Carbon.h> | |
| int main (int argc, const char *argv[]) | |
| { | |
| TISInputSourceRef english = TISCopyInputSourceForLanguage(CFSTR("en-US")); | |
| if (!english) | |
| return 1; |
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 error = new Error; | |
| Object.defineProperty(global, '__stack', { | |
| get: function(){ | |
| Error.prepareStackTrace = function(err, frames){ | |
| err.frames = frames; | |
| }; | |
| try { | |
| throw error; | |
| } catch (err) { |
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
| # ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby) | |
| # | |
| # turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses! | |
| # ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165 | |
| # | |
| # ... kudos to @chadfowler for the tip! | |
| # | |
| # (note: works on 1.8.7 as well :-)) | |
| def should_i_upgrade? |
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
| # ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby) | |
| # | |
| # turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses! | |
| # ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165 | |
| # | |
| # ... kudos to @chadfowler for the tip! | |
| # | |
| # (note: works on 1.8.7 as well :-)) | |
| def should_i_upgrade? |
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
| cd ~ | |
| sudo apt-get update | |
| sudo apt-get install unzip curl python-software-properties openjdk-7-jre -y | |
| wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.2.tar.gz -O elasticsearch.tar.gz | |
| tar -xf elasticsearch.tar.gz | |
| rm elasticsearch.tar.gz | |
| sudo mv elasticsearch-* elasticsearch | |
| sudo mv elasticsearch /usr/local/share |
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 Rails.root.to_s + '/lib/watch.rb' | |
| watch TheFind::SearchQuery, :initialize do | |
| before do |*args| | |
| attrs = args[0] | |
| SmartLog.info("SearchPoduct", attrs) | |
| end | |
| end |
OlderNewer