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
dgilperez / springrole
Created Feb 14, 2019
springrole verification
View springrole
2abeca13d96df706beeb3204e00dc56977b3c0158ae05bc65ac2a909d0183926cbb675cd933f97d0149f91a20c08556febeeae69433ef79272785857cd0f166d
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 config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@dgilperez
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: 'postgres.ocad.ca', user: 'canvas_user')
View gist:b4341063c9cd2e2f0a3bf453558b7ade
# $> gem install octokit
# $> irb
require 'octokit'
client = Octokit::Client.new(login: '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
View elixir.md

(my response to https://twitter.com/apotonick/status/717105889845624832)

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
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}"
end
}
$enable_tracing = true
@dgilperez
dgilperez / gource.sh
Last active Nov 11, 2016 — forked from qiaoxueshi/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
View gource.sh
# 1.install gource using HomeBrew
brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@dgilperez
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...
end
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
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.
end
You can’t perform that action at this time.