Skip to content

Instantly share code, notes, and snippets.

View Thinkscape's full-sized avatar

Arthur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / zodErrorToString.ts
Last active November 21, 2023 23:12
Recursively convert ZodError to a string, or array of issue descriptions.
import { type ZodError, type ZodIssue } from "zod";
export function zodErrorToString(error: ZodError, separator = ", ") {
return zodIssuesToStrings(error.issues).join(separator);
}
function zodIssuesToStrings(obj: ZodIssue[]) {
let results: string[] = [];
function traverse(node: ZodIssue | ZodIssue[]) {
@Thinkscape
Thinkscape / disk-bench.sh
Last active November 8, 2023 02:24
disk benchmark using fio at different block sizes
#!/bin/env bash
for bs in 4k 16k 64k 256k 1M 4M; do
echo "Running burst speed test of $1 with block size $bs";
fio --name=burst_speed_test --ioengine=libaio --iodepth=1 --rw=rw --direct=1 --runtime=60 --time_based \
--verify=crc32c --do_verify=1 --verify_fatal=1 --verify_dump=1 --verify_backlog=1000 \
--filename=$1 --bs=$bs --numjobs=1 --group_reporting;
done
@Thinkscape
Thinkscape / dom-parser.ts
Created May 16, 2017 18:13
PM DOMParser allowing invokables for parseDOM
import * as dom from '../prosemirror/dom';
import {
DOMParser as PMDOMParser,
ParseContext as PMParseContext,
NodeType,
ParseRule,
Node,
Mark
} from '../prosemirror';
@Thinkscape
Thinkscape / -
Created February 24, 2016 10:51
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 52.9.79.155...
* Connected to sameroom.io (52.9.79.155) port 443 (#0)
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: www.sameroom.io
* Server certificate: StartCom Class 2 Primary Intermediate Server CA
* Server certificate: StartCom Certification Authority
> GET /maps/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NTYzOTQ0MDAsImJyaWRnZV9pZCI6MjYwODl9.QX8reWSuV6l9r3-Ze6LrZ0CkUwjaGEtwng7HB_lU_NE HTTP/1.1
> Host: sameroom.io
--- duplicity 2015-08-19 12:00:48.000000000 +0200
+++ duplicity 2015-08-19 12:00:43.000000000 +0200
@@ -158,7 +158,8 @@
# there is no sign_key and there are recipients
elif (action == "full"
and (globals.gpg_profile.recipients or globals.gpg_profile.hidden_recipients)
- and not globals.gpg_profile.sign_key):
+ and not globals.gpg_profile.sign_key
+ and not globals.restart):
return ""
@Thinkscape
Thinkscape / EffectiveUrlMiddleware.php
Last active October 4, 2022 18:30
getEffectiveUrl() replacement for Guzzle 6.*
<?php
namespace Thinkscape\Guzzle;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class EffectiveUrlMiddleware
{
/**
* @var Callable
@Thinkscape
Thinkscape / gist:a9f96d9ecffeb6ba9f4f
Last active August 29, 2015 14:27
Mixcloud onboarding genres 08.2015
@Thinkscape
Thinkscape / gist:da8bf3c2f33b23af68c3
Created August 10, 2015 16:47
List of last.fm top-level genres (tags) 08.2015
60s
70s
80s
90s
acoustic
ambient
blues
classical
country
electronic
@Thinkscape
Thinkscape / gist:8b98b82a74c102b31f5d
Created August 10, 2015 16:46
List of soundcloud.com music genres 08.2015
Alternative Rock
Ambient
Audiobooks
Business
Classical
Comedy
Country
Dance & EDM
Dancehall
Deep House
@Thinkscape
Thinkscape / mtr.txt
Created July 2, 2015 10:28
mtr -c 30 --report 5.135.99.110
Start: Thu Jul 2 11:25:00 2015
HOST: Sombrero-3.local Loss% Snt Last Avg Best Wrst StDev
1.|-- 10.100.84.1 0.0% 30 1.2 3.3 1.1 23.9 5.1
2.|-- 84.207.252.3.not-updated. 0.0% 30 1.1 1.1 0.9 2.6 0.3
3.|-- 217.112.154.169.not-updat 0.0% 30 7.2 9.4 7.0 47.8 7.5
4.|-- ??? 100.0 30 0.0 0.0 0.0 0.0 0.0
5.|-- rbx-g2-a9.fr.eu 0.0% 30 16.7 17.1 16.2 18.3 0.3
6.|-- rbx-s5-6k.fr.eu 0.0% 30 51.9 19.3 15.7 55.5 9.5
7.|-- 5.135.99.110 0.0% 30 16.1 17.4 16.0 29.4 3.2