Skip to content

Instantly share code, notes, and snippets.

View Thinkscape's full-sized avatar

Arthur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / README.md
Last active May 7, 2024 14:20
Fix lodash edge compatibility (vercel, cloudflare workers)

Lodash and Edge Runtimes

See: lodash/lodash#5862

Lodash uses Function(String) which upsets Next.js and is incompatible with CloudFlare workers (Vercel Edge), resulting in errors like:

Failed to compile.
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
@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