Skip to content

Instantly share code, notes, and snippets.

View dabit's full-sized avatar

David Padilla dabit

View GitHub Profile
@dabit
dabit / fix_skype_conversation_icons_retina.sh
Created October 14, 2012 03:40 — forked from dive/fix_skype_conversation_icons_retina.sh
Fix the size of avatars in the Skype conversation screen for Retina Macbook Pro screen
#!/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'
@dabit
dabit / lazy-1.rb
Created November 4, 2012 06:25
Ruby 2.0 features examples
elements = (1..19999999)
p elements.class # => Range
results = elements.select { |n|
n % 2 == 0
}.map { |n|
n + 1
}.take(10)
@dabit
dabit / Rakefile
Created November 16, 2012 17:26
How to fix the Ruby motion dependency problem
Motion::Project::App.setup do |app|
app.files.insert(-10, "./app/controllers/nav_bar_controller.rb")
end
@dabit
dabit / Gemfile
Last active December 12, 2015 01:38
Rails Issue #8811
source "https://rubygems.org"
gem "sqlite3"
gem "rails", :git => 'https://github.com/rails/rails.git', :branch => '3-2-stable'
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
}
def times_bought
count = 0
orders = Spree::Order.complete
orders.each {|o| count+=1 if o.products.include?(self)}
count
end
def foo(options = {})
[options[:bar], options[:baz]]
end
foo(bar: '12345', baz: 'abcdef') # => ["12345", "abcdefg"]
@dabit
dabit / Rack.rb
Created March 21, 2013 03:31
Railsconf talk
def call(env)
[200, {}, 'Hello']
end
@dabit
dabit / hash_table.rb
Last active May 16, 2023 16:57
Code example for my blogpost Hash lookup in Ruby, why is it so fast?
require 'benchmark'
#
# Code example for my blogpost
#
# Hash lookup in Ruby, why is it so fast?
#
#
# Struct used to store Hash Entries
@dabit
dabit / Gemfile
Last active December 17, 2015 21:39
AASC Example
source "https://rubygems.org"
gem "acts_as_shopping_cart"
gem "sqlite3"