Skip to content

Instantly share code, notes, and snippets.

View mthadley's full-sized avatar
💾
Loading...

Michael Hadley mthadley

💾
Loading...
View GitHub Profile
@mthadley
mthadley / keymap.lua
Created February 26, 2025 00:24
Set a Neovim key mapping to run `rush build` in a Rush monorepo.
-- Run rush build for the package containing the current buffer
keymap.set("n", "<leader>b", function()
local rush_root = vim.fs.find({ "rush.json" }, {
path = vim.api.nvim_buf_get_name(0),
upward = true,
})[1]
if not rush_root then
vim.print("No rush.json found. Ostensibly not a Rush project.")
return
end
@mthadley
mthadley / code.js
Created January 28, 2025 21:21
GitHub OAuth button disablement
// By default the oauth button remains disabled until the visitor focusses the
// window. This event handler enables the button once the window has been focussed.
async function updateButtonOnPageFocused(button: Element) {
await pageFocused(document)
await new Promise(resolve => setTimeout(resolve, 1000))
if (button instanceof HTMLButtonElement) button.disabled = false
}
#!/usr/bin/env ruby
require "io/console"
class Keyboard
def initialize(queue) = @queue = queue
def monitor
return if @thread
@mthadley
mthadley / redis_keys.rb
Last active June 16, 2022 20:06
`dump` or `restore` Redis keys
#!/usr/bin/env ruby
require "bundler/inline"
require "json"
require "base64"
gemfile do
source "https://rubygems.org"
gem "redis", "~> 4.6"
@mthadley
mthadley / uptime.rb
Created April 12, 2022 23:21
Uptime Checker for HTTPS Services
#!/usr/bin/env ruby
require "net/http"
require "openssl"
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "colorize", "~> 0.8"
@mthadley
mthadley / custom-install.sh
Last active November 29, 2020 19:56
OpenCL Install Script for AMDGPU PRO driver on Ubuntu 20.04
#!/usr/bin/env bash
#
# Author: Michael Hadley
# Tested on:
# OS: Ubuntu 20.04
# Kernel: 5.8.0-29-generic
# Pro Driver: 20.45
#
# Custom install script for the OpenCL components of the "AMDGPU-PRO" driver. I was unable to use the
# script that came with the driver asit always atempted to install componetns that depend on the amdgpu-dkms
#!/usr/bin/env nix-shell
#! nix-shell -i runhaskell -p ghcid ghc
import Control.Applicative
import Data.Char
import Data.List
import Data.Maybe
import Text.Read
main :: IO ()
@mthadley
mthadley / randomize_server.rb
Created March 29, 2020 01:24
The Randomizer™️
#! /usr/bin/env nix-shell
#! nix-shell -i ruby -p ruby bundler --pure
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem 'sinatra'
gem 'thin'
@mthadley
mthadley / server.rb
Created March 29, 2020 00:31
Portable Nix/Ruby Web Server
#! /usr/bin/env nix-shell
#! nix-shell -i ruby -p ruby bundler --pure
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem 'sinatra'
gem 'thin'
@mthadley
mthadley / start_pihole.sh
Created January 10, 2020 19:27
Pihole startup script
#!/bin/bash
# Remove existing container
docker stop pihole
docker rm pihole
docker run -d \
--name pihole \
-e TZ="America/Los_Angeles" \
-e ServerIP="192.168.1.201" \