Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / test.js
Created Jan 9, 2020
Promise + Async/Await Test1
View test.js
console.log(1);
(async () => {
const promiseF = new Promise((resolve, reject) => {
console.log(2)
setTimeout(()=>{
try {
console.log(3)
resolve()
console.log(4)
} catch (error) {
@ryanhanwu
ryanhanwu / test.js
Created Oct 31, 2019
how to load environment variable from dotenv with link break?
View test.js
// MY_KEY=test\ntest2\ntest3
JSON.parse(`"${process.env.MY_KEY}"`)
/*
test
test2
test3
*/
@ryanhanwu
ryanhanwu / Brewfile
Last active Sep 1, 2022
New Mac Setup Script 2021
View Brewfile
# Taps
tap 'homebrew/cask-fonts'
tap 'homebrew/cask-versions'
tap 'heroku/brew'
# Install CLI Tools
## Shell Utilities
brew 'coreutils'
brew 'findutils'
brew 'autojump'
@ryanhanwu
ryanhanwu / githistory.sh
Created Oct 1, 2019
Change git history names
View githistory.sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@ryanhanwu
ryanhanwu / Dockerfile
Created Feb 26, 2019
muti-stage build for node+babel+docker
View Dockerfile
# common base image for development and production
FROM node:10.11.0-alpine AS base
WORKDIR /app
# dev image contains everything needed for testing, development and building
FROM base AS development
COPY package.json yarn.lock ./
# first set aside prod dependencies so we can copy in to the prod image
@ryanhanwu
ryanhanwu / cloudSettings
Last active Apr 27, 2021
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2021-04-27T14:20:49.226Z","extensionVersion":"v3.4.3"}
View inArray.asp
<%
Function InArray(Needle, Haystack)
Dim i, x
InArray = False
For i = 0 To Ubound(Haystack)
If IsArray(Needle) = True Then
For x = 0 To Ubound(Needle)
If Trim(Haystack(i)) = Trim(Needle(x)) Then
InArray = True
View test.sh
aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]"
View filepreview.js
/*
filepreview : A file preview generator for node.js
*/
var child_process = require('child_process');
var crypto = require('crypto');
var async = require('async');
var path = require('path');
View append.js
fs.appendFile('message.txt', 'data to append', function (err) {
if (err) throw err;
console.log('Saved!');
});