Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / curl.md
Created May 18, 2018 11:39 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

// https://stackoverflow.com/questions/34772012/capturing-panic-in-golang/34772516
// Log the panic under unix to the log file
//+build unix
package main
import (
"log"
"os"
@smallnest
smallnest / sysserver.go
Created June 14, 2018 09:56 — forked from mangalaman93/sysserver.go
setting low level socket options in golang (SO_PRIORITY, SO_REUSEADDR)
package main
import (
"bufio"
"fmt"
"net"
"os"
"syscall"
)
@smallnest
smallnest / Dockerfile
Created June 20, 2018 03:02 — forked from PurpleBooth/Dockerfile
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
RUN mkdir -p /go/src/github.com/purplebooth/example
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@smallnest
smallnest / gist:5a3d490562084983abc0ba7dc627744d
Created June 26, 2018 09:17 — forked from wendal/gist:4537679
演示golang转编码 (gb2312 --> utf8)
package main
import (
iconv "github.com/djimenez/iconv-go"
"io/ioutil"
"log"
"net/http"
@smallnest
smallnest / gbkbig5.go
Created June 26, 2018 09:19 — forked from 18o/gbkbig5.go
Golang GBK Big5 from/to UTF-8 转换
import (
"bytes"
"io/ioutil"
"golang.org/x/text/encoding/traditionalchinese"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
//convert GBK to UTF-8
func Decodegbk(s []byte) ([]byte, error) {
I := bytes.NewReader(s)
@smallnest
smallnest / gbkbig5.go
Created June 26, 2018 09:19 — forked from zhang0098/gbkbig5.go
Golang GBK Big5 from/to UTF-8 转换
import (
"bytes"
"io/ioutil"
"golang.org/x/text/encoding/traditionalchinese"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
//convert GBK to UTF-8
func Decodegbk(s []byte) ([]byte, error) {
I := bytes.NewReader(s)
@smallnest
smallnest / quick_sort.go
Last active June 26, 2018 11:05
golang quick_sort by goroutines
package main
import (
"fmt"
"math/rand"
"sort"
"time"
"github.com/psilva261/timsort"
)
@smallnest
smallnest / epoll.go
Created August 9, 2018 10:47 — forked from artyom/epoll.go
Using epoll from Go.
package main
import (
"log"
"os"
"syscall"
)
func main() {
f, err := os.Open("/tmp/pipe")
@smallnest
smallnest / main.go
Created August 9, 2018 10:49 — forked from wolfeidau/main.go
Epoll example in golang starting point
package main
//
// Starting point is from http://gcmurphy.wordpress.com/2012/11/30/using-epoll-in-go/
//
import (
"fmt"
"os"
"syscall"