Skip to content

Instantly share code, notes, and snippets.

{
local id = function(x) x,
local keySet = function(a, keyF=id)
{ [k]: true for k in std.map(keyF, a) if k != null },
arrUnion(a, b, keyF=id)::
local aSet = keySet(a, keyF);
local bSet = keySet(b, keyF);
a + std.foldl(function(acc, e) acc + (
local key = keyF(e);
@thewisenerd
thewisenerd / adx-hc-export.js
Created March 28, 2024 02:16
export Azure Data Explorer chart output as a PNG
'use strict';
(() => {
let filename = 'adx-' + Date.now() + '.png';
let lightModeBg = 'white';
let darkModeBg = '#1b1a19';
let dl = (url, name) => {
let link = document.createElement('a');
const defaults = {
'a': 1
};
const foo = (flag = false) => {
let headers: any = defaults;
if (flag) {
headers['b'] = 2;
}
return headers;
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logging.basicConfig(
handlers=[ch],
level=logging.ERROR,
format='%(levelname)-8s [%(asctime)s.%(msecs)03d] %(name)s: %(message)s',
@thewisenerd
thewisenerd / dont-run-this-lmao.sh
Created November 16, 2022 21:34
installing facebook prophet on macOS arm64
brew install python@3.11
python3.11 -m pip install cmdstanpy
python3.11 -m pip install prophet # this should work ? if it dont, good luck lmao
# at this point, you might get an error
# RuntimeError: Error during optimization! Command '/opt/homebrew/lib/python3.11/site-packages/prophet/stan_model/prophet_model.bin
# dyld[71677]: Library not loaded: '@rpath/libtbb.dylib'
cd /opt/homebrew/lib/python3.11/site-packages/prophet/stan_model
install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin
# 'Prophet.fit' should no longer throw a fit haha
@thewisenerd
thewisenerd / env.ts
Created February 12, 2024 14:20
hello process.env
// src/lib/env.ts
export function env(envKey: string): string | undefined {
if (typeof window === 'undefined') {
console.error("[__NEXT_PUBLIC__] env() is not expected to be invoked on the server. this is a recoverable bug.");
return process.env[envKey];
}
if (!('__NEXT_PUBLIC__' in window)) {
console.error("[__NEXT_PUBLIC__] window.__NEXT_PUBLIC__ is not defined. this is a bug.");
return undefined;
}
@thewisenerd
thewisenerd / Dockerfile
Created January 18, 2024 14:17
docker stretch ca-certificates letsencrypt
# Update stretch repositories
RUN sed -i -e 's/deb.debian.org/archive.debian.org/g' \
-e 's|security.debian.org|archive.debian.org|g' \
-e '/stretch-updates/d' /etc/apt/sources.list
# LetsEncrypt DST Root CA X3 expired on 2021-09-30
# https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
RUN sed -i '/^mozilla\/DST_Root_CA_X3.crt$/ s/^/!/' /etc/ca-certificates.conf
RUN update-ca-certificates
import * as openpgp from 'openpgp';
import {Octokit} from "@octokit/rest";
const privateKeyArmored: string = `-----BEGIN PGP PRIVATE KEY BLOCK-----
HAHAHAHA did you really think
-----END PGP PRIVATE KEY BLOCK-----
`;
async function createEmptyCommit(
octokit: Octokit,
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define ONE_MB (1024 * 1024)
#define SLEEP_BUF_DEFAULT 16 // wait 1s every N MB
#define SLEEP_BUF_MIN 0
#define SLEEP_BUF_MAX (1024 * 1024) // surely nobody has 1 TB lying around
@thewisenerd
thewisenerd / not-alert.py
Last active July 19, 2023 03:40
send slack alert if output file doesn't see any additions for 5 minutes
import glob
import json
import os
import sys
import time
import typing
import urllib.request
period_in_seconds = 60
watch_time_seconds = 300