This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bufio" | |
| "github.com/yuin/goldmark" | |
| "os" | |
| ) | |
| func main() { | |
| scanner := bufio.NewScanner(os.Stdin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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), {}) | |
| } |
NewerOlder