Skip to content

Instantly share code, notes, and snippets.


Ian Vaughan IanVaughan

View GitHub Profile
IanVaughan / gist:b604d5b26a0b8fa36c4fab9188cdb6db
Created Sep 18, 2020
failed to build gem native extension. xcode
View gist:b604d5b26a0b8fa36c4fab9188cdb6db
Fetching nio4r 2.5.4
Installing nio4r 2.5.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/ianvaughan/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/nio4r-2.5.4/ext/nio4r
/Users/ianvaughan/.asdf/installs/ruby/2.7.1/bin/ruby -I /Users/ianvaughan/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200918-40223-cj3k1e.rb extconf.rb
checking for unistd.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
IanVaughan / hash-to-json.rb
Created Sep 15, 2020
Convert a log of hashes into json files in ruby
View hash-to-json.rb
file ='log')
file.each_line do |line|
hash = eval line
File.write("data-#{i}.json", hash.to_json)
puts i
IanVaughan /
Created Aug 27, 2020
Steps to Upgrade a Heroku DB in a script
#!/usr/bin/env bash
APP=name-production # name-staging
heroku addons:create heroku-postgresql:standard-2 --follow DATABASE_URL --app $APP # DONE
heroku addons:wait # DONE
for (( ; ; )); do; heroku pg:info --app $APP | grep Behind; sleep 1; done # DONE
IanVaughan / gist:9ac9a30597719b3e86d6b252e0db9c92
Created Aug 27, 2020
Intresting differences between rails routing form_for helpers
View gist:9ac9a30597719b3e86d6b252e0db9c92
# [:admin, @application] => admin_onboarding_url
# [:admin, @collections_facility] => admin_collections_facility_url
# [:admin, @application, @collections_facility] => admin_onboarding_collections_facility_url
# [:admin, :application, @collections_facility] => No route matches {:action=>"show", :application_id=>#<Collections::Facility id: 409, user_id: 1303, amount: 0.1e5, revenue_share: 0.25e1, fee: 0.31e1, created_at: "2020-01-24 10:45:50", updated_at: "2020-01-24 10:45:50", application_id: 886>, :controller=>"admin/collections/facilities"}, missing required keys: [:id]
# [:admin, :application, @application] => admin_application_onboarding_url
# format.html { redirect_to [:admin, :application, @application], notice: 'Facility was successfully created.' }
# redirect_to [:admin, :application, @collections_facility]
# => "<html><body>You are being <a href=\"\">redirected</a>.</body></html>"
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>"
You can’t perform that action at this time.