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 / send_smart_contract_tokens.go
Last active March 9, 2023 11:59
Send tokens to an address (golang)
package main
import (
"context"
"fmt"
"log"
"math"
"math/big"
"time"
@canhlinh
canhlinh / send_eth_transaction.go
Created June 11, 2018 02:00
Send ether transaction
package main
import (
"context"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
@canhlinh
canhlinh / proxy_buffer.go
Last active August 13, 2017 04:19
Buffered reader and writer
func NewBufferQueue() *BufferQueue {
return &BufferQueue{
Q: make(model.Queue, 100),
quitRr: make(chan bool, 1),
quitWr: make(chan bool, 1),
W: &sync.WaitGroup{},
}
}
type BufferQueue struct {
[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
@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"
@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 / 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 / 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 / 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 / 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)