Skip to content

Instantly share code, notes, and snippets.

View aeinbu's full-sized avatar

Arjan Einbu aeinbu

View GitHub Profile
@aeinbu
aeinbu / .zshrc
Last active November 8, 2023 19:54
`la` and `mkcd` commands
alias la="ls -a"
mkcd() {
mkdir $1 && cd $1
}
@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 = [
public abstract record StronglyTypedId<TValue>(TValue Value)
where TValue : notnull
{
public override sealed string ToString() => $"{Value}";
}
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;
}
function Deferred() {
this.resolve = null;
this.reject = null;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
@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) {

Linux users/groups/permissions cheatsheet

See a file's ownership and permissions with ls -a

Add user

$ sudo useradd -m peter
$ sudo passwd peter

$ groupadd myAppUsers

How to add a new disk in Linux

This post takes you through creating a partition, formatting it and finally mount it in the filesystem.

These procedures where tested on Linux Mint 19

List disks and partitions

$ sudo fdisk -l

The result will vary depending on the number of disk you have. On my computer I got these three entries:

@aeinbu
aeinbu / running-docker-images-cheatsheet.md
Last active February 19, 2024 23:26
docker cheat sheet

Running docker images cheatsheet

Download a docker image

Download the image called debian:

docker pull debian

Create a container (and start it)

The container in the samples will be named "debby"

@aeinbu
aeinbu / chain.js
Created May 14, 2019 08:57
Helper to chain method calls while we're waiting for |> (the js pipe operator)
const chain = (obj, op = obj => obj, ...restOps) => restOps.length > 0
? chain(op(obj), ...restOps)
: op(obj);