Skip to content

Instantly share code, notes, and snippets.

View dkubb's full-sized avatar
🏠
Working from home

Dan Kubb dkubb

🏠
Working from home
  • Betterment
  • Mission, BC, Canada
  • X @dkubb
View GitHub Profile
# current code:
unless @users = cache_get("active_users")
@users = User.all(:active => true)
cache_set("active_users", @users)
# object caching can be used to avoid pulling huge amounts of data
# from the database.
# you could have calle cache_set with an expiration time as well:
# cache_set("active_users", @users, 10)
end
@dkubb
dkubb / Brewfile
Last active August 29, 2015 14:01
My Brewfile
# Upgrade, Update, Check Homebrew
update
upgrade
doctor
# Install taps
tap caskroom/cask
tap sceaga/tap
# Install bash
@dkubb
dkubb / sitemap.rb
Created June 27, 2014 23:19
Create a sitemap for supplied hostname and list of urls
#!/usr/bin/ruby
require 'rubygems'
require 'mechanize'
require 'addressable/uri'
ROOT_URL = Addressable::URI.parse(ARGV.fetch(0)).freeze
# Disable SSL certificate verification
I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil
# inside Rakefile
unless ARGV.any? && ARGV[0][0..3] == 'dm:'
Kernel.send(:undef_method, :repository)
end
it 'should save both the object and parent if both are new' do
pending('This is a bug that should be fixed') do
area1 = Area.new(:name => 'area1')
area1.machine = Machine.new(:name => 'machine1')
area1.save
area1.machine_id.should == area1.machine.id
end
end
father = Father.new
child = Child.new(:father => father)
father.save
child.father_id.should == father.id # how? the child references the father, but there's no backlink atm
# ... unless
@identity_map = Hash.new do |h,model|
resource = h[model.base_model]
# set the IM if the resource's model is an ancestor of model
h[model] = resource if resource.model >= model
end
Merb::BootLoader.after_app_loads do
DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, Merb.logger.level)
end
@dkubb
dkubb / gist:e2763e1bd1047ab0bcd6
Last active August 29, 2015 14:22
Slack Conversation about Ruby5 comments
dkubb [12:34 PM]
I feel solnic’s pain in trying to swim against the current
dkubb [12:44 PM]
https://twitter.com/dkubb/status/608359066172313600
Dan Kubb@dkubb
.@rubyfive @_solnic_ has done great things for ruby, and your dismissive tone to his valid criticism only hurts the community.
Today at 12:44 PM
mbj [12:47 PM]