Skip to content

Instantly share code, notes, and snippets.

View Thinkscape's full-sized avatar

Arthur Bodera Thinkscape

View GitHub Profile
@Thinkscape
Thinkscape / immich-validate-encoded-videos.sh
Last active October 15, 2024 02:49
Check all assets' encoded video files - if a file is missing, set to empty in the database so that it can be re-encoded
#!/bin/bash
# Instructions for running inside docker:
# 1. Exec into a container, i.e. with: docker exec -it c0nta1ner1d bash
# 2. Copy or create the script and make it executable with: chmod +x script.sh
# 3. Install deps with: apt update && apt install -y postgresql-client
# 4. Run it and wait until finished.
# 5. Go to Immich web and into Administration
# 6. Go to Jobs and scroll down to TRANSCODE VIDEOS
# 7. Click MISSING
@Thinkscape
Thinkscape / route.ts
Last active June 19, 2024 01:11
Oversized JWT early detection for Next.js + kinde SDK
// /src/api/auth/[kindeAuth]/route.ts
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";
import jwt_decode from "jwt-decode";
import { type RedirectError } from "next/dist/client/components/redirect";
import { type ResponseCookies } from "next/dist/compiled/@edge-runtime/cookies";
import { NextResponse, type NextRequest } from "next/server";
import { hostName } from "~/env.mjs";
import { logger } from "~/server/logger";
@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