Skip to content

Instantly share code, notes, and snippets.

View ezza's full-sized avatar

Erin Francis ezza

  • Chargefox
  • Melbourne AU
View GitHub Profile
@ezza
ezza / set-screenshot-location.sh
Created February 17, 2017 00:41
Save screenshots in a subfolder of documents, not the desktop
mkdir ~/Documents/Screenshots
defaults write com.apple.screencapture location ~/Documents/Screenshots/
killall SystemUIServer
@ezza
ezza / split-factories.rb
Created September 25, 2024 01:16
Split a factories.rb file into subfiles by class
require "active_support"
require 'fileutils'
def calculate_file_to_write_to(line)
parts = line.strip.split ' '
if line.include? 'class:'
fname = parts[-2].gsub(',', '')
fname.gsub! '/'
fname = ActiveSupport::Inflector.underscore fname
@ezza
ezza / count-versions.rb
Last active October 7, 2024 22:56
Count how many times each key has changed in your jsonb papertrail storage
# If you use the default table name
PaperTrail::Version.connection.execute(<<-SQL
select k as key, count(*)
from versions v cross join lateral
jsonb_object_keys(v.object_changes) k
group by k order by count(*) desc;
SQL
).to_a
# If your table name is papertrail_versions