Skip to content

Instantly share code, notes, and snippets.

dlew / trombonechamp.kt
Created Sep 24, 2022
Trombone Champ hacky trombone code
View trombonechamp.kt
import be.tarsos.dsp.AudioEvent
import be.tarsos.dsp.pitch.PitchDetectionHandler
import be.tarsos.dsp.pitch.PitchDetectionResult
import be.tarsos.dsp.pitch.PitchProcessor
import be.tarsos.dsp.pitch.PitchProcessor.PitchEstimationAlgorithm
import java.awt.Robot
import java.awt.event.InputEvent
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
dlew / gist:debc5ea214678bf0739a8ec92dabe095
Created Nov 5, 2021
Privacy Policy for Apps That Collect No Data
View gist:debc5ea214678bf0739a8ec92dabe095
This app collects no private data, period. Your data will not be used in any way, because we won't have it.
dlew / thing.kt
Last active Jan 31, 2021
Gson -> Moshi name snafu detector
View thing.kt
fun verifySerializedNameMatchesJsonName() {
// Reflections library
.flatMap { clz ->
// FieldUtils is in Apache Commons
FieldUtils.getAllFieldsList(clz).filter { !Modifier.isStatic(it.modifiers) }
.forEach { field ->
val serializedNameAnnotation = field.declaredAnnotations.find { it is SerializedName } as? SerializedName

Keybase proof

I hereby claim:

  • I am dlew on github.
  • I am danlew ( on keybase.
  • I have a public key ASD8v3oTeKIyAZP1WwjzP1Wxej0F_V6CqXZOdQ9A61iewAo

To claim this, I am signing this object:

dlew /
Created Nov 9, 2018
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
# You can download a CSV of package names here:
# It'll run faster on a clean build because then there are fewer files to scan over.
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
dlew /
Created Nov 1, 2017
Simple Python script that tells you all the current artifact spots on a Stardew Valley save
import xml.etree.ElementTree as ET
tree = ET.parse('/path/to/save/file')
root = tree.getroot()
locations = root.find('locations')
for location in locations:
name = location.find('name').text
objects = location.find('objects')
for thing in objects:

When Mac OS X first launched they did so without an existing poll function. They later added poll() in Mac OS X 10.3, but we quickly discovered that it was broken (it returned a non-zero value when asked to wait for nothing) so in the curl project we added a check in configure for that and subsequently avoided using poll() in all OS X versions to and including Mac OS 10.8 (Darwin 12). The code would instead switch to the alternative solution based on select() for these platforms.

With the release of Mac OS X 10.9 “Mavericks” in October 2013, Apple had fixed their poll() implementation and we’ve built libcurl to use it since with no issues at all. The configure script picks the correct underlying function to use.

Enter macOS 10.12 (yeah, its not called OS X anymore) “Sierra”, released in September 2016. Quickly we discovered that poll() once against did not act like it should and we are back to disabling the use of it in preference to the b

dlew /
Created Mar 1, 2016
Automated onError() message generation
public static Action1<Throwable> crashOnError() {
final Throwable checkpoint = new Throwable();
return throwable -> {
StackTraceElement[] stackTrace = checkpoint.getStackTrace();
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()`
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)",
View gist:9fd280bbc057af800213
* Returns the Java Compilation task if javac was configured to compile the source files.
* @deprecated prefer {@link #getJavaCompiler} which always return the java compiler task
* irrespective of which tool chain (javac or jack) used.
JavaCompile getJavaCompile() throws IllegalStateException;