Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Jerome Dalbert jeromedalbert

👨‍💻
View GitHub Profile
@jeromedalbert
jeromedalbert / README.md
Created May 19, 2022 — forked from hopsoft/README.md
Smart Heroku Review Apps managed by GitHub Actions
View README.md

Smart Heroku Review Apps managed by GitHub Actions

This gist aims to provide a simple solution for managing Heroku Review Apps with GitHub Actions due to the security incident that continues to disrupt Heroku's GitHub integration. Watch the demo to learn more.

Demo Video

.github
├── workflows
│   ├── heroku_review_app_create.yml
View gist:cb9e6fa1353ab8bb1aa874b0120f39ef
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
View setup.sh
#!/bin/sh
# Set up Rails app. Run this script immediately after cloning the codebase.
# Exit if any subcommand fails
set -e
# Copy over configs
if ! [ -f .env ]; then
cp .sample.env .env
View tmp_settings.rb
module TmpSettings
module_function
def get(user:, setting:)
return nil if !user
$redis.get("tmp_settings:#{setting}:#{user.id}")
end
def set(user:, setting:, value:)
@jeromedalbert
jeromedalbert / Gemfile
Created Jan 4, 2021 — forked from dhh/Gemfile
HEY's Gemfile
View Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@jeromedalbert
jeromedalbert / .rubocop.yml
Created Nov 3, 2020
Custom Rubocop rule to prevent unless with multiple conditions
View .rubocop.yml
require:
- ./.rubocop_custom_cops.rb
AllCops:
# ...
@jeromedalbert
jeromedalbert / .gitattributes
Last active Sep 24, 2021
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (now works with Rails 5 and recent versions of Git). The following files should be in your home ~ directory. Inspired by https://tbaggery.com/2010/10/24/reduce-your-rails-schema-conflicts.html
View .gitattributes
db/schema.rb merge=railsschema
View new-rails-app
#!/bin/bash
set -e
PROJECT_NAME=$1
main() {
display_logo
init_project
choose_branch
View spring.rb
class Spring::Watcher::Listen
def base_directories
%w(app config lib spec)
.map { |path| Pathname.new(File.join(root, path)) }
end
end
%w(
.ruby-version
.rbenv-vars
@jeromedalbert
jeromedalbert / .zshrc
Last active Jul 19, 2018
Remove branches just like git rebase --interactive
View .zshrc
gbDi() {
git branch --sort=-committerdate | remove-colors | egrep -v "master|\*" | cut -c3- > /tmp/branches && \
cp /tmp/branches /tmp/branches-to-keep && \
vim /tmp/branches-to-keep && \
comm -23 <(sort /tmp/branches) <(sort /tmp/branches-to-keep) | xargs 2> /dev/null git branch -D
}
remove-colors() {
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}