Skip to content

Instantly share code, notes, and snippets.

View Zatte's full-sized avatar

Mikael Rapp Zatte

  • Kvantic.com
  • Stockholm
View GitHub Profile
@Zatte
Zatte / ReaderFanOut.go
Last active November 30, 2023 15:46
A GoLang fanout reader / Multi reader to have multiple consumers process the same io.Reader without buffering
// ReaderFanOut allows multiple consumers of one io.Reader.
// all consumers are run concurrently (in go threads) but will process
// the reading sequentially; this means that if a consumer stops consuming
// the reader it will block other consumers.
// If a consumer returns the it's reader is automatically drained to avoid
// stalling other consumers. If any consumer returns a non nil error the
// context for all other consumers is cancelled and the first error is returned.
func ReaderFanOut(
ctx context.Context,
source io.Reader,
@Zatte
Zatte / BigQuerySchemaToJsonSchema.sql
Last active January 13, 2022 20:34
POC - BigQuery UDF generating a JSON Schema string that validates JSON to match a BQ schema,
CREATE TEMP FUNCTION BigQuerySchemaToJsonSchema(src STRING)
RETURNS STRING LANGUAGE js AS """
let expandStrRep = function(subStr){
let pairs = []
let position = 0
let carrotOffset = 0
let state = "col_name"
let pair = []
for(i=0; i<subStr.length; i++){
if (state == "col_name" && subStr[i] == " "){
@Zatte
Zatte / mirror-org-repos.sh
Created November 5, 2021 08:10 — forked from benbalter/mirror-org-repos.sh
Mirror all organization repositories
org="whitehouse"
for repo in $(curl -v -s "https://api.github.com/orgs/$org/repos?per_page=100&type=sources" 2>&1 | grep '"full_name": "*"' | cut -d':' -f2 | sed s'/,$//' | sed s'/"//g' ); do
filename=$(echo "$repo" | cut -d'/' -f2)
echo "Downloading $repo..."
curl -o "$filename.zip" -L "https://github.com/$repo/archive/master.zip"
done
@Zatte
Zatte / Host
Last active November 6, 2023 12:32 — forked from lucndm/Host
Proxmox GPU passthrough to LXC Container
Note : Proxmox 6.1
VI : /etc/apt/sources.list
# security updates
deb http://security.debian.org jessie/updates main contrib
# PVE pve-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian jessie pve-no-subscription
@Zatte
Zatte / cookies.js
Created November 30, 2020 10:02 — forked from rubinchyk/cookies.js
[Read cookies] Read cookies
function readCookies() {
const cookies = document.cookie.replaceAll("; ", "&");
const params = new URLSearchParams(cookies);
return Object.fromEntries(params.entries());
}
// OR
Object.fromEntries(new URLSearchParams(document.cookie.replaceAll("; ", "&")).entries())