For macOS
$ gpg --armor --export ${KEY_ID} | pbcopy
// Written by ChatGPT4 | |
// Dump header and body of the request. | |
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
) |
# create tmux session if not exists with specific settings. | |
function tmwork () { | |
local session=work | |
if ! tmux has-session -t ${session} >/dev/null 2>&1; then | |
tmux new-session -d -s ${session} -n misc | |
tmux new-window -t ${session}: -n backend -c ${HOME}/project/backend | |
tmux new-window -t ${session}: -n frontend -c ${HOME}/project/frontend | |
fi | |
tmux attach-session -t ${session}:backend | |
} |
// Convert HEX string into string | |
const ASCII_LENGTH = 2; | |
const UNICODE_LENGTH = 4; | |
const str2hex = (str) => Array.from(str) | |
.map((c) => c.codePointAt().toString(16).padStart(4, "0")) | |
.join(""); | |
const hex2str = (hex, length = UNICODE_LENGTH) => hex | |
.split("") |
/** | |
* Using tagged template feature to provide Scala-like text formatting feature | |
* References: | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals | |
* https://gist.github.com/jimschubert/06fea56a6d2a1e7fdbc2 | |
* | |
* e.g. stripMargin` | |
* |stripMargin | |
* |will strip extra spaces`; | |
*/ |
For macOS
$ gpg --armor --export ${KEY_ID} | pbcopy
# useradd rubyist --create-home --shell /bin/bash | |
# # packages to install rbenv and ruby-build, packages to install ruby, and packages to install gems | |
# apt-get install -y git build-essential \ | |
# libssl-dev libreadline-dev zlib1g-dev \ | |
# libxml2-dev libcurl4-openssl-dev libpq-dev libsqlite3-dev | |
# sudo su rubyist | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
cd ~/.rbenv && src/configure && make -C src | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowAllActions", | |
"Effect": "Allow", | |
"Action": "*", | |
"Resource": "*" | |
} | |
] |
const Octokit = require('@octokit/rest') | |
const { addDays, format, isBefore } = require('date-fns') | |
const octokit = Octokit({ | |
auth: process.env.GITHUB_TOKEN, | |
baseUrl: 'https://api.github.com', | |
}) | |
const stopAt = new Date('2019-11-30Z') | |
let nextSprint = { |
#!/bin/bash +x | |
[ $# -lt 2 ] && echo "Usage: $(basename $0) <input path> <output filename>" >&2 && exit 1 | |
input_path=$1 | |
output_filename=$2 | |
input_dirname=$(cd $(dirname "$input_path") && pwd -P) | |
ffmpeg -i "$input_path" -vf fps=10,scale=640:-1 "$input_dirname/$output_filename.gif" |
// Type strict; couldn't find a good use case | |
// from https://stackoverflow.com/a/49894514 | |
const strictKeys = <T>(anenum: T): (keyof T)[] => | |
Object.keys(anenum).filter((k) => typeof anenum[k] === 'number') as any | |
// Only available for number enum | |
// from https://github.com/Microsoft/TypeScript/issues/17198#issuecomment-315400819 | |
const nkeys = <T>(anenum: T): string[] => | |
Object.keys(anenum).filter((k) => typeof anenum[k] === 'number') |