Skip to content

Instantly share code, notes, and snippets.

View vaidd4's full-sized avatar

David vaidd4

  • France
View GitHub Profile
@vaidd4
vaidd4 / object-mapper.js
Last active May 24, 2019 13:57
Map to object with a mapping description
const f1 = a => a + 1
const f2 = (...args) => args.join(', ')
const src = { a: 1, b: 2, c: 3, d: 4, e: 5 }
const mapDesc = [
'a',
['b', 'f'],
[[f1, 'c'], 'g'],
[[f2, 'd', 'e'], 'h']

Git orphan branches & working trees

Creating an ophan branch

This command will create a branch with no parent (no commit history) on a repo.

git checkout --orphan <new-branch>

Managing working trees

Manage folders linked to others branches of your repo. Do not confuse them with git submodules which are links to different repositories.

@vaidd4
vaidd4 / git-worktree-cheatsheet.md
Last active January 24, 2024 15:58
A cheat sheet for Git Worktrees

Git Worktree Cheatsheet

Documentation

Setup a folder inside a repo with a specific commit of that repo.

Create a new worktree

git worktree add [-f] [--detach] [--checkout] [--lock] [-b ]  []
@vaidd4
vaidd4 / cbtoasync.js
Created January 12, 2021 22:50
Callback-based function to promise-based function.
function cbtoasync(fncb, ...params) {
return new Promise((res, rej) => {
fncb(...params, (...data) => {res(...data)})
})
}
function tr_cbtoasync(fncb) {
return (...data) => cbtoasync(fncb, ...data)
}
@vaidd4
vaidd4 / goldmark-cli.go
Created February 10, 2022 23:08
Markdown to Html Converter - Basic command line tool using https://github.com/yuin/goldmark
package main
import (
"bufio"
"github.com/yuin/goldmark"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)