Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / gist:5e97e2d61f766e868ba74a081c9717d5
Created May 12, 2017 10:18 — forked from williballenthin/gist:ee0335a6826ce55ece2d
Methods for fetching structure fields in Go (golang)
package main
import "log"
import "time"
import "reflect"
// suggested via http://stackoverflow.com/a/8363629/87207
func trace(s string) (string, time.Time) {
log.Println("START:", s)
return s, time.Now()
/*
Copyright (c) 2016, Nitin Gode
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
@smallnest
smallnest / rpc.go
Created June 2, 2017 03:11 — forked from siddontang/rpc.go
a simple rpc test
package main
import (
"bytes"
"encoding/gob"
"reflect"
)
func RemoteOnline(id uint64) (uint64, string) {
return id, "abc"
#!/usr/bin/env bash
#
# Auto install latest kernel for TCP BBR
#
# System Required: CentOS 6+, Debian7+, Ubuntu12+
#
# Copyright (C) 2016-2017 Teddysun <[email protected]>
#
# URL: https://teddysun.com/489.html
#
#!/usr/bin/env bash
#
# Auto install latest kernel for TCP BBR
#
# System Required: CentOS 6+, Debian7+, Ubuntu12+
#
# Copyright (C) 2016-2017 Teddysun <[email protected]>
#
# URL: https://teddysun.com/489.html
#
@smallnest
smallnest / sb.go
Created July 28, 2017 07:57 — forked from ice1000/sb.go
Java-like StringBuffer for Golang
package sb
import (
"fmt"
"strings"
)
const maxLength = 150
/// a java style string buffer
@smallnest
smallnest / gzip.go
Created September 25, 2017 04:20 — forked from alex-ant/gzip.go
golang: gzip and gunzip
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"log"
)
@smallnest
smallnest / client.go
Created October 9, 2017 03:56 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@smallnest
smallnest / epoll.go
Created November 28, 2017 12:22 — forked from tevino/epoll.go
Golang example for using epoll
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
@smallnest
smallnest / container.go
Created December 26, 2017 07:11 — forked from christophberger/container.go
A container in less than 60 lines of Go
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {