Skip to content

Instantly share code, notes, and snippets.

View rodrigopinto's full-sized avatar

Rodrigo Pinto rodrigopinto

  • Berlin, Germany
  • 12:54 (UTC +01:00)
View GitHub Profile
require "can_use"
# Example using default envinronment and feature? block
CanUse.configure do |config|
config.file = "config/features.yaml"
end
CanUse.feature?("show_puts") do
puts "It is diplaying"
end
tap "heroku/brew"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "homebrew/services"
tap "luckyframework/lucky"
tap "phrase/brewed"
tap "shopify/shopify"
tap "thoughtbot/formulae"
tap "universal-ctags/universal-ctags"
@rodrigopinto
rodrigopinto / how-to.md
Last active January 18, 2023 15:20
Runs rubocop against the diff before commit

For those like me that often forget to run rubocop against the diff code, I added a pre-commit git hook to do this.

  1. Goes to your repository folder $ cd yourrepo/.

  2. Add the pre-commit executable file to your .git/hooks folder.

  3. Be happy, you will never more be alerted by your CI about rubocop complaints.

@rodrigopinto
rodrigopinto / .laptop.local
Last active February 14, 2018 16:14
It's my .laptop.local extension for rodrigopinto/laptop installation.
#!/bin/sh
brew bundle --file=- <<EOF
# Caskroom recipes
cask "alfred"
cask "docker-toolbox"
cask "firefox"
cask "flux"
cask "grammarly"
cask "gimp"
pt-BR:
easy_auth:
sessions:
create:
notice: 'Você se autenticou.'
error: 'Não foi possível autenticar. Por favor verifique suas credenciais.'
delete:
notice: 'Você foi desconectado.'
password_reset:
create:
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
# Configuration file for Unicorn
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# See also http://unicorn.bogomips.org/examples/unicorn.conf.rb for
# a more verbose configuration using more features.
app_name = "appname"
root = "/home/deployer/apps/#{app_name}/current"

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@rodrigopinto
rodrigopinto / company.rb
Last active December 16, 2015 01:29
Model using paranoia with paperclip should preserve file when deleting the record.
class Company < ActiveRecord::Base
has_attached_file :logo, :preserve_files => true
acts_as_paranoid
#...
end
original = [2, 3, 5, 10].tap do |arr|
arr.map { |v| v*v }.tap {|x| puts "squares: #{x.inspect}"} # => squares: [4, 9, 25, 100]
end
puts "original: #{original.inspect}" # => original: [2, 3, 5, 10]