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 / 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
@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 / 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 / gist:bedaae613be47fe4a6835a08a647668c
Created December 22, 2016 01:31 — forked from jacobh/gist:9884192
LIFX build status light
require 'LIFX'
require 'net/http'
require 'json'
# LIFX setup
green = LIFX::Color.green saturation: 1
red = LIFX::Color.red saturation: 1
white = LIFX::Color.white
off_color = LIFX::Color.white brightness: 0
@ezza
ezza / .profile
Last active January 18, 2016 03:44
Colourify SSH terminal sessions
# Add this to ~/.profile
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi # if you have trouble with this, change
# "Default" to the name of your default theme
echo -e "\033]50;SetProfile=$NAME\a"
}
function colorssh() {
@ezza
ezza / gist:9590fc468dd3ecac5141
Last active August 29, 2015 14:19
AWS IO benchmarks
EBS optimized r3.xlarge instance with 3.3TB EBS volume attached.
###### Write benchmarks #########
sudo dd bs=1M count=2048 if=/dev/zero of=foo oflag=dsync
## 16GB EBS System Partition
2147483648 bytes (2.1 GB) copied, 51.1244 s, 42.0 MB/s
## 75GB Instance Store
2147483648 bytes (2.1 GB) copied, 24.5199 s, 87.6 MB/s
@ezza
ezza / word-loop.md
Last active August 29, 2015 14:05
Codeday Friday: Wordloop

Given a single word as input try to find a repeated letter inside of it such that you can loop the text around and reuse that letter. For example:

$ ruby word_loop.rb Mississippi
 i

 p
 p

Mis

 ss

 si
@ezza
ezza / mysql-grant
Last active January 3, 2016 09:59
Grant access to the flippa DBs if your VM init script fails.
mysql -u root -e "GRANT ALL ON flippa.* TO flippa@localhost IDENTIFIED BY 'flippa';"
mysql -u root -e "GRANT ALL ON commerce.* TO flippa@localhost IDENTIFIED BY 'flippa';"
mysql -u root -e "GRANT ALL ON commerce.* TO commerce@localhost IDENTIFIED BY 'commerce';"
mysql -u root -e "CREATE DATABASE flippatest;"
mysql -u root -e "GRANT ALL ON flippatest.* TO flippa@localhost IDENTIFIED BY 'flippa';"
@ezza
ezza / git-stash-grep
Last active December 28, 2015 02:09 — forked from hartym/git-stash-grep
Add to bashrc so you can stashgrep term
# added to ~/.bashrc
stashgrep() {
for i in `git stash list --format="%gd"`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
}
# usage:
# stashgrep zip
# returns
// ==UserScript==
// @name G+ Hangouts Autojoin
// @description Automatically click the join button when loading a hangout
// @include https://plus.google.com/hangouts/_/*
// @match https://plus.google.com/hangouts/_/*
// @version 0.1.0
// ==/UserScript==
(function(){