Skip to content

Instantly share code, notes, and snippets.

@dlmanning
dlmanning / Cargo.toml
Last active April 6, 2023 10:12
Little utility to list all PR's waiting for your review in a specified repo
[package]
name = "gh-pr-cli"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
async-openai = "0.10.2"
dotenvy = "0.15.7"
@dlmanning
dlmanning / output.txt
Last active June 19, 2022 18:43
Calculate odds of recombinators
mods \ total mods in pool
desired \______________________________________________
| 1 | 2 | 3 | 4 | 5 | 6 |
-------------|-------|-------|-------|-------|-------|-------
1 | 0.667 | 0.667 | 0.633 | 0.563 | 0.500 | 0.450 |
-------------|-------|-------|-------|-------|-------|-------
2 | 0.000 | 0.333 | 0.367 | 0.267 | 0.200 | 0.160 |
-------------|-------|-------|-------|-------|-------|-------
3 | 0.000 | 0.000 | 0.200 | 0.087 | 0.050 | 0.035 |
@dlmanning
dlmanning / dnd.c
Created June 15, 2021 03:45
read whether or not macOS's Do Not Disturb mode is on
#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>
int main()
{
CFStringRef DO_NOT_DISTURB = CFStringCreateWithCString(kCFAllocatorDefault, "doNotDisturb", kCFStringEncodingUTF8);
CFStringRef APP_ID = CFStringCreateWithCString(kCFAllocatorDefault, "com.apple.notificationcenterui", kCFStringEncodingUTF8);
Boolean keyExists;
@dlmanning
dlmanning / traversal.js
Created May 31, 2020 16:15
Pre and post order traversal without recursion
class Stack extends Array {
top() {
return this[this.length - 1];
}
size() {
return this.length;
}
}
@dlmanning
dlmanning / example-output-alt
Last active April 18, 2020 22:06
Runs a simulation of doing the Standford Santa Clara County serological survey 30000 times against a given population
Hypothetical distribution of study results in a population with 0% prevalence using a test with 98.5% selectivity
[0.0078, 0.0084]: |
[0.0084, 0.0090]: |
[0.0090, 0.0096]: ||
[0.0096, 0.0102]: |||||
[0.0102, 0.0108]: |||||||||
[0.0108, 0.0114]: ||||||||||||||||||
[0.0114, 0.0120]: ||||||||||||||||||||||||||||||||
[0.0120, 0.0126]: ||||||||||||||||||||||||||||||||||||||||||||||||
#include <cstddef>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
class Foo {
public:
const fs = require('fs');
const mathWASM = fs.readFileSync('./math.wasm');
const mainWASM = fs.readFileSync('./main.wasm');
async function main() {
// Both modules will share this table
const table = new WebAssembly.Table({
element: "anyfunc",
initial: 3,
@dlmanning
dlmanning / monty.js
Last active June 19, 2017 14:13
Simulation of the Monty Hall problem
/*
There are a certain number of doors (usually 3). Behind one is a prize. Behind the others are goats.
The contestant picks a door, and then the host removes one of the non-selected choices that did contain
the prize. The contestant is given the option to either keep their original choice, or switch to one of
the remaining doors. What should they do?
Let's simulate their potential decisions to find out!
*/
const doors = [1, 2, 3]
@dlmanning
dlmanning / injected.js
Created April 20, 2017 02:51
Script comcast injected in my http response to show me a modem ad
// Copyright (C) 2015 Comcast Cable Communications, LLC
// Contact Us: http://customer.xfinity.com/contact-us/
// Intended use of this message is to display critical and time sensitive notifications to customers.
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
'use strict'
const async = makeGenerator => function () {
const generator = makeGenerator.apply(this, arguments);
const handle = result =>
result.done
? Promise.resolve(result.value)
: Promise.resolve(result.value)
.then(res => handle(generator.next(res)))