Skip to content

Instantly share code, notes, and snippets.

@olivierlacan
olivierlacan / 1_nickel.rb
Last active Aug 29, 2015
Trying to figure out why I'm having to manually require a class that is within the same namespace inside of Rails.
View 1_nickel.rb
# located in lib/pumper/nickel.rb
# the only way Back.setup works inside of #add_crappy_music
# is if I add the following:
# require "pumper/nickel/back"
#
# Why?
module Pumper
class Nickel < ActiveRecord::Base
def add_crappy_music
View keybase_proof.md

Keybase proof

I hereby claim:

  • I am olivierlacan on github.
  • I am olivierlacan (https://keybase.io/olivierlacan) on keybase.
  • I have a public key whose fingerprint is 657E 4315 B9D1 4DA4 EC57 152C 8AF8 9C6A 1FF9 AF6D

To claim this, I am signing this object:

@olivierlacan
olivierlacan / Hash#contain?.patch
Last active Aug 29, 2015 — forked from nobu/Hash#comprized?.diff
Proposed implementation for Hash#contains? created by Nobu and slightly tweaked for semantics. Details here: http://olivierlacan.com/posts/proposal-for-a-better-ruby-hash-include/
View Hash#contain?.patch
diff --git i/hash.c w/hash.c
index 007508a..6f39e47 100644
--- i/hash.c
+++ w/hash.c
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash)
return ary;
}
+static int
+hash_contain_i(VALUE key, VALUE value, VALUE arg)
@olivierlacan
olivierlacan / merge_var_content_checker.rb
Created Jun 8, 2014
RSpec matcher for mandrill_mailer gem that allows you to check the main CONTENT merge var for a specific string using expect(mailer).to include_merge_var_content('my string')
View merge_var_content_checker.rb
# Public: Matcher for asserting specific merge vars content contains something.
#
# merge_var_key - Key of the merge var whose content will be checked
# expected_data - Data to look for in the specified merge var key.
#
# WelcomeMailer is an instance of MandrillMailler::TemplateMailer
#
# let(:user) { FactoryGirl.create(:user) }
# let(:mailer) { WelcomeMailer.welcome_registered(user) }
# it 'should have the correct data' do
View Hash#comprized?.diff
diff --git i/hash.c w/hash.c
index 007508a..6f39e47 100644
--- i/hash.c
+++ w/hash.c
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash)
return ary;
}
+static int
+hash_comprised_i(VALUE key, VALUE value, VALUE arg)
@olivierlacan
olivierlacan / gist:cafddd3fbed4593c3b25
Created Dec 27, 2014
Ruby 2.2.0 & Rails 4.2.0 app push fail
View gist:cafddd3fbed4593c3b25
-----> Fetching custom tar buildpack... done
-----> Ruby app detected
-----> Compiling Ruby/Rails
!
! Command: 'set -o pipefail; curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 20 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/ruby-2.2.0.tgz -s -o - | tar zxf -' failed unexpectedly:
!
! gzip: stdin: unexpected end of file
! tar: Child returned status 1
! tar: Exiting with failure status due to previous errors
!
@olivierlacan
olivierlacan / changelog_parser.rb
Last active Aug 29, 2015
Really naive CHANGELOG parser we used on Code School for a while to export public-facing release notes from a private-ish CHANGELOG.md file.
View changelog_parser.rb
require 'vandamme'
module PagesHelper
def changes
changes = {}
sections = changelog_file.each_with_index do |day, index|
change_sets = {}
day[1].scan(section_title_scanner) do |match|
View paris_design.md
@olivierlacan
olivierlacan / climate_control.rb
Last active Aug 29, 2015
Climate Control RSpec support helper
View climate_control.rb
# in spec/support/climate_control.rb
module ClimateControlHelper
def with_modified_env(options, &block)
ClimateControl.modify(options, &block)
end
end
RSpec.configure do |config|
config.include(ClimateControlHelper)