Skip to content

Instantly share code, notes, and snippets.

View canhlinh's full-sized avatar
🇻🇳
Working from home

Kyo Nguyen canhlinh

🇻🇳
Working from home
View GitHub Profile
@canhlinh
canhlinh / gist:5bf404d155741195382847e942c61a5d
Created July 11, 2016 03:53 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@canhlinh
canhlinh / gist:bed2e9d66e46831a7f5f2b46cb5a132f
Created July 15, 2016 04:14 — forked from imkarthikk/gist:772f86858f90efa55687
Graphite, UWSGI and nginx setup on Ubuntu 14.04
# update packages
sudo apt-get update
# install python and graphite dependencies
sudo apt-get install -y python python-dev python-virtualenv libevent-dev python-pip python-cairo python-django-tagging python-twisted python-memcache python-pysqlite2
# install web server
sudo apt-get install -y nginx uwsgi uwsgi-plugin-python
# install postgresql and dependencies
@canhlinh
canhlinh / jwtRS256.sh
Created August 18, 2016 02:32 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@canhlinh
canhlinh / Leak goroutines
Created September 9, 2016 09:06
Leak goroutines
package main
import (
"fmt"
"runtime"
// "runtime/debug"
)
func foo(m *runtime.MemStats) {
runtime.ReadMemStats(m)
@canhlinh
canhlinh / demo_timeout_transaction.go
Created December 5, 2016 10:42
Try update a table has transaction not commited
package main
import (
"database/sql"
"time"
"log"
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
@canhlinh
canhlinh / health_check.go
Created April 18, 2017 14:13
[GO] Health check apns http2 , connection death after a longtime no send push notification
package main
import (
"crypto/tls"
"log"
"math/rand"
"syscall"
"time"
"github.com/canhlinh/log4go"
@canhlinh
canhlinh / linux_command.md
Last active June 26, 2020 02:09
Usefull linux comand

Count how many connections are made by a process

netstat -natp | grep "{process name}" | wc -l

Show path of current active processes

ps -ef

*Gen letencrypt cert

@canhlinh
canhlinh / video_proxy.service
Created June 24, 2017 04:14
Systemctl for golang binary
[Unit]
Description= Video Streaming Proxy
[Service]
LimitNOFILE=64000
User=ubuntu
Group=ubuntu
Restart=always
WorkingDirectory=/opt/video-proxy
ExecStart=/opt/video-proxy/proxy_streaming
@canhlinh
canhlinh / benchmark_primary_key_test.go
Last active July 5, 2017 18:11
Benchmark performance between varying primary_key types mysql.
package main
import (
"bytes"
"database/sql"
"encoding/base32"
"encoding/binary"
"math/rand"
"testing"
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
ExecStop=/usr/bin/mongod -f /etc/mongodb.conf --shutdown
Restart=always
User=mongodb