Skip to content

Instantly share code, notes, and snippets.

View aeinbu's full-sized avatar

Arjan Einbu aeinbu

View GitHub Profile
@aeinbu
aeinbu / .eslintrc.json
Last active May 6, 2019 09:07
My ESLint file
module.exports = {
"env":
{
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions":
{
@aeinbu
aeinbu / .babelrc
Last active December 16, 2019 20:00
{
"presets": [
["@babel/preset-env", {"modules": "commonjs"}]
],
"plugins": [
["@babel/plugin-proposal-object-rest-spread", {}],
["@babel/plugin-proposal-class-properties", { "loose": false }],
["@babel/plugin-proposal-nullish-coalescing-operator"],
["@babel/plugin-proposal-optional-chaining"],
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]
@aeinbu
aeinbu / wrapInReadOnlyProxy.js
Last active July 26, 2017 08:26
This method creates a read only wrapper around a javascript object, so that you can pass large object without copying them and still avoiding that they are changed.
function wrapInReadOnlyProxy(orig, throwOnSet = false) {
if (typeof orig !== "object") {
return orig;
}
return new Proxy(orig, {
get: function(target, property) {
if (property in target) {
return wrapInReadOnlyProxy(target[property]);
}
@aeinbu
aeinbu / combinePredicates.js
Last active August 14, 2018 08:38
Combine predicates for filtering
const combinePredicates = (predicate1, predicate2, ...predicateRest) =>
(item) =>
predicate1(item) && (predicateRest.length > 0? combinePredicates(predicate2, predicateRest[0]): predicate2)(item);
// sample predicates
const exclude = (val) => (item) => item !== val;
const excludeRange = (from, to) => (item) => item < from || item > to;
// sample data
let arr = [1,2,3,4,5,6,7,8,9,10];
@aeinbu
aeinbu / ArjansJsTsDebugHelpers.code-snippets
Last active October 28, 2023 21:37
Snippets to aid debugging collections transformations (map/filter/reduce) and promises
{
"console.log(\"***\", ...)": {
"prefix": "conso",
"scope": "javascript,typescript,typescriptreact",
"body": [
"console.log(\"*** $1\", $0)",
""
]
},
"debug-map":{
@aeinbu
aeinbu / .gitconfig
Last active July 29, 2021 13:39
Some practial aliases for Git
[alias]
refresh = !git fetch --all --prune && git checkout master && git pull --rebase && git lastbranch
amend = commit --amend --no-edit
lastbranch = checkout @{-1}
ql = log -10 --oneline --decorate --graph
qb = "!qb(){ git refresh && git checkout -b aei/PPN-$@; }; qb"
qc = "!qc(){ git checkout aei/PPN-$@; }; qc"
qa = "!qa(){ git refresh && git branch --remote | grep $@ | sed 's/origin\\///' | xargs git checkout && git pull --rebase && git rebase master; }; qa"
@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);
@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"

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:

Linux users/groups/permissions cheatsheet

Add user

sudo useradd -m peter
sudo passwd peter

groupadd myAppUsers

sudo usermod -a -G peter myAppUsers