Skip to content

Instantly share code, notes, and snippets.

View david-bakin's full-sized avatar

David Bakin david-bakin

View GitHub Profile
@david-bakin
david-bakin / OneArrayElementPerLineNoWhitespacePrettyPrinter.java
Created July 1, 2023 02:29
Jackson pretty printer that prints objects compactly (no whitespace) and array elements one-per-line
/* Looks like this:
{"todo":[
{"isbn":"0064632105"},
{"isbn":"007001115X"},
{"isbn":"0070079749"},
...
*/
public static class OneArrayElementPerLineNoWhitespacePrettyPrinter extends DefaultPrettyPrinter {
public OneArrayElementPerLineNoWhitespacePrettyPrinter() {}
@david-bakin
david-bakin / ReplaceThrowableMessageFragment.java
Last active July 3, 2023 01:03
Rewriting the message of a Throwable
/** Sometimes you might want to rethrow the same exception but with a little extra in the message. This allows
* you to "clone" an exception but change the message. (C# exceptions have the capability to hold arbitrary
* information via the `Data` property (a `Dictionary`).)
*/
@NonNull
public static Throwable replaceMessageOf(@NonNull final Throwable ex, @NonNull final String msg) {
// First try using reflection to just stomp on the exception instance's message
if (false) {
final var rex = stompOnMessageOf(ex, msg);
@david-bakin
david-bakin / UHK-w_-layers-adjusted-for-P16-keyboard.kbd.json
Last active April 4, 2025 04:30
UHK w/ layers adjusted for P16 keyboard
[
{
"name": "UHK w/ layers adjusted for P16 keyboard"
},
[
{
"c": "#459896",
"fa": [
1,
0,
location layer
center normal / shifted
top left MOD
top right Fn
bottom left Mouse
center front Key Id