Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View LucasArruda's full-sized avatar
🎯
Focusing

Lucas Arruda LucasArruda

🎯
Focusing
View GitHub Profile
@LucasArruda
LucasArruda / libreadline_7_not_found.sh
Created January 16, 2019 19:22
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
LucasArruda / ruby_conf_br_2017.md
Last active March 27, 2018 17:44
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

https://speakerdeck.com/segiddins/bundling-bundler-2-dot-0

@LucasArruda
LucasArruda / create_review_app_subdomain.rake
Created January 22, 2018 00:11 — 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.
namespace :staging do
desc 'create subdomain DNS record for Heroku review app'
task :publish_dns do
require 'dnsimple'
require 'platform-api'
STAGING_DOMAIN = 'mystagingdomain.com'.freeze
DNSIMPLE_ACCOUNT_ID = .freeze
heroku_app_name = ENV['HEROKU_APP_NAME']
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first
@LucasArruda
LucasArruda / application.rb
Created November 28, 2017 15:36 — forked from averyvery/application.rb
Inline CSS or JS in Rails
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@LucasArruda
LucasArruda / gist:b0461143e64756e35b3c778116c67e66
Created November 6, 2017 16:21 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@LucasArruda
LucasArruda / install icu
Last active September 7, 2017 20:17 — forked from giniedp/install icu
install icu on machttp://site.icu-project.org/download/58
curl -O https://ufpr.dl.sourceforge.net/project/icu/ICU4C/58.2/icu4c-58_2-src.tgz
tar xzvf icu4c-58_2-src.tgz
cd icu/source
chmod +x runConfigureICU configure install-sh
./runConfigureICU MacOSX
make
sudo make install
@LucasArruda
LucasArruda / friendly_urls.markdown
Created August 7, 2017 22:41 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@LucasArruda
LucasArruda / fix_brew.sh
Created October 6, 2015 15:17
Fixing brew
#!/bin/sh
cd $(brew --prefix) && git fetch && git reset --hard origin/master
brew update
@LucasArruda
LucasArruda / add-css-vanilla.js
Last active August 29, 2015 14:25
Add CSS or JS on the fly
function loadCss(url) {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
document.getElementsByTagName("head")[0].appendChild(link);
}
@LucasArruda
LucasArruda / uri.js
Last active August 29, 2015 14:16 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"