Skip to content

Instantly share code, notes, and snippets.

View SimDing's full-sized avatar

Simon Ding SimDing

View GitHub Profile
@SimDing
SimDing / as_gwf.ts
Last active December 22, 2023 03:54
Baldurs Gate 3 - Great Weapon Fighting and Savage Attacker Calculations
// DSL for producing distributions of dice rolls
type Cont<T> = (state: T) => void;
const rollDie = <T, U>(faces: number, state: T, cont: (faces: number, state: T, next: Cont<U>) => void, next: Cont<U>) => {
for (let i = 1; i <= faces; i++) {
//console.log(state, 'rolled', i);
cont(i, { ...state }, next);
}
};
const testSolution = (f, n, r, mod) => {
iterations = 0;
const start = process.hrtime();
const result = f(n, r, mod);
const diff = process.hrtime(start);
console.log(`${n}C${r} = ${result}, iterations: ${iterations}, duration: ${diff[1]/1000}μs`);
};
// More verbose and integer caching
@SimDing
SimDing / binomial_coefficient.ts
Created December 25, 2020 16:05
Two ways of calculating binomial coefficient
// More verbose and integer caching
// O(n^2) first call, best case in subsequent calls: O(1)
let iterations = 0;
const nCr = (n: number, r: number) => {
if (r == 0 || r == n) {
return 1;
}
nCr[n] = nCr[n] || [];
if (!nCr[n][r]) {
nCr[n][r] = nCr(n-1, r-1) + nCr(n-1, r);
import java.awt.Point;
import java.util.Scanner;
class Main {
public static String CorrectPath(String str) {
return findWay(new Point(0, 0), str);
}
public static String findWay(Point from, String using) {
@SimDing
SimDing / messageBlinker.user.js
Last active February 26, 2024 07:37
Gibt ein Blinksignal in der Tableiste, wenn eine neue Nachricht empfangen wurde.
// ==UserScript==
// @name Proxer Message Info
// @namespace de.simonding.proxer
// @author Simon Ding (0ger)
// @description Gibt ein Blinksignal in der Tableiste, wenn eine neue Nachricht empfangen wurde.
// @include http://proxer.me/*
// @include https://proxer.me/*
// @include http://www.proxer.me/*
// @include https://www.proxer.me/*
// @version 0.4
@SimDing
SimDing / proxer_auto_bookmark.user.js
Last active February 26, 2024 07:36
Greasemonkey/Tampermonkey script: Ermöglicht das automatische Anlegen von Lesezeichen für Manga auf der Seite proxer.me
// ==UserScript==
// @name Proxer Auto-Lesezeichen
// @namespace de.093r.proxer
// @description Ermöglicht das automatische Anlegen von Lesezeichen für Manga auf der Seite proxer.me
// @include http://proxer.me/*
// @include https://proxer.me/*
// @version 2.3
// @downloadURL https://gist.github.com/SimDing/dd46389817c3f999944a/raw/proxer_auto_bookmark.user.js
// @grant none
// @history 2.3 Improved storage integrity
@SimDing
SimDing / BetterPrank
Last active February 26, 2024 07:38
// ==UserScript==
// @name BetterPrank
// @namespace dngsimon
// @include http://fediafedia.com/prank/win7/*
// @version 1
// @grant none
// ==/UserScript==
// trash original shit