Skip to content

Instantly share code, notes, and snippets.

View ralphschuler's full-sized avatar

Ralph Schuler ralphschuler

View GitHub Profile
@ralphschuler
ralphschuler / adaway.tld
Created September 11, 2024 15:44
FritzBox Internet Filter List
analytics.163.com
crash.163.com
iad.g.163.com
api4.1mobile.com
sync.1rx.io
tag.1rx.io
s.206ads.com
api.247-inc.net
tie.247-inc.net
247realmedia.com
openapi:%203.1.0%0Ainfo%3A%0A%20%20title%3A%20Notion%20API%0A%20%20description%3A%20%22Hello%20and%20welcome!%5Cn%5CnTo%20make%20use%20of%20this%20API%20collection%20collection%20as%20it's%20written,%20please%20duplicate%20%5Bthis%20database%20template%5D(https%3A//www.notion.so/8e2c2b769e1d47d287b9ed3035d607ae?v=dc1b92875fb94f10834ba8d36549bd2a).%5Cn%5Cn%5CuFEFFUnder%20the%20%60Variables%60%20tab,%20add%20your%20environment%20variables%20to%20start%20making%20requests.%20You%20will%20need%20to%20%5Bcreate%20an%20integration%5D(https://www.notion.so/my-integrations)%20to%20retrieve%20an%20API%20token.%20You%20will%20also%20need%20additional%20values,%20such%20as%20a%20database%20ID%20and%20page%20ID,%20which%20can%20be%20found%20in%20your%20Notion%20workspace%20or%20from%20the%20database%20template%20mentioned%20above.%5Cn%5CnFor%20our%20full%20documentation,%20including%20sample%20integrations%20and%20guides,%20visit%20%5Bdevelopers.notion.com%5D(https://developers.notion.com/)%5CuFEFF.%5Cn%5CnPlease%20note:
@ralphschuler
ralphschuler / SeedManagement.ts
Created November 1, 2023 22:41
Random Seed Management and Comparison
type Vector = number[];
type VectorPair = [Vector, Vector];
class MathOperations {
static calculateDotProduct(vectorA: Vector, vectorB: Vector): number {
return vectorA.reduce((accumulator, value, index) => accumulator + value * vectorB[index], 0);
}
static calculateNorm(vector: Vector): number {
return Math.sqrt(this.calculateDotProduct(vector, vector));
@ralphschuler
ralphschuler / ObjectObserver.ts
Created November 1, 2023 22:38
Random Typescript ObjectObserver
// Custom error classes
class ObjectAlreadyObservedError extends Error {
constructor(identifier: Identifier) {
super(`Object with identifier ${identifier} is already being observed.`);
Object.setPrototypeOf(this, ObjectAlreadyObservedError.prototype);
}
}
class ObjectNotObservedError extends Error {
constructor(identifier: Identifier) {
@ralphschuler
ralphschuler / BetterMap.ts
Last active September 25, 2023 13:49
Typescript Code Snippets I (found/wrote/generated using ai)
class BetterMap<k, v> extends Map<k, v> {
update(key:k, updater: (v:v, k:k) => v, notset:v = undefined) {
if(this.has(key)) this.set(key, updater(this.get(key), key))
else this.set(key, notset)
}
filter(predicate: (v:v, k:k) => boolean) {
const newMap = new BetterMap<k, v>()
const entries = Array.from(this.entries())
for(const [key, value] of entries) {