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 / 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 / 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 / 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 / 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

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+
@mmertsock
mmertsock / bio.markdown
Last active January 15, 2016 16:47
Running Inside Out Bio

Mike Mertsock discovered the Rochester trail running community while building what would become the official #TrailsRoc app. Now a member of #TrailsRoc and groupie to many of the local running personalities, he has a hard time refusing a race. Mike’s haphazard but prodigious training has got him through local classics such as Sehgahunda, Mind the Ducks, Finger Lakes 50s, Twisted Branch and Mendon Trail Run, and he continues to search for the next challenge in ultra, trail, and mountain running, or any excuse to spend long day in the woods.

In addition to the #TrailsRoc app, Mike created Dayly Calendar to track all the non-running things in his life that he would otherwise forget, like cross-training and litter-scooping.

Mike’s wife Valerie is known for her top-notch aid station, crew, and pastry skills.

Though not normally very talkative, Mike occasionally goes deep with his race reports on his blog, [Running|Code](http://ww