Skip to content

Instantly share code, notes, and snippets.

View aeinbu's full-sized avatar

Arjan Einbu aeinbu

View GitHub Profile
@aeinbu
aeinbu / wrapInDebugModeProxy.tests.ts
Created May 8, 2020 07:01
Makes new object that guards against executing methods and changing properties when not in debug mode
import { wrapInDisablerProxyFactory } from "./wrapInDebugModeProxy"
describe("Enable/disable functions", () => {
const obj = {
flipTheFlag(target) {
target.flag = true
},
inner: {
anotherFlipTheFlag(target) {
function Deferred() {
this.resolve = null;
this.reject = null;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
function round(value, precision) {
return Number(Math.round(value + "e" + precision) + "e-" + precision)
}
function strictCompare(left, right) {
console.log(`strictCompare(${left}, ${right})`);
return left === right;
}
public abstract record StronglyTypedId<TValue>(TValue Value)
where TValue : notnull
{
public override sealed string ToString() => $"{Value}";
}
@aeinbu
aeinbu / adhoc.js
Last active January 8, 2023 10:48
Quick queries over json files...
const {
chain,
filter,
count,
groupBy,
map
} = require("./chaining")
const transforms = [
@aeinbu
aeinbu / .zshrc
Last active November 8, 2023 19:54
`la` and `mkcd` commands
alias la="ls -a"
mkcd() {
mkdir $1 && cd $1
}