Skip to content

Instantly share code, notes, and snippets.

View mriddle's full-sized avatar

Matthew Riddle mriddle

View GitHub Profile
@mriddle
mriddle / repository_archiving_report.rb
Last active October 12, 2022 20:05
List of all unarchived repositories within organization using the GitHub GraphQL API. Requires a PAT (Personal Access Token) that has the necessary privileges
#!/usr/bin/env ruby
# List of all unarchived repositories within organization
# - group by year last updated
# - exclude those updated in the last 12 months
#
# Requires a GitHub Personal Access Token with the `repo` scope
# and it will need be authorized with with SSO where applicable.
#
# Pass token in via the GITHUB_ACCESS_TOKEN environment variable

Minecraft on Apple Silicon

In this gist, you can find the steps to run Minecraft 1.16.4 natively on Apple Silicon (AS), without needing Rosetta 2 translation of the dependencies (mainly LWJGL and related libraries).

While it's possible to use a launcher like MultiMC to have a prettier way to run the game on AS, it requires installing even more dependencies (like QT) which take time and are difficult to distribute. Therefore, I've put together a command line-based launcher tool using a couple shell & Python scripts.

To get up and running quickly, follow the steps below. Otherwise, for more detail, watch my YouTube video.

Download my package

@mriddle
mriddle / Rails dependency finder
Last active August 28, 2022 17:50
Find dependencies that need to be bumped for a Rails upgrade: check_rails_dependancies.rb -v 6.1.0
# Example usage
$ ./check_rails_dependencies.rb --version 6.1.0
------------------------------
93 dependencies using Rails
------------------------------
action_mailer-logged_smtp_delivery v2.1.0
✗ actionmailer
actionpack-action_caching v1.2.0
✓ actionpack
✓ activerecord
@mriddle
mriddle / query_tracer.rb
Created March 24, 2020 10:21
Log slow queries in Rails
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 15
THRESHOLD = 100 # In ms
def sql(event)
return unless event.duration > THRESHOLD
callers = Rails.
backtrace_cleaner.
@mriddle
mriddle / config
Created April 8, 2019 05:47
"~/.bundle/config"
BUNDLE_PATH: "./vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_JOBS: "8"
BUNDLE_GEM__TEST: "rspec"
BUNDLE_GEM__MIT: "true"
BUNDLE_GEM__COC: "false"
module Helpers
class Range
def self.merge_overlapping_ranges(ranges)
ranges.sort_by(&:begin).inject([]) do |collection, range|
if !collection.empty? && overlap?(collection.last, range)
collection[0...-1] + [merge(collection.last, range)]
else
collection + [range]
end
end
@mriddle
mriddle / snoopy.rb
Created December 5, 2014 12:57
Snoopy the helpful WTF? tool
class Snoopy < BasicObject
def initialize(obj)
@obj = obj
end
def method_missing(method, *attributes, &block)
@obj.send(method, *attributes, &block).tap do |val|
@obj.send(:puts, "#{method} #{attributes} -> #{val}")
@obj.send(:puts, "\t#{::Kernel.caller.to_a[0..2].join("\n\t")}\n\n")
end
@mriddle
mriddle / example_output
Last active August 29, 2015 14:07
Print out an up-to-date list of the Ruby exception hierarchy
BasicObject
Exception
MonitorMixin::ConditionVariable::Timeout
NoMemoryError
ScriptError
LoadError
Gem::LoadError
NotImplementedError
SyntaxError
SecurityError
@mriddle
mriddle / poi_counter.rb
Last active August 29, 2015 14:07
xslt transformation and poi counter
#/usr/bin/env ruby
require 'rexml/document'
total_poi_count = 0
Dir.glob("output/*.xml").each do |file|
# extract event information
doc = REXML::Document.new(File.read(file))
poi_count = doc.elements.to_a('//vendor-pois/entry').length
puts "Count: #{poi_count} for #{file}"
@mriddle
mriddle / up_postgres.sh
Last active August 29, 2015 13:56
Upgrades postgres 9.1 to 9.3 with PostGIS 2.1 on Ubuntu (precise)
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.3 postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 libpq-dev postgresql-9.3-postgis-2.1
cd /tmp