Skip to content

Instantly share code, notes, and snippets.

Arjan Einbu aeinbu

Block or report user

Report or block aeinbu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View add-disk-in-linux.md

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:

View running-docker-images-cheatsheet.md

Running docker images cheatsheet

Create a container (and start it)

The container in the samples will be named "debby"

docker run -dit -v /Users/arjan/dev:/host --name debby debian:latest /bin/bash
  • -dit flags - These just work, dont ask ;)
    • d for detached
    • i for interactive
@aeinbu
aeinbu / Materializer.cs
Last active Jul 28, 2019
Create concrete types from interfaces in runtime
View Materializer.cs
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
namespace typebuilder_test
{
public class Materializer
{
private readonly ModuleBuilder _moduleBuilder;
View App.svelte
<script>
import Component2 from "./Component2.svelte"
</script>
<Component2></Component2>
<Component2></Component2>
View Run SQL Server in docker.MD
@aeinbu
aeinbu / chain.js
Created May 14, 2019
Helper to chain method calls while we're waiting for |> (the js pipe operator)
View chain.js
const chain = (obj, op = obj => obj, ...restOps) => restOps.length > 0
? chain(op(obj), ...restOps)
: op(obj);
@aeinbu
aeinbu / .gitconfig
Last active Jan 23, 2020
Some practial aliases for Git
View .gitconfig
[alias]
refresh = !git fetch --all --prune && git checkout master && git pull --rebase && git lastbranch
amend = commit --amend --no-edit
lastbranch = checkout @{-1}
qlog = log -10 --oneline --decorate --graph
qbranch = "!qb(){ git checkout -b my-branch-prefix/$@; }; qb"
qcheckout = "!qc(){ git checkout my-branch-prefix/$@; }; qc"
qa = "!qa(){ git refresh && git branch --remote | grep $@ | sed 's/origin\\///' | xargs git checkout && git pull --rebase; }; qa"
@aeinbu
aeinbu / javascript.json
Last active May 10, 2019
Snippets to aid debugging collections transformations (map/filter/reduce) and promises
View javascript.json
{
"debug-map":{
"prefix": "debug-map",
"body": [
".map(res => { console.log(\"DEBUG-MAP ***\", res); return res;})"
]
},
"debug-reduce":{
"prefix": "debug-reduce",
"body": [
@aeinbu
aeinbu / combinePredicates.js
Last active Aug 14, 2018
Combine predicates for filtering
View combinePredicates.js
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 / wrapInReadOnlyProxy.js
Last active Jul 26, 2017
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.
View wrapInReadOnlyProxy.js
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]);
}
You can’t perform that action at this time.