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
| Kernel.class_eval do | |
| alias :old_require :require | |
| def require(*args) | |
| puts args | |
| old_require(*args) | |
| 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
| describe Note do | |
| describe 'notes with valid time entry' do | |
| [ {text: 't:9h20m', parsed_entry: 33600}, | |
| {text: 't:20m', parsed_entry: 1200}, | |
| {text: 't: 9h', parsed_entry: 32400}, | |
| {text: 't: 20m', parsed_entry: 1200}, | |
| {text: 't: 09h', parsed_entry: 32400}, | |
| {text: 'time: 09h', parsed_entry: 32400}, | |
| {text: 'Time: 20m', parsed_entry: 1200} | |
| ].each do |note| |
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
| #Reassign All Markets and children to a new region | |
| def self.reasign_all_markets_to_new_region(old_region_id, new_region_id) | |
| # old_southeast = Group.find_by_id(10870) | |
| # new_southeast = Group.find_last_by_name('Southeast') | |
| # sql.execute("UPDATE links SET parent_id = #{new_southeast.id} WHERE parent_id=#{old_southeast.id}"); | |
| #or | |
| # g = Group.find_by_id(7283) | |
| # ng = Group.find(12791) | |
| # BurgerKing::GroupRedistribution.reasign_all_markets_to_new_region(g.id, ng.id) |
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 Appointment = Backbone.Model.extend({}); | |
| var appointment = new Appointment(); | |
| appointment.set('title', 'My knee hurts'); | |
| var AppointmentView = Backbone.View.extend({ | |
| render: function(){ | |
| $(this.el).html(' | |
| ' + this.model.get('title') + ' '); | |
| } | |
| }); |
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
| //1. Defaults | |
| var Appointment = Backbone.Model.extend({ | |
| defaults: { | |
| title: 'Checkup', | |
| date: new Date() | |
| } | |
| }); | |
| //2 Fixing Defutls | |
| var Appointment = Backbone.Model.extend({ |
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
| // 1. Changing the class | |
| var AppointmentView = Backbone.View.extend({tagName: 'li'}); | |
| // 2. adding a class | |
| var AppointmentView = Backbone.View.extend({ | |
| tagName: 'li', | |
| className: 'appointment' | |
| }); | |
| //3. TOP-LEVEL JQUERY |
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
| # **Quickly Host a Git Repository** | |
| REPO_ROOT='~/source/repos' # Can be anywhere | |
| GIT_PROJECT_PATH='~/projects/my_cool_git_project' # Your local project using git | |
| GIT_PROJECT_NAME=$(basename $GIT_PROJECT) | |
| mkdir -p $REPO_ROOT | |
| cd $REPO_ROOT | |
| git clone --bare $GIT_PROJECT_PATH | |
| cd $GIT_PROJECT_NAME.git |
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 'rspec' | |
| class Array | |
| def custom_group_by(&block) | |
| results = {} | |
| each do |e| | |
| (results[block.call(e)] ||= []) << e | |
| 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
| tweet = Tweet.new('Ruby Bits!') | |
| success = -> { puts "Sent!"} | |
| error = -> { raise 'Auth Error' } | |
| tweet.post(success, post) |
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
| #closure and lambdas | |
| def tweet_as(user) | |
| lambda {|tweet| puts "#{user}: #{tweet}"} | |
| end | |
| mark_tweet = tweet_as("mark") | |
| mark_tweet.call("This is awesome!") |
OlderNewer