Skip to content

Instantly share code, notes, and snippets.

View j0sh's full-sized avatar
🐠

Josh Allmann j0sh

🐠
View GitHub Profile
@j0sh
j0sh / equals_test.go
Created March 28, 2024 00:02
Slice vs []byte equality in golang
package main
import (
"bytes"
"crypto/rand"
"slices"
"testing"
)
// generateRandomByteSlice generates a random byte slice of the given size.
@j0sh
j0sh / Dockerfile.cloudflared
Last active March 7, 2024 00:31
Passing tunnel tokens into cloudflared via Docker Compose secrets
FROM busybox:1.36.1-uclibc as busybox
FROM cloudflare/cloudflared:2023.8.2
COPY --from=busybox /bin/sh /bin/sh
COPY --from=busybox /bin/cat /bin/cat
ENTRYPOINT [ "/bin/sh", "-c", "export TUNNEL_TOKEN=$(cat /run/secrets/tunnel_prod_token) ; cloudflared --no-autoupdate tunnel run" ]
package main
import "encoding/base64"
type Base64URLBlob []byte
var b64 = base64.URLEncoding
func (b Base64URLBlob) MarshalJSON() ([]byte, error) {
dst := make([]byte, b64.EncodedLen(len(b))+2)
@j0sh
j0sh / auth.tsx
Created October 20, 2023 04:18
pocketbase oauth with github and react ts
import React from 'react'
import ReactDOM from 'react-dom/client'
import PocketBase from 'pocketbase'
type DashState = {
pb?: PocketBase;
authenticated: boolean;
}
const defaultDashState : DashState = {
authenticated: false,
@j0sh
j0sh / split.test.ts
Created July 31, 2023 21:22
typescript string split with remainder
import { split } from './utils';
test('string split', () => {
const p = split("a b c d", " ", 2);
expect(p).toStrictEqual(["a", "b c d"]);
});
test('string split nonexistent', () => {
const p = split("a b c d", ",", 2);
expect(p).toStrictEqual(["a b c d"]);
From 5db9543bdf466a7894e5532c10618e42c162da83 Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Fri, 24 May 2019 15:30:32 +0000
Subject: [PATCH] lavfi/vf_scale_cuda: Reset frame size after acquiring from
hwframe.
The first frame is scaled correctly, and subsequent frames are
over-scaled / cropped since the frame data is reset with the
hwframe after each invocation of the scaler.
@j0sh
j0sh / Makefile
Last active April 24, 2019 19:09
Testing GPU with LPMS
# Also assumes you have the ffmpeg libs within pkg-config
all:
CPATH=/usr/local/cuda/include LIBRARY_PATH=/usr/local/cuda/lib64 go build gpu.go
bench:
CPATH=/usr/local/cuda/include LIBRARY_PATH=/usr/local/cuda/lib64 go build lpms-bench.go
clean:
rm -f gpu lpms-bench
@j0sh
j0sh / pusub.ml
Last active March 11, 2016 19:11
(*
pubsub semantics:
previous message is stored and sent to newly subscribing clients if present.
unpublishes will clear any previously stored messages
unsubscribes will push None to wake up any read loops
*)
type ('a, 'b) t = {
msg_tbl : ('a, 'b) Hashtbl.t;
sub_tbl : ('a, ('b option -> unit)) Hashtbl.t;
module Sqlexpr = Sqlexpr_sqlite.Make(Sqlexpr_concurrency.Lwt)
module S = Sqlexpr
open Lwt.Infix
let test_retry_begin =
let __ppx_sqlexpr_shared_1 =
{
Sqlexpr.statement =
{
Sqlexpr.sql_statement = "SELECT COUNT(*) FROM foo";
stmt_id = (Some "9e11a7554f37de62d53f51cdd7f94b6b");