Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile
@stevenharman
stevenharman / 00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Last active March 11, 2024 04:11
Heroku Release Phase script for managing Rails DB migrations, and playing nice with Review Apps and postdeploy scripts

Heroku Release Phase + Review Apps + Rails

This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps. Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:

  1. Fail, loudly, if the DB does not yet exist.
  2. Load the DB schema if the current schema version (as determined by bin/rails db:version) is 0.
  3. Run DB migrations otherwise.

For a "normal" app that usually means it will run the DB migrations.

@dansteele
dansteele / create_review_app_subdomain.rake
Last active September 15, 2022 23:45
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
@ibraheem4
ibraheem4 / postgres-brew.md
Last active April 25, 2024 08:55 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active March 1, 2024 14:39
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
@rubyconvict
rubyconvict / bulk_reindexer.rb
Last active February 15, 2023 21:42 — forked from VvanGemert/bulk_reindexer.rb
Asynchronous bulk reindexing module for Searchkick with Sidekiq
# https://medium.com/rubyinside/asynchronous-elasticsearch-bulk-reindexing-with-rails-searchkick-and-sidekiq-26f2f9aa8513
# https://github.com/ankane/searchkick
# 2.3.2 [unreleased]
# - Added wait option to async reindex
# Searchkick.reindex(async: {wait: true})
# This code has been ported to searchkick.
require 'sidekiq/api'
# BulkReindexer
module BulkReindexer
@WaKeMaTTa
WaKeMaTTa / order-rails-controller-callbacks.md
Last active July 29, 2019 12:29
Order of Rails Controller Callbacks

Order of Rails Controller Callbacks

Rails 4.x

Started GET "/" for 127.0.0.1 at 2017-05-19 14:17:18 +0200
  Processing by WelcomeController#index as HTML
    prepend_around_action
    prepend_before_action
 before_action
@iloveitaly
iloveitaly / capybara_fill_stripe_elements.rb
Created March 4, 2017 21:21
Fill in a Stripe Elements (https://stripe.com/docs/elements) credit card field using capybara
def fill_stripe_elements(card)
using_wait_time(15) { within_frame('stripeField_card_element0') do
card.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
end }
# Cleans up branches like:
# if Shopify.rails_next?
# # Rails 5 login
# else
# # Rails 4 login
# end
module RuboCop
module Cop
module ShopifyRails
class RailsNextUnless < Cop
@wrburgess
wrburgess / example_job.rb
Last active April 6, 2020 20:17
ActiveJob on Rails 5 with RSpec
# app/jobs/example_job.rb
class ExampleJob < ActiveJob::Base
queue_as :default
rescue_from(ActiveRecord::RecordNotFound) do
retry_job wait: 1.minute, queue: :default
end
def perform(param_1, param_2)
@wbotelhos
wbotelhos / libreadline_6_not_found.sh
Created November 29, 2016 20:42
Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib