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
export class Log { | |
private static getTime() { | |
const date = new Date() | |
return `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}]` | |
} | |
static d(_: unknown) { | |
const message = `${this.getTime()} [debug] ${_}` | |
console.log(message) | |
} | |
static i(_: unknown) { |
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
#!/usr/bin/env bash | |
# ---------------------------------------------------------------------------- | |
# script.sh: Bash script template with argument parsing | |
# | |
# Author: Raphael Tang <[email protected]> | |
# ---------------------------------------------------------------------------- | |
# Dependencies: | |
# - dependency1 | |
# - dependency2 |
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
#!/usr/bin/env ts-node | |
import assert from "assert"; | |
import fs from "fs"; | |
import readline from "readline"; | |
const argv = process.argv.slice(2); | |
const argFileName = argv[0]; | |
function error(msg: string) { |
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
import { | |
useContext, | |
createContext, | |
type ReactNode, | |
type Provider as ReactProvider, | |
} from 'react' | |
/** | |
* Utility context builder which streamlines the context | |
* building and exposing API. |
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 safe<P extends ReadonlyArray<unknown>, R>( | |
func: (...params: P) => R | |
): (...params: P) => [R, null] | [null, unknown] { | |
return (...params: P) => { | |
try { | |
return [func(...params), null]; | |
} catch (e) { | |
return [null, e]; | |
} | |
}; |
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 ghq-repo --description 'Navigate to remote repository' | |
set path (ghq list --full-path --bare | fzf --delimiter / --with-nth -1 --preview 'echo {}' --preview-window down:2) | |
if not test -z "$path" | |
cd "$path" | |
end | |
end |