Setup a folder inside a repo with a specific commit of that repo.
git worktree add [-f] [--detach] [--checkout] [--lock] [-b ] []
| package main | |
| import ( | |
| "bufio" | |
| "github.com/yuin/goldmark" | |
| "os" | |
| ) | |
| func main() { | |
| scanner := bufio.NewScanner(os.Stdin) |
| function cbtoasync(fncb, ...params) { | |
| return new Promise((res, rej) => { | |
| fncb(...params, (...data) => {res(...data)}) | |
| }) | |
| } | |
| function tr_cbtoasync(fncb) { | |
| return (...data) => cbtoasync(fncb, ...data) | |
| } |
Setup a folder inside a repo with a specific commit of that repo.
git worktree add [-f] [--detach] [--checkout] [--lock] [-b ] []
This command will create a branch with no parent (no commit history) on a repo.
git checkout --orphan <new-branch>
Manage folders linked to others branches of your repo.
Do not confuse them with git submodules which are links to different repositories.
| 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'] |
| let obj = { a: 'a', b: null, undefined: 'undef', null: 'nil' } | |
| obj['a'] // 'a' | |
| obj[obj.b] // 'nil' | |
| obj[obj.c] // 'undef' (obj.c is undefined) | |
| obj[obj] // undefined | |
| // Can be used for making conditions with objects |
| const http = require('http') | |
| const url = require('url') | |
| const path = require('path') | |
| const fs = require('fs') | |
| const PORT = parseInt(process.argv[2]) || 8888 | |
| http.createServer(function(req, res) { | |
| const uri = url.parse(req.url).pathname | |
| const filename = path.join(process.cwd(), uri) |
| /** | |
| * Pick the specified properties of an object | |
| * | |
| * @param obj | |
| * @param {Array<Array<string> | string>} keys | |
| * @returns {{}} | |
| */ | |
| function pick (obj, keys) { | |
| return keys.reduce((sum, k) => (Array.isArray(k) ? sum[k[1]] = obj[k[0]] : sum[k] = obj[k], sum), {}) | |
| } |
| /** | |
| * Simple logging on an observable, without altering the subscription. | |
| * | |
| * @param {Observable<any>} obs - Observable (RxJS) | |
| * @param success - success message | |
| * @param failure - error message | |
| * @returns {Observable<any>} | |
| */ | |
| function logObservable (obs, success, failure) { | |
| if (success) { |
| 'use strict'; | |
| const parseMs = require('parse-ms'); | |
| const plur = require('plur'); | |
| const units = [{ s: 'y', l: 'year' }, | |
| { s: 'd', l: 'day' }, | |
| { s: 'h', l: 'hour' }, | |
| { s: 'm', l: 'minute' }, | |
| { s: 's', l: 'second' }, | |
| { s: 'ms', l: 'millisecond' }]; |