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
| #!/bin/bash | |
| # by Artyom Loenko aka dive ([email protected]) | |
| # Usage: | |
| # - download this script | |
| # - open Terminal.app | |
| # - goto to Folder where script downloaded | |
| # - run 'chmod +x fix_skype_conversation_icons_retina.sh' | |
| # - then run './fix_skype_conversation_icons_retina.sh' |
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
| elements = (1..19999999) | |
| p elements.class # => Range | |
| results = elements.select { |n| | |
| n % 2 == 0 | |
| }.map { |n| | |
| n + 1 | |
| }.take(10) |
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
| Motion::Project::App.setup do |app| | |
| app.files.insert(-10, "./app/controllers/nav_bar_controller.rb") | |
| 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
| source "https://rubygems.org" | |
| gem "sqlite3" | |
| gem "rails", :git => 'https://github.com/rails/rails.git', :branch => '3-2-stable' |
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 matches?(env) | |
| req = @request.new(env) | |
| @constraints.each { |constraint| | |
| if constraint.respond_to?(:matches?) && !constraint.matches?(req) | |
| return false | |
| elsif constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req)) | |
| return false | |
| 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
| def times_bought | |
| count = 0 | |
| orders = Spree::Order.complete | |
| orders.each {|o| count+=1 if o.products.include?(self)} | |
| count | |
| 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
| def foo(options = {}) | |
| [options[:bar], options[:baz]] | |
| end | |
| foo(bar: '12345', baz: 'abcdef') # => ["12345", "abcdefg"] | |
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 call(env) | |
| [200, {}, 'Hello'] | |
| 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
| require 'benchmark' | |
| # | |
| # Code example for my blogpost | |
| # | |
| # Hash lookup in Ruby, why is it so fast? | |
| # | |
| # | |
| # Struct used to store Hash Entries |
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
| source "https://rubygems.org" | |
| gem "acts_as_shopping_cart" | |
| gem "sqlite3" |