Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# until https://github.com/JetBrains/intellij-community/pull/3022 gets merged
set -e
tmpdir="$(mktemp -d -t patch.df-bf)"
echo "using tmpdir: $tmpdir" >&2
function patch_impl() {
cd "$tmpdir"
:root {
--font-family-default: "Berkeley Mono", monospace;
}
@layer base {
code {
font-family: "Berkeley Mono", monospace !important;
}
}
@thewisenerd
thewisenerd / userscript.js
Created October 17, 2024 05:23
Open Slack in Browser, not App
// ==UserScript==
// @name Open Slack in Browser, not App
// @match https://*.slack.com/ssb/redirect
// @match https://*.slack.com/archives/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
'use strict';
(() => {
const xsrf = [...new URLSearchParams(window.location.search)].find(x => x[0].length == 32);
if (!xsrf) throw new Error("xsrf token not found");
fetch('/sysmgmt/2015/server/vconsole?type=HTML5', {
headers: {'xsrf-token': xsrf[0]}
}).then(res => {
if (!res.ok) throw new Error(`invalid status code: ${res.status}`);
return res.json();
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
let secret = rand::thread_rng().gen_range(1..=100);
let mut guess = String::new();
loop {
guess.clear();
{
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 / 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;
}