Skip to content

Instantly share code, notes, and snippets.

View hanksudo's full-sized avatar
:octocat:
Follow your passion.

Hank Wang hanksudo

:octocat:
Follow your passion.
View GitHub Profile
@hanksudo
hanksudo / co.go
Created January 23, 2024 07:25
coroutine experiment in python and go
package main
import (
"fmt"
"time"
)
func a() string {
fmt.Println("b")
go func() {
@hanksudo
hanksudo / google-oauth2.md
Last active June 27, 2023 08:37
Get access token from Google OAuth2
  1. Create OAuth client ID from Google Credentials
  2. Request OAuth on browser

I use business.manage as scope here, change to yours

https://accounts.google.com/o/oauth2/auth?client_id=<CLIENT_ID>&redirect_uri=http://localhost&scope=https://www.googleapis.com/auth/business.manage&access_type=offline&response_type=code

If success, you will get a code from the url.

@hanksudo
hanksudo / app.js
Created October 20, 2022 14:57
React (standalone)
'use strict';
function App(props) {
return <h1>Hello, world!</h1>
}
ReactDOM.render(<App />, document.querySelector('#root'));
@hanksudo
hanksudo / download_all_gists.sh
Created September 15, 2022 02:55
Download all public gists with gh command line
#!/bin/sh
gh api gists | jq -r '.[] | select(.public == true) | .files[].raw_url' | while read -r row ; do
curl -sO "$row"
done
@hanksudo
hanksudo / promise.race.js
Last active December 6, 2021 02:57
nodejs promise race
let promiseA = new Promise((resolve) => {
const timeout = 100 + Math.floor(Math.random() * 1900)
setTimeout(() => resolve('A'), timeout);
console.log('A timeout', timeout)
})
let promiseB = new Promise((resolve) => {
const timeout = 100 + Math.floor(Math.random() * 1900)
setTimeout(() => resolve('B'), timeout);
console.log('B timeout', timeout)
@hanksudo
hanksudo / combineAndKeepOrder.go
Created August 18, 2021 13:26
(go) combine two array and keep order
package main
import "log"
func main() {
result := combineAndKeepOrder([]string{"a", "b", "c"}, []string{"c", "a", "d"})
log.Println(result, testEq(result, []string{"c", "b", "a", "d"}))
result = combineAndKeepOrder([]string{}, []string{"c", "a", "d"})
log.Println(result, testEq(result, []string{"c", "a", "d"}))
@hanksudo
hanksudo / remove-storyboard.md
Last active December 8, 2020 03:23
Initial iOS project without Storyboard (remove storyboard)
  1. Remove Main.storyboard file
  2. Remove Main interface in Deployment Info

Screen Shot 2020-12-08 at 12 11 07

  1. Remove UISceneStoryboardFile key in Info.plist
UISceneStoryboardFile
@hanksudo
hanksudo / loopback.md
Created November 4, 2020 13:28
Add/remove loopback alias IPs on macOS
# add 
sudo ifconfig lo0 alias 127.0.0.2

# revert
sudo ifconfig lo0 -alias 127.0.0.2

Terraform note

example.tf

provider "aws" {
  profile    = "default"
  region     = "us-east-1"
}