Skip to content

Instantly share code, notes, and snippets.

View inouire's full-sized avatar
⛑️
Deploying every day

Edouard inouire

⛑️
Deploying every day
View GitHub Profile
@inouire
inouire / git_go_back_in_time.md
Last active April 21, 2023 08:13
Go back in time with git

Pick a date, pick a branch, here you go

git checkout `git rev-list -n 1 --first-parent --before="2019-07-27 13:37" master`

List all tables referencing a target table using a foreign key

SELECT tc.table_schema, tc.constraint_name, tc.table_name, kcu.column_name, ccu.table_name
AS foreign_table_name, ccu.column_name AS foreign_column_name
FROM information_schema.table_constraints tc
JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage ccu ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY'
AND ccu.table_name='name_of_your_target_table_here'

Ruby heap size rules of thumb

GC.stat[:heap_live_slots]
  • <1 million = don't sweat it
  • 1mil->3mil = Pretty average
  • 3mil->5mil = Typical of Big Chonker Monoliths
  • 5mil->10mil = Something probably wrong, fix to reduce RSS usage + speed up your GCs
@inouire
inouire / i18n.rb
Last active May 20, 2019 10:44
Simple i18n setup in my Hanami 1.3 app
# config/initializers/i18n.rb
require 'i18n'
# Configure it as you want
I18n.load_path = Dir["config/locales/**.yml"]
I18n.enforce_available_locales = true
I18n.default_locale = "en"
I18n.backend.load_translations
@inouire
inouire / gist:ba850551fd352238579d
Created December 9, 2014 08:57
CSV dataset provider, draft
<?php
namespace MetarDecoder\Service;
use MetarDecoder\Exception\DatasetLoadingException;
class DatasetProvider
{
private $base_dir;