Skip to content

Instantly share code, notes, and snippets.

View olivierlacan's full-sized avatar

Olivier Lacan olivierlacan

View GitHub Profile
@olivierlacan
olivierlacan / 1_nickel.rb
Last active August 29, 2015 13:57
Trying to figure out why I'm having to manually require a class that is within the same namespace inside of Rails.
# 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
@olivierlacan
olivierlacan / keybase_proof.md
Created April 17, 2014 10:02
Keybase.io Proof

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 August 29, 2015 14:00 — 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/
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 June 8, 2014 14:48
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')
# 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
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 December 27, 2014 19:30
Ruby 2.2.0 & Rails 4.2.0 app push fail
-----> 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 August 29, 2015 14:14
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.
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|
@olivierlacan
olivierlacan / paris_design.md
Last active August 29, 2015 14:14
Paris Design
@olivierlacan
olivierlacan / css.rb
Created August 29, 2015 17:58
Decoupling CSS IDs from RSpec/Capybara feature specs with centralized YAML list. We use this for Code School feature specs.
# Defines a method returning the selector for a CSS selector
# used within the test suite to scope a feature spec.
#
# Developers: always use these instead of hard-coding CSS selectors
# when scoping or selecting crucial elements on a page.
# Designers: always check this module before/after modifying existing
# classes or IDs that may cause test failures
#
# Example usage:
# - page.should have_selector(CSS.some_method)
@olivierlacan
olivierlacan / github_conflict_resolution.md
Created August 29, 2015 19:03
I dream of easier merge conflict resolution on GitHub Pull Requests

Howdy,

It's currently a bit of a hassle (unless I'm doing it wrong) to fix a PR that used to be green but is now unmergeable due to an simple little merge conflict with master.

It would be quite fantabulous if I could access the swanky invisible PR branches from the web interface in order to quickly fix the merge conflict and merge/close the PR without having to:

  • ask & wait for the submitter to fix a conflict they might not understand better than I do (since master likely caused it if the branch is green)
  • tediously add the submitter's repo as a remote and pull their branch, merge master in it to fix the conflict and either submit a PR to their fork or merge it into master directly (which sadly by-passes the existing PR)
  • do the local PR checkout trick (but I'm lazy, don't make me do it!)

A dream solution that would make GitHub even more addictive would be an interactive conflict resolutio