Skip to content

Instantly share code, notes, and snippets.

@tosone
tosone / app.go
Last active October 25, 2020 06:42
请完成其中 Tester 的 io.Reader interface 相关函数
package main
import (
"io"
"log"
"os"
"github.com/gin-gonic/gin"
)
@tosone
tosone / docker.sh
Created October 11, 2019 07:40
[docker save] #docker
#for not running docker, use save:
docker save <dockernameortag> | gzip > mycontainer.tgz
#for running or paused docker, use export:
docker export <dockernameortag> | gzip > mycontainer.tgz
#load
gunzip -c mycontainer.tgz | docker load
@tosone
tosone / bash.sh
Created August 29, 2019 02:40
[K8s]
kubectl get namespaces
kubectl get pods --namespace uaa
kubectl get pods --namespace scf
kubectl get pods --namespace stratos
kubectl describe pods uaa-0 --namespace uaa
kubectl describe pods router-0 --namespace scf
kubectl logs -f --namespace uaa uaa-0 uaa
@tosone
tosone / git.sh
Created July 21, 2019 13:50
[Initialize Script] #Bash
git config user.signingkey B48CF8424DDA96E1
git config commit.gpgsign true
git config user.email "i@tosone.cn"
git config user.name "Tosone"
@tosone
tosone / gen.sh
Last active July 21, 2019 13:40
[Mac Keys]
ssh-keygen -t rsa -b 4096 -C "i@tosone.cn" -P "" -f deploy-key
@tosone
tosone / objectid.go
Last active July 21, 2019 13:05
[Object ID] Generate MongoDB object id. #Go
package main
import (
"crypto/md5"
"crypto/rand"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"os"
@tosone
tosone / cgo.md
Last active July 21, 2019 13:11 — forked from zchee/cgo.md
[Golang CGO] #Go

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@tosone
tosone / callback.c
Last active August 16, 2019 03:22
[Callback in C] #C
#include <stdio.h>
typedef void (*callback_t)(char *);
void callback_test(char *str) {
printf("%s\n", str);
return;
}
void callback_main(callback_t cb) {
@tosone
tosone / float32642byte.go
Last active July 21, 2019 13:07
[Byte to Float] #Go
import (
"encoding/binary"
"math"
)
func Float32ToByte(float float32) []byte {
bits := math.Float32bits(float)
bytes := make([]byte, 4)
binary.LittleEndian.PutUint32(bytes, bits)
@tosone
tosone / relect.go
Last active July 21, 2019 13:09
[Golang reflect struct] #Go
package main
import (
"fmt"
"reflect"
"time"
)
func main() {
type T struct {