Skip to content

Instantly share code, notes, and snippets.

class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
def render_not_found
respond_to do |format|
format.html { render action: "errors/not_found.html.erb", status: 404 }
end
end
end
@duduribeiro
duduribeiro / introrx.md
Created December 19, 2015 18:09 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@duduribeiro
duduribeiro / massive_ag.txt
Created February 1, 2016 20:47
Massive update with ag (the silver searcher)
ag -l SEARCH | xargs perl -pi -e "s/SEARCH/REPLACE/g"
@duduribeiro
duduribeiro / woodo
Created February 2, 2016 03:51 — forked from 1995eaton/woodo
sudo woodo
#!/bin/sh
if [ $EUID -ne 0 ]; then
echo "It's a weird tree."
else
cat << "EOF"
@@@ @@@
@///@ /@@ @; @
@/ //@ / ;@ @;; @
@// ///@ @ ;;@ @;;;;;@
@duduribeiro
duduribeiro / gist:44fcabe8458ddcba5136
Created February 3, 2016 15:41
openssl/ssl.h file not found
-- --with-cppflags=-I/usr/local/opt/openssl/include
@duduribeiro
duduribeiro / delete_merged_branchs.sh
Created February 24, 2016 14:13
Delete merged branchs
git branch --merged | grep -v "\*" | grep -v master | grep -v staging | xargs -n 1 git branch -d
convert img20160112_13174979.pdf img20160112_13175002.pdf -quality 100 essay.pdf # +append will split and merge on the same page
@duduribeiro
duduribeiro / remove_old_containers.sh
Created April 28, 2016 02:26
remove old docker's containers
docker rm $(docker ps -aq)
@duduribeiro
duduribeiro / featre_toggle.rb
Created May 31, 2016 23:42
simple feature toggle in ruby
module Rollout
def self.features
@features ||= YAML.load_file(Rails.root.join("config", "rollout.yml"))[Rails.env]
end
def self.features=(value)
@features = value
end
def self.active?(key)
@duduribeiro
duduribeiro / retryable.rb
Created June 1, 2016 16:03
Retry on around filter
def retryable(options = {})
opts = { :tries => 1, :on => Exception }.merge(options)
retry_exception, retries = opts[:on], opts[:tries]
begin
return yield
rescue retry_exception
if (retries -= 1) > 0
sleep 2