Skip to content

Instantly share code, notes, and snippets.

Jerome Dalbert jeromedalbert

View GitHub Profile
jeromedalbert / .gitattributes
Last active Mar 3, 2019
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (now works with Rails 5 and recent versions of Git). The following files should be in your home ~ directory. Inspired by
View .gitattributes
db/schema.rb merge=railsschema
View new-rails-app
set -e
main() {
View spring.rb
class Spring::Watcher::Listen
def base_directories
%w(app config lib spec)
.map { |path|, path)) }
jeromedalbert / .zshrc
Last active Jul 19, 2018
Remove branches just like git rebase --interactive
View .zshrc
gbDi() {
git branch --sort=-committerdate | remove-colors | egrep -v "master|\*" | cut -c3- > /tmp/branches && \
cp /tmp/branches /tmp/branches-to-keep && \
vim /tmp/branches-to-keep && \
comm -23 <(sort /tmp/branches) <(sort /tmp/branches-to-keep) | xargs 2> /dev/null git branch -D
remove-colors() {
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
jeromedalbert / mixpanel_async_tracker.rb
Last active Jan 30, 2018
Make the Mixpanel gem work with Rails Active Job. Should work with any background job backend.
View mixpanel_async_tracker.rb
# Make Mixpanel work with Rails Active Job.
# Should work with any background job backend.
class MixpanelAsyncTracker < Mixpanel::Tracker
def initialize
super(ENV['MIXPANEL_TOKEN']) do |*message|
jeromedalbert / gist:7476f445b7538b488c6ec34b5c4f3da4
Created May 28, 2016
Installing the Docker Toolbox on OS X with brew
View gist:7476f445b7538b488c6ec34b5c4f3da4
brew cask install dockertoolbox
docker-machine create --driver virtualbox default
docker-machine ls
eval $(docker-machine env default)
Put the exports in this eval in your .zshrc or .bashrc if you use bash
jeromedalbert / .zshrc
Last active Apr 27, 2016
Ctrl-z In n Out
View .zshrc
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
zle accept-line
zle push-input
zle clear-screen
zle -N fancy-ctrl-z
View .eslintrc.js
module.exports = {
"env": {
"browser": true,
"es6": true,
"jquery": true
"extends": "eslint:recommended",
"rules": {
"indent": [
jeromedalbert /
Last active Feb 8, 2016
Configure OSX Yosemite with sensible defaults
# Disable the "Are you sure you want to open this application?" dialog
defaults write LSQuarantine -bool false
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
# Decrease the initial time before a keyboard repeat
jeromedalbert / gist:5382169
Last active Apr 7, 2019
Different ways to return in Ruby
View gist:5382169
# Return statements are useless in snippets below, but they can help readability (highlight "end cases" of recursion)
# Order of preference : 3, 2/1, 4
# 1) Extra returns make it more obvious what is happening. Maybe a bit verbose
def decompose(n)
if n == 0
return []
elsif n == 1
return [1]
You can’t perform that action at this time.