Skip to content

Instantly share code, notes, and snippets.


Ian Vaughan IanVaughan

View GitHub Profile
IanVaughan / team_stats.rb
Created Aug 27, 2020
Find GitHub team PR counts
View team_stats.rb
# frozen_string_literal: true
require 'awesome_print'
require 'httparty'
class TeamPrStatistics
attr_accessor :stats
IanVaughan / unused_routes.rb
Created Aug 27, 2020
Find unused rails routes
View unused_routes.rb
# frozen_string_literal: true
unused_routes = {}
# Iterating over all non-empty routes from RouteSet do |route|
name = route[:controller].camelcase
next if name.start_with?('Rails')
IanVaughan / gist:806cd9cb6be5995b8ca9ef0be1856e1a
Created Aug 27, 2020
Mounting a raid drive on my Netgear readynas
View gist:806cd9cb6be5995b8ca9ef0be1856e1a
fsck /dev/sdb1
parted /dev/sda 'print'
lsblk -f
mount /dev/sba1 ~/mountpoint
mdadm --assemble --run /dev/md0 /dev/sdb1
mdadm --assemble --run /dev/md3 /dev/sdb3
mount /dev/md3 ~/old-disk/
IanVaughan / db rows
Created Aug 19, 2020
get db row counts
View db rows
tables = [ "users" ]
tables.each do |table|
count = ActiveRecord::Base.connection.execute("SELECT count(*) from #{table};")
puts "#{table}, #{count.entries.first["count"]}"
IanVaughan / git-push-all
Created Aug 6, 2020
Push each commit on the branch on its own so CI builds each one by one
View git-push-all
branch=$(git branch --show-current)
for sha1 in $(git rev-list --reverse ...master) ; do
git push origin $sha1:$branch --force
View gist:8e1a42b06237bfdeffe865c0701aeb46
"blocks": [
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<|This message *is* a link>"
View gist:e08c552474b46b829cf1fc72702458b8
gcloud config set project ${PROJECT_ID}
gcloud sql instances create ex-kills-db-us-west1 --region=us-west1 --database-version=POSTGRES_9_6 --tier=db-f1-micro
gcloud sql instances describe ex-kills-db-us-west1 #=> connectionName: ex-kills:us-west1:ex-kills-db-us-west1
gcloud sql users set-password postgres --instance=ex-kills-db-us-west1 --prompt-for-password #=> 123456
gcloud container clusters create ex-kills-cluster-us-west1 --num-nodes=1 --zone=us-west1 --scopes=gke-default,sql-admin
gcloud container clusters get-credentials --zone=us-west1 ex-kills-cluster-us-west1
gcloud config set container/cluster ex-kills-cluster-us-west1
mkdir -p /tmp/cloudsql
May 13 08:00:33.022	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:114:in `get'
May 13 08:00:33.022	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:107:in `request'
May 13 08:00:33.022	pid=4 tid=baglec WARN: /app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/client.rb:119:in `request'
May 13 08:00:33.021	pid=4 tid=baglec WARN: OAuth2::Error: internal_server_error: Sorry, we are experiencing technical difficulties. Please try again later.
May 12 20:00:59.103	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:114:in `get'
May 12 20:00:59.103	/app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/access_token.rb:107:in `request'
May 12 20:00:59.103	pid=4 tid=40uw WARN: /app/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.2/lib/oauth2/client.rb:119:in `request'
View git-rename
# Put somewhere in your $PATH, and chmod +x git-rename
# On a branch with files already moved and changed locally but not in git.
# Usage:
# git rename existing-checked-in-filename new-and-changed-filename
#!/usr/bin/env bash
mv $TO ${TO}-1
IanVaughan / cred-diff
Created Apr 8, 2020
See diffs between rails credentials
View cred-diff
#!/usr/bin/env bash
# usage: On your branch or commit 'cred-diff production'
git checkout production --quiet
rails credentials:show --environment $1 > /tmp/prod
git checkout - --quiet
rails credentials:show --environment $1 > /tmp/yours
diff /tmp/prod /tmp/yours
rm /tmp/prod /tmp/yours