Skip to content

Instantly share code, notes, and snippets.

View dlew's full-sized avatar

Dan Lew dlew

View GitHub Profile
@dlew
dlew / gist:debc5ea214678bf0739a8ec92dabe095
Created November 5, 2021 17:56
Privacy Policy for Apps That Collect No Data
This app collects no private data, period. Your data will not be used in any way, because we won't have it.
@dlew
dlew / trombonechamp.kt
Created September 24, 2022 14:36
Trombone Champ hacky trombone code
import be.tarsos.dsp.AudioEvent
import be.tarsos.dsp.io.jvm.AudioDispatcherFactory
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
dlew / gist:bbcfa2e0a0e92d2474699a2c5814708e
Created April 8, 2025 14:27
All "bugged" seeds in Balatro (erratic deck generates all tens of spades)
BGY5SDS
1V3UQ6AP
36756M6I
3WBV4FSC
627SP6LE
6WG44S7Z
7LB2WVPK
81N7QMOM
9PCOBR2D
B9A4IA7S
@dlew
dlew / script.sh
Created November 9, 2018 16:36
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: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# 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
dlew / themes-debug.xml
Last active January 20, 2025 16:07
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@dlew
dlew / File.java
Created March 1, 2016 20:46
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)",
element.getClassName(),
element.getMethodName(),
element.getFileName(),
element.getLineNumber());
@dlew
dlew / thing.kt
Last active January 31, 2021 02:30
Gson -> Moshi name snafu detector
@Test
fun verifySerializedNameMatchesJsonName() {
// Reflections library
Reflections("com.foobar").getTypesAnnotatedWith(JsonClass::class.java)
.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
@dlew
dlew / build.gradle
Last active September 11, 2019 18:35
Sample gradle.build for Crashlytics
// Follow the five numbered instructions for setting up Crashlytics
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
// 1. Add the Crashlytics Maven repository to your build script.
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {

Keybase proof

I hereby claim:

  • I am dlew on github.
  • I am danlew (https://keybase.io/danlew) on keybase.
  • I have a public key ASD8v3oTeKIyAZP1WwjzP1Wxej0F_V6CqXZOdQ9A61iewAo

To claim this, I am signing this object: