Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Pau Pérez Fabregat sauloperez

I may be slow to respond.
View GitHub Profile
sauloperez / bundle_update_output.log
Created Mar 12, 2019
Bundle update output for Spree 2.1
View bundle_update_output.log
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
rails (~> 4.0.0) was resolved to 4.0.0, which depends on
actionpack (= 4.0.0)
simple_form was resolved to 2.0.2, which depends on
actionpack (~> 3.0)
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
# At the bottom of add /etc/postgresql/9.5/main/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
sudo systemctl restart postgresql
sudo su postgres
CREATE extension pg_stat_statements;
sauloperez / gist:c789684fbcdcabbccfca000e27b42293
Created Dec 27, 2018
Silence deprecation warnings in Rails
View gist:c789684fbcdcabbccfca000e27b42293
ActiveSupport::Deprecation.silenced = true
sauloperez / dalyed_job_checks.rb
Created Oct 25, 2017
Snippets to check Delayed Job data
View dalyed_job_checks.rb
# Failed
Delayed::Job.where('failed_at IS NOT NULL')
# Active
Delayed::Job.where('failed_at IS NULL AND locked_by IS NOT NULL')
# Queued
Delayed::Job.where('failed_at IS NULL AND locked_by IS NULL')
# Destroy
sauloperez / beat_the_refactoring_blerch
Created Apr 20, 2017
Beat the refactoring blerch
View beat_the_refactoring_blerch
Have you seen Matthew Inman's (The Oatmeal) comic about why he runs? It's
a classic. In it he talks about his inspiration for taking up long-distance
running. He imagines his tendency to slack off and sit on the couch as a little
creature he calls "The Blerch". It follows him around, tempting him to stop
moving and scarf down junk food.
I run too, though nothing close to the distances Inman runs. In my experience,
refactoring as a skill has a lot in common with running or any other athletic
sport. You can exercise your refactoring muscles, by deliberately working
through the steps with discipline, like we talked about in the last email. As
sauloperez / toc.rb
Created Oct 21, 2016
Markdown TOC generator
View toc.rb
#!/usr/bin/env ruby
FILENAME = ARGV[0], 'r') do |f|
f.each_line do |line|
forbidden_words = ['Table of contents', 'define', 'pragma']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }
title = line.gsub("#", "").strip
# Some required stuff
sudo apt-get install -y git build-essential curl
# Install RVM and Ruby 2.1.2
gpg --keyserver hkp:// --recv-keys D39DC0E3
curl -sSL | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.1.2
rvm use --default 2.1.2
sauloperez / gist:771cfba97cf6e2397e95
Created May 2, 2014
IEEE locally-assigned MAC addresses
View gist:771cfba97cf6e2397e95
# Generates IEEE locally-assigned MAC addresses
# @return [String] following the pattern [0-9A-Fa-f][26AEae][0-9A-Fa-f]{10}
def mac
mac = ('%0.2X' % rand(256))[0, 1] + %w(2 6 A E).sample
mac << (1..5).map { "%0.2X" % rand(256) }.join
View redch.conf
description "start passenger stand-alone"
# When to start the service
start on filesystem or runlevel [2345]
# When to stop the service
stop on runlevel [!2345]
# Automatically restart process if crashed
sauloperez / gist:8971804
Created Feb 13, 2014
Get Rails callback names
View gist:8971804 { |cb| cb.kind.eql?(:before) }.collect(&:filter).each { |c| puts "#{c}\n" }
You can’t perform that action at this time.