Skip to content

Instantly share code, notes, and snippets.

@theimpostor
theimpostor / json-merge.pl
Created October 24, 2016 19:59
Merge json files via simple perl script
#!/usr/bin/perl
BEGIN { $ENV{PERL_JSON_BACKEND} = 'JSON::PP' }
use JSON; # always uses JSON:PP
use File::Slurp;
use Hash::Merge qw( merge );
use warnings;
use strict;
##
@theimpostor
theimpostor / Dockerfile
Last active July 8, 2018 20:22
read input w/curl
FROM alpine
RUN apk add --no-cache \
bash \
curl
CMD [ "/bin/bash", "-c", "curl --include https://api.apify.com/v2/key-value-stores/${APIFY_DEFAULT_KEY_VALUE_STORE_ID}/records/INPUT?disableRedirect=1" ]
@theimpostor
theimpostor / Dockerfile
Created October 30, 2018 03:03
apify.com actor for https://praytime.app
FROM praytime/praytime
Process: ccls [24711]
Path: /usr/local/Cellar/ccls/0.20181225.8/bin/ccls
Identifier: ccls
Version: 0
Code Type: X86-64 (Native)
Parent Process: languageclient [24703]
Responsible: ccls [24711]
User ID: 502
Date/Time: 2019-02-06 11:55:28.990 -0600
@theimpostor
theimpostor / CMakeLists.txt
Last active April 29, 2019 21:33
rocksdb slow seek
cmake_minimum_required(VERSION 3.0)
project(rocksdb-slow-seek-proj)
# write a compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_library(ROCKSDB_LIBRARY rocksdb
PATHS ${ROCKSDB_DIR}/lib)
find_library(SNAPPY_LIBRARY snappy
@theimpostor
theimpostor / LOG
Last active April 30, 2019 19:36
slow-seek w/delete range
2019/04/30-14:34:43.957327 7fff973af380 RocksDB version: 5.15.10
2019/04/30-14:34:43.958137 7fff973af380 Git sha rocksdb_build_git_sha:
2019/04/30-14:34:43.958140 7fff973af380 Compile date Feb 12 2019
2019/04/30-14:34:43.958144 7fff973af380 DB SUMMARY
2019/04/30-14:34:43.958191 7fff973af380 SST files in db dir, Total Num: 0, files:
2019/04/30-14:34:43.958193 7fff973af380 Write Ahead Log file in db:
2019/04/30-14:34:43.958195 7fff973af380 Options.error_if_exists: 0
2019/04/30-14:34:43.958196 7fff973af380 Options.create_if_missing: 1
2019/04/30-14:34:43.958197 7fff973af380 Options.paranoid_checks: 1
2019/04/30-14:34:43.958198 7fff973af380 Options.env: 0x10701ca58
@theimpostor
theimpostor / gist:8c35f6b602950ba5153043b444a29196
Last active July 29, 2021 07:11
download a youtube-dl playlist in parallel
PLAYLIST_URL=https://www.youtube.com/playlist?list=PLC89682017B43845D
PARALLEL=4
ARGS=" -f bestaudio -x --audio-format mp3"
youtube-dl -J $PLAYLIST_URL | jq -r '.entries[].webpage_url' | xargs -n 1 -P $PARALLEL youtube-dl $ARGS
# optional trim silence:
find . -maxdepth 1 -type f -name \*.mp3 -print0 | xargs -0 -n 1 -P 8 mp3splt -q -r -p min=2 -d trimmed -o '@f'
@theimpostor
theimpostor / main.cpp
Created October 31, 2019 00:33
Solution to nine digits puzzle at compile time
#include <stdio.h>
#define SWAP_INT(x, y) \
do { \
int tmp = (x); \
(x) = (y); \
(y) = tmp; \
} while (0)
template <int N> struct ConstArray {
@theimpostor
theimpostor / index.html
Created October 30, 2022 15:33
WNyQZNR
<canvas id="canvas" width=500 height=400></canvas>