Skip to content

Instantly share code, notes, and snippets.

@foolmoron
foolmoron / Program.cs
Last active August 1, 2024 01:53
Card matching game monte carlo
using System.Diagnostics;
const int N_SIMS = 100_000_000;
const int N_THREADS = 1_000;
const int N_PLAYERS = 6;
const int N_WINS = 3;
const int N_PAIRS = 24;
float[] playerAccuracy = [ 0.90f, 0.87f, 0.83f, 0.80f, 0.90f, 0.85f ];
var tasks = Enumerable.Range(0, N_THREADS).Select(i => Task.Run(RunSims)).ToArray();
@foolmoron
foolmoron / typescript.ts
Last active March 19, 2025 16:16
Advanced Typescript Types companion code
// To follow along using VSCode, copy/paste this code into
// a TS file (using TS 4.8.2+), and enable the VSCode
// js/ts.implicitProjectConfig.strictNullChecks setting
const obj = {
nested: {
prop1: 1,
prop2: 'a',
}
@foolmoron
foolmoron / compression.js
Last active July 27, 2021 22:47
Node.js compression tests
const zlib = require('zlib');
const perf_hooks = require('perf_hooks')
function t() {
return perf_hooks.performance.now()
}
const BUFFER_SIZE = 1024*1024
const TRIALS = 20
@foolmoron
foolmoron / ListDict.cs
Last active March 1, 2022 06:08
C# List-backed dictionary, for garbage-free and consistent performance
public class ListDict<TKey, TValue> {
public readonly List<TKey> Keys;
public readonly List<TValue> Values;
public int Count { get { return Keys.Count; } }
public ListDict(int capacity = 0) {
Keys = new List<TKey>(capacity);
Values = new List<TValue>(capacity);
}
@foolmoron
foolmoron / autoSkip.js
Last active August 5, 2016 20:01
Auto skip certain songs on Soundcloud by title
function autoSkip(songName) {
setInterval(() => {
if (document.querySelector('.sound.playing .soundTitle__title').innerText.toLowerCase().indexOf(songName.toLowerCase()) >= 0) {
document.querySelector('.skipControl__next').click();
}
}, 500);
}
autoSkip('Cold Water'); // seriously plz stop remixing this
@foolmoron
foolmoron / keybase.md
Created May 8, 2015 03:29
Keybase.io identity verification!

Keybase proof

I hereby claim:

  • I am foolmoron on github.
  • I am foolmoron (https://keybase.io/foolmoron) on keybase.
  • I have a public key whose fingerprint is D39F 27DE E6F2 B60F FA59 14DD 6A8F 8CA1 9B7D 7064

To claim this, I am signing this object: