Skip to content

Instantly share code, notes, and snippets.

View yifeiyin's full-sized avatar
🧼

Yifei Yin yifeiyin

🧼
View GitHub Profile
@yifeiyin
yifeiyin / index.mjs
Created November 6, 2022 19:13
commit message parsing using magic-regexp https://regexp.dev
import assert from 'node:assert';
import {
createRegExp,
exactly,
oneOrMore,
char,
wordChar,
whitespace,
maybe,
} from 'magic-regexp';
@yifeiyin
yifeiyin / publish-gh-page.yml
Created August 4, 2021 03:31
Put this file in .github/workflows/publish-gh-page.yml
name: Publish to GitHub Page
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
@yifeiyin
yifeiyin / cert-helpers
Last active July 24, 2021 05:56
Helper functions for creating your own CA and signed certificates
#!/bin/bash
# See: https://wiki.yyin.me/guides/cert
function create-key-pair() {
if [ $# -ne 1 ]; then echo 'Args: key pair name'; return; fi
openssl genrsa -out $1.key 2048
}
function create-self-signed-cert() {
@yifeiyin
yifeiyin / relative.js
Created January 19, 2021 04:59
Format relative date
/*
* [Relative Date Internationalization In JavaScript | Web Dev Simplified Blog](https://blog.webdevsimplified.com/2020-07/relative-time-format/)
*
*/
const formatter = new Intl.RelativeTimeFormat(undefined, {
numeric: "auto",
})
const DIVISIONS = [
@yifeiyin
yifeiyin / mymediadl
Last active November 13, 2020 06:24
Download MyMedia Video
#!/bin/sh
# Usage:
# $ mymediadl URL [FILE_NAME]
mymediadl() {
URL=$(echo "$1" | awk -F '/' '{ print $NF }')
echo "Downloading $URL"
NAME="$2"
if [[ -z $NAME ]]; then
@yifeiyin
yifeiyin / pintos-gdb-macros.md
Created July 27, 2020 20:21
Pintos, GDB, Load Macros
  1. Create a file at pintos/gdb-c with one line as the content:
gdb -x /pintos/src/misc/gdb-macros $@
  1. In the pintos shell, make the new file executable:
$ chmod +x /pintos/gdb-c
@yifeiyin
yifeiyin / graph.txt
Created July 9, 2020 02:33
Generate React Components Dependency Graph
https://www.netlify.com/blog/2018/08/23/how-to-easily-visualize-a-projects-dependency-graph-with-dependency-cruiser/
npm i -g dependency-cruiser
brew install graphviz
depcruise --exclude "^node_modules" --output-type dot src | dot -T svg > dependencygraph.svg
@yifeiyin
yifeiyin / .devcontainer_slash_devcontainer.jsonc
Last active February 16, 2021 01:52
Debug pintos with VSCode
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.122.1/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
@yifeiyin
yifeiyin / uninstall_shell_integration.sh
Created June 8, 2020 19:51 — forked from victor-torres/uninstall_shell_integration.sh
Uninstalling shell integration from iTerm 2
#!/bin/bash
function die() {
echo "${1}"
exit 1
}
which printf > /dev/null 2>&1 || die "Shell integration requires the printf binary to be in your path."
which sed > /dev/null 2>&1 || die "Shell integration requires the sed binary to be in your path."
@yifeiyin
yifeiyin / download-and-run.sh
Created June 3, 2020 04:50
Java checkstyle using google format settings
curl \
https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.33/checkstyle-8.33-all.jar \
-o /tmp/deleteme-checkstyle-8.33-all.jar -sL
curl \
https://github.com/checkstyle/checkstyle/raw/ec015cd3529ddbb2005639782e1995e46c0a05d1/src/main/resources/google_checks.xml \
-o /tmp/deleteme-google_checks.xml -sL
java \
-jar /tmp/deleteme-checkstyle-8.33-all.jar \