Skip to content

Instantly share code, notes, and snippets.

@dr-kd
dr-kd / gist:5ca74ba3ca62cb10ec0dcf6f9065d376
Created July 25, 2025 01:06
JQ invocation to expand all JSON strings, and change any "None" value to delete the key.
jq -c 'def try_parse_json: try (fromjson) catch .;
def expand_json_strings: walk(if type == "string" then try_parse_json | if type == "string" then . else expand_json_strings end else . end);
def remove_none_values: if type == "object" then with_entries(select(.value != "None")) elif type == "array" then map(remove_none_values) else . end$
expand_json_strings | remove_none_values
| .[]'
# line 2 - anything that expands with fromjson gets expanded
# line 3 - any key with the value of "None", the key gets deleted.
#!/usr/bin/env perl
use Mojo::Base -base;
use IPC::System::Simple qw/capture/;
use FindBin qw/$Bin/;
use Data::Dumper;
use JSON::MaybeXS;
use Path::Tiny;
chdir $Bin;
my $j = JSON->new->pretty->canonical;
# Before:
my %thing = ( this => 'that', other => $self->my_method(@args));
sub my_method { ...; return $stuff }
# except it's really easy for me the developer to forget to type the 'other' key
# which results in surprising fails
# So ... wantarray
@dr-kd
dr-kd / Dockerfile
Created October 4, 2022 23:21
postgres oracle fdw container
ARG postgres_version=15beta4
FROM postgres:$postgres_version
ARG oracle_fdw_version=2_4_0
ENV ORACLE_HOME /usr/lib/oracle/19.6/client64
ENV LD_LIBRARY_PATH /usr/lib/oracle/19.6/client64/lib
RUN set -ex; \
@dr-kd
dr-kd / audio-with-speed-control.markdown
Created September 25, 2022 08:44
Audio with speed control
#!/bin/bash
# script to update your header cache for imap folders of interest non-interactively.
# set this up to run nightly in cron - it especially helps the performance of BIG mail boxes
# e.g. mailboxes big enough to crash outlook are super-snappy after header cache refresh
declare -a FOLDERS=("Archive"
"Drafts"
"INBOX"
"Outbox"
"Sent\ Items"
"Tasks"
#!/usr/bin/env perl
use warnings;
use strict;
use Array::Circular;
use Data::Dumper;
use Text::Xslate qw/mark_raw/;
use feature qw/say/;
my $tx = Text::Xslate->new(syntax => 'TTerse');
#!/usr/bin/env perl
use warnings;
use strict;
use Array::Circular;
use Data::Dumper;
use Text::Xslate qw/mark_raw/;
use feature qw/say/;
my $tx = Text::Xslate->new(syntax => 'TTerse');
#include <Keypad.h>
const byte ROWS = 7;
const byte COLS = 5;
byte CHANNEL = 1;
char keys[COLS][ROWS] = {
{ 31, 32, 30, 10, 2, 28, 29 },
{ 27, 7, 9, 25, 26, 24, 4 },
{ 6, 22, 23, 21, 1, 3, 19 },
@dr-kd
dr-kd / Proposal.POD
Created October 8, 2017 11:44 — forked from jjn1056/Proposal.POD
First Draft of possible grant proposal (2nd Draft)

Perl Catalyst Web Framework for Heretics.

Name:

John Napiorkowski <[email protected]>,<[email protected]>

Amount Requested:

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 4:

=over without closing =back