Skip to content

Instantly share code, notes, and snippets.

View cftang0827's full-sized avatar
🏠
Playing~

Paul Tang cftang0827

🏠
Playing~
View GitHub Profile
@cftang0827
cftang0827 / promises
Created February 28, 2020 02:36 — forked from kuanhsuh/promises
callback vs promises
function logWord(word){
setTimeout(function() {
console.log(word)
}, Math.floor(Math.random() * 100) + 1
// return value between 1 ~ 100
)
}
function logAll(){
logWord("A")
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
var sumPool int
@cftang0827
cftang0827 / docker-compose-yml-sample-3.yml
Created January 8, 2020 05:35
docker compose circleci sample 3
version: "3"
services:
db:
image: mysql:5.7
restart: always
container_name: db
ports:
- "3306:3306"
environment:
@cftang0827
cftang0827 / docker-compose-yml-sample-2.yml
Created January 8, 2020 05:33
docker-compose-circleci-sample-2
version: "3"
services:
db:
image: mysql:5.7
restart: always
container_name: db
ports:
- "3306:3306"
environment:
@cftang0827
cftang0827 / docker-compose-yml-sample.yml
Created January 8, 2020 05:31
docker-compose yaml sample for circleci building
version: "3"
services:
db:
image: mysql:5.7
restart: always
container_name: db
ports:
- "3306:3306"
environment:
@cftang0827
cftang0827 / example-circleci-config.yml
Created January 8, 2020 05:29
example circleci config
version: 2
jobs:
build:
working_directory: /test_app
parallelism: 1
docker:
- image: docker/compose:1.25.0-rc2-debian
steps:
- run:
name: Configure environment
version: 2
jobs:
build:
working_directory: ~/circleci-demo-ruby-rails
# Primary container image where all commands run
docker:
- image: circleci/ruby:2.4.1-node
environment:
@cftang0827
cftang0827 / remove_empty_string.py
Created August 30, 2019 05:53
The simple script to replace empty value in json to null
def remove_empty_string(dic):
"""
Replace empty string to None
"""
for e in dic:
if isinstance(dic[e], dict):
dic[e] = remove_empty_string(dic[e])
if (isinstance(dic[e], str) and dic[e] == ""):
dic[e] = None
if isinstance(dic[e], list):
@cftang0827
cftang0827 / gopsutil_example.go
Created April 26, 2019 08:24
The example of gopsutil, get the info of CPU memory and disk
import (
"fmt"
"net/http"
"os"
"time"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
@cftang0827
cftang0827 / gist:5b7430f9ea4364944ff3f9a4eaf70270
Created December 26, 2018 03:43
get wheel package from pip remote server
pip wheel --wheel-dir=./ numpy==1.12 --no-deps