Skip to content

Instantly share code, notes, and snippets.

View michchan's full-sized avatar

Michael Chan L. S. michchan

View GitHub Profile
@michchan
michchan / .eslintignore
Last active October 27, 2020 10:41
.eslintignore file for common use case
# Package manager files
**/node_modules/*
**/package-lock.json
**/yarn.lock
# Build/executable files
**/build/*
**/bundles/*
**/dist/*
**/bin/*
@michchan
michchan / .stylelintrc-styled-components.jsonc
Last active October 27, 2020 10:18
.stylelintrc file for Styled-Components project
/*
DevDependencies:
stylelint
stylelint-processor-styled-components
stylelint-config-styled-components
stylelint-config-standard
*/
{
"processors": ["stylelint-processor-styled-components"],
"extends": [
@michchan
michchan / package-scripts.jsonc
Last active October 28, 2020 08:31
Useful npm scripts setup on package.json for Node/TypeScript/React projects
{
// React / Node project
"clearbuildcache": "rm -rf ./build",
// source-map-explorer
"analyze": "source-map-explorer 'build/static/js/*.js'",
// Eslint
"eslint": "eslint --ext .js,.jsx,.ts,.tsx .",
"eslint:fix": "npm run eslint -- --fix",
// Stylelint
"stylelint": "stylelint 'src/**/*.{js,jsx,ts,tsx}'",
@michchan
michchan / move_inline_comment_behind_statement_to_above.md
Last active October 21, 2020 11:04
Some search-and-replace snippets for fixing eslint problems

1. "line-comment-position": "above"

Search:

(\s+)([a-zA-Z0-9])(.+)([a-zA-Z0-9,;]) // (.+)

Replace:

$1// $5
$1$2$3$4

2. "prefer-destructuring"

Search:

@michchan
michchan / tabToSpaceMacOSX.sh
Last active October 17, 2020 11:26
Replace indentation tabs to spaces, 4-to-2 spaces
# Reference:
# https://stackoverflow.com/questions/11094383/how-can-i-convert-tabs-to-spaces-in-every-file-of-a-directory/11094422
# http://azaleasays.com/2014/03/07/os-x-sed-does-not-recognize-tab-character/
# "\( -iname \*.ts -o -iname \*.tsx -o -iname \*.js \)" means filtering only .ts .tsx, or .js files
# Tab to space
# * Press Ctrl+V and Tab to replace "\t" on Mac
find ./YOUR_PATH -type f \( -iname \*.ts -o -iname \*.tsx -o -iname \*.js \) -exec sed -i '' -E 's/\t/ /g' {} \;
@michchan
michchan / world-indices-timeseries-IndicesByPeriod-GSI.csv
Last active October 16, 2020 09:32
DynamoDB IndicesByPeriod GSI design for World indices timeseries
GSIHash time symbol name lastPrice
PERIOD 2020-10-16T07:41:02.281Z ^HSI HANG SENG INDEX 24347.65
PERIOD 2020-10-16T07:41:02.281Z ^IXIC NASDAQ Composite 11713.87
PERIOD 2020-10-16T07:41:02.281Z ^DJI Dow Jones Industrial Average 28494.20
@michchan
michchan / world-indices-timeseries-base-table.csv
Last active October 16, 2020 08:59
DynamoDB base table design for World indices timeseries
symbol (PK) time name lastPrice change changeRate
^HSI 2020-10-16T07:41:02.281Z HANG SENG INDEX 24347.65 189.11 0.78
^IXIC 2020-10-16T07:41:02.281Z NASDAQ Composite 11713.87 -54.86 -0.47
^DJI 2020-10-16T07:41:02.281Z Dow Jones Industrial Average 28494.20 -19.80 -0.07
@michchan
michchan / vscode-settings.json
Last active April 14, 2022 06:01
My vscode settings JSON (* based theme: Darcula)
{
"aws.samcli.location": "/usr/local/bin/sam",
"breadcrumbs.enabled": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.fontFamily": "'Inconsolata-g', Monaco, 'Courier New', monospace",
"editor.letterSpacing": 0.1,
"editor.minimap.enabled": false,
"editor.quickSuggestionsDelay": 2,
"editor.quickSuggestions": {
"other": true,
@michchan
michchan / npm-install-all.js
Created March 18, 2020 10:18
Script to run npm install for all nested folders
/**
* Script to run npm install for all nested folders
*
* Reference: https://stackoverflow.com/questions/31773546/the-best-way-to-run-npm-install-for-nested-folders
*/
var fs = require('fs')
var resolve = require('path').resolve
var join = require('path').join
var cp = require('child_process')
var os = require('os')
@michchan
michchan / replaceDirNames.sh
Created February 27, 2020 05:33
Bash Script to Search and Replace Directory Names
find . -type d -name "*NameToReplace*" | while read f; do mv $f $(echo $f | sed "s/NameToReplace/ReplacedName/g"); done