Skip to content

Instantly share code, notes, and snippets.

Working from home

Lucas Arruda LucasArruda

Working from home
View GitHub Profile
LucasArruda / add-index.sql
Created Jun 12, 2022 — forked from leandronsp/add-index.sql
Comparing B-Tree index vs CTE's
View add-index.sql
DROP INDEX IF EXISTS transfers_in, transfers_out;
CREATE INDEX transfers_in ON transfers (target_account_id);
CREATE INDEX transfers_out ON transfers (source_account_id);
LucasArruda / !README.MD
Created Apr 18, 2022 — forked from davideluque/!README.MD
Sign in with Apple in Ruby on Rails using apple_id gem.

Implementation of the Sign in with Apple service in Ruby on Rails. This implementation is convenient for Ruby on Rails APIs as it does not use views.

This implementation does:

  • Verify the user's identity token with apple servers to confirm that the token is not expired and ensure it has not been tampered with or replayed to the app.
  • Log in the user, register the user or connect the user's apple account to the user's existing account.


  • code: Apple's authorizationCode after sign in. Example: c49a75458b1e74b9f8e866f5a93b1689a.0.nrtuy. ...
LucasArruda / copyToClipboard.js
Created Nov 26, 2020
Copies a supplied text to the clipboard. Useful for react components that loop and can't depends on ids.
View copyToClipboard.js
// Copies 'text' to clipboard. Doesn't depends on id's, targets. Just text.
const copyToClipboard = (text) => {
const el = document.createElement('input');
el.value = text;;
el.setSelectionRange(0, 99999); /*For mobile devices*/
View rails_single_file.rb
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
gemfile(true) do
source ""
View running_app_in_production_locally.markdown
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

LucasArruda / redis.rb
Created Nov 24, 2019 — forked from joel/redis.rb
View redis.rb
# Mock Redis
class MockRedis
attr_accessor :store
def initialize
@store = {}
def flushall
@store = {}
LucasArruda /
Created Jan 16, 2019
Ruby on Rails console load error after brew update -> Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
# Ruby on Rails console load error after brew update
# Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
LucasArruda /
Last active Mar 27, 2018
RubyConfBR 2017 summary of some of the presentations

Bundler 2.0

  • Slowly being introduced as bundler starts to show it's age
  • Already working well and coming out of beta
  • Caching (github, gem, ext)
  • Multi-source (now safe to do)
  • No more platform issues (win vs linux vs unix)
  • We should prepare to migrate soon

LucasArruda / create_review_app_subdomain.rake
Created Jan 22, 2018 — forked from dansteele/create_review_app_subdomain.rake
Use a sub-subdomain on Heroku review apps with DNSimple. Run this task from your app.json in your postdeploy script.
View create_review_app_subdomain.rake
namespace :staging do
desc 'create subdomain DNS record for Heroku review app'
task :publish_dns do
require 'dnsimple'
require 'platform-api'
STAGING_DOMAIN = ''.freeze
heroku_app_name = ENV['HEROKU_APP_NAME']
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first
LucasArruda / application.rb
Created Nov 28, 2017 — forked from averyvery/application.rb
Inline CSS or JS in Rails
View application.rb
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _