Skip to content

Instantly share code, notes, and snippets.

View mmertsock's full-sized avatar
💭
⛰️ 🐐

Mike Mertsock mmertsock

💭
⛰️ 🐐
View GitHub Profile
@mmertsock
mmertsock / stroop_rng.swift
Created August 7, 2023 17:44
Stroop RNG test
import Foundation
func tally(prob: Double, precision: UInt32, maxDiff: Double, repetitions: Int) {
var trues = 0
let threshold = UInt32(prob * Double(precision))
print("tally(prob: \(prob), precision: \(precision), repetitions: \(repetitions)):")
for _ in 1...repetitions {
let isTrue = arc4random_uniform(precision) < threshold
if isTrue {
trues += 1
@mmertsock
mmertsock / get-release-info.rb
Last active November 17, 2021 22:16
Get pull request info between commits
#!/usr/bin/ruby
require 'net/http'
require 'uri'
require 'json'
require 'base64'
$compare_from = ARGV[0]
$compare_to = ARGV[1]
$output_format = ARGV[2] || "markdown"
@mmertsock
mmertsock / geothemic_meandian.js
Created March 11, 2021 15:42
xkcd’s Geothemic Meandian
// https://xkcd.com/2435/
// Usage: geothemic meandian = g(array, epsilon, [iterations = 3])
function g(a, epsilon, iterations) {
if (a.length < 1) { return NaN; }
iterations = (Number.isFinite(iterations) && iterations > 0) ? iterations : 3;
let geothmetic = Array.from(a);
while (range(geothmetic) > epsilon) {
geothmetic = f(geothmetic);
}
@mmertsock
mmertsock / GitHub Title and URL.scpt
Last active September 24, 2020 20:23
AppleScript: get GitHub title and URL
-- For copying/pasting the title and URL of something from GitHub into an email or whatever.
-- output: places text into clipboard, e.g. "TitleOfPullRequest https://github.com/x/y/pull/123"
tell application "Safari"
set my_n to name of current tab of front window
set my_u to URL of current tab of front window
set my_script to "((document.title.match(/^(.*)( · Issue #| by [^ ]+ · Pull Request)/) || [])[1] || document.title)+ ' ' + document.location.href;"
set my_t to (do JavaScript my_script in current tab of front window)
set the clipboard to my_t
end tell
@mmertsock
mmertsock / CycleAccentColor.scpt
Created December 24, 2019 15:30
AppleScript to pick a random macOS accent color
-- https://apple.stackexchange.com/a/338355/13458
tell application "System Preferences"
reveal anchor "Main" of pane id "com.apple.preference.general"
end tell
tell application "System Events"
repeat until exists of checkbox "Dark" of window "General" of application process "System Preferences"
delay 0.1
@mmertsock
mmertsock / publish_pod.sh
Last active July 16, 2018 08:57
Helper script template for publishing podspecs to a private repository. Place the `publish_pod.sh` file in the root directory of your pod (the same directory as your podspec file). You should also have a working copy of your private Cocoapods pod repository. The path of the pods repo and the name of the pod need to be inserted into the script te…
set -e # http://stackoverflow.com/q/2870992/795339
podname=<TODO:NAME>
version=$(grep s.version $podname.podspec | head -1 | cut -d = -f 2 | cut -d '"' -f 2)
poddir=<TODO:ROOT DIRECTORY OF YOUR LOCAL PODS REPO>/$podname/$version
# This should print without any quote characters. Otherwise the script will break.
echo "Publishing $podname release $version..."
echo "The podspec file should be updated with a new version number. Going to commit."
@mmertsock
mmertsock / md.md
Last active May 2, 2018 14:59
Link Scratchpad
<html>
<body>
<h2>Bookmarklets</h2>
<p>
Golden cookie alert:
<a href="javascript:window.shc=3;setInterval(function(){if(Game.shimmers.length>0){if(shc&gt;0){var v=Game.volume;Game.volume=100;PlaySound('snd/pop'+(shc--)+'.mp3');Game.volume=v;}}else{shc=3;}},1e3);">here is your bookmarklet</a>
</p>
</body>
</html>
@mmertsock
mmertsock / fl50s.markdown
Created April 4, 2016 17:41
2015 Finger Lakes 50s Race Report

Race data on Strava

I chose this as my first 50-mile trail race with the perception that it was “easy” (on paper, relative to Virgil and Cayuga at least) and well timed as a training race for Twisted Branch (though I did intend to really race it, just not as a goal race).

The hills were entirely reasonable. The mud was something else: I certainly expected mud, though not the quantity and quality and variety that we faced today. Given the choice I'd avoid a muddy run, but I'm not afraid of it (after completing last year's Sehgahunda). The mud mainly presented some interesting strategic and technical challenges: increased wear and fatigue on the legs, more focus required on otherwise not-very-technical trails, and most importantly it required a singular dedication to making up time on what dry ground was available.

Since this was in a way my first 50-mile race (I got in 54 at Mind the Ducks but that's a different thing), it was a very inte

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+