Skip to content

Instantly share code, notes, and snippets.

Build that!

David Gil dgilperez

Build that!
Block or report user

Report or block dgilperez

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dgilperez / springrole
Created Feb 14, 2019
springrole verification
View springrole
View gist:2286c7ff4d1a6f9531fac3f628ddb048

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by
  • pry -r ./config/environment.rb - load your rails into a pry session


dgilperez / check.rb
Created Aug 26, 2018 — forked from christopher-b/check.rb
Canvas MySQL -> Postgres Migration
View check.rb
#!/usr/bin/env ruby
# Do sanity check on imported data by comparing the number of rows in each table
require 'pg'
require 'mysql2'
tables = %w( { list the tables to compare here })
p = PG.connect(dbname:'canvas', host: '', user: 'canvas_user')
View gist:b4341063c9cd2e2f0a3bf453558b7ade
# $> gem install octokit
# $> irb
require 'octokit'
client = 'whoami', password: 'whatamidoinghere')
client.pull_requests('user/repo_name', state: 'all', per_page: 100).each {|pr| p [pr.title, pr.body, pr.user.login].join("\n")};nil
# more pages?
# client.pull_requests('user/repo_name', state: 'all', per_page: 100, page: 2).each {|pr| p [pr.title, pr.body, pr.user.login].join("\n")};nil

(my response to

I haven't yet came across readily available resources for large-scale application architecture for Elixir apps. I found Programming Phoenix to be a good start for that though. And there's ~30 years of knowledge in the Erlang land :)

For web apps, I found the abstractions that Elixir/Phoenix provides to be really helpful. Indeed, the list below is somewhat ORM focused.

In the small, Ecto.Schema, Ecto.Query, Ecto.Changeset, and Phoenix.View allow me to build highly composable and side-effect free modules. I can have many schemas, changesets and queries all interacting with the same underlying DB table(s) if I want to. Most of the side-effects (through Ecto.Repo for DBs) are usually in the Phoenix.Controller (or other Plugs).

dgilperez / gist:e41da50eec00fd00448f1336e9828c87
Created May 7, 2017 — forked from sebboh/gist:f1dfe4f096746c45f3e9ea06a09743a0
Installing a Gem on Heroku from a Private GitHub Repo
View gist:e41da50eec00fd00448f1336e9828c87

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub
View stackleveltoodeep_tracer.rb
$enable_tracing = false
$trace_out = open('trace.txt', 'w')
set_trace_func proc { |event, file, line, id, binding, classname|
if $enable_tracing && event == 'call'
$trace_out.puts "#{file}:#{line} #{classname}##{id}"
$enable_tracing = true
dgilperez /
Last active Nov 11, 2016 — forked from qiaoxueshi/
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
brew install gource
# 2.install avconv
git clone git://
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
dgilperez / example.rb
Created Oct 14, 2016 — forked from nthj/example.rb
Methods I like to monkey-patch onto the Object class in Ruby
View example.rb
# Say you want to look up the attrs of a Stripe Event for logging to your internal database.
attrs = begin
retriable(Stripe::APIConnectionError, Stripe::APIError, max: 25) do
# ... retrieve attrs from the Stripe event here...
rescue Stripe::APIConnectionError, Stripe::APIError
# We're inside an SQS queue block
throw :skip_delete # we'll just have to wait on this event, come back later
rescue Stripe::Error
notify $!
dgilperez / trello-import.rb
Last active Apr 18, 2017
Taiga to Trello - ruby script to import Taiga cards into Trello
View trello-import.rb
require 'trello'
# Trello.open_public_key_url # copy your public key
# Trello.open_authorization_url key: 'yourpublickey' # copy your member token
Trello.configure do |config|
config.developer_public_key = 'your_public_key' # The "key" from step 1
config.member_token = 'your_member_token' # The token from step 3.
You can’t perform that action at this time.