Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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.

@smallnest
smallnest / README.markdown
Created May 15, 2018 02:30 — forked from FranklinYu/README.markdown
links for old versions of Docker for Mac (inspired by docker/for-mac#1120)

links for old versions of Docker for Mac

Deprecated

Docker provides download links in release note. They promised that

(we) will also include download links in release notes for future releases.

Note:

@smallnest
smallnest / generate_go_types.pl
Created March 5, 2018 03:39
Create go types based on mysql schema #tags: lang-go, lang-perl
#!/usr/bin/env perl
use strict;
use Getopt::Long;
use DBI;
use String::CamelCase qw(camelize decamelize wordsplit);
my $type_map = {
bigint => 'int64',
blob => 'string',
@smallnest
smallnest / go-qthtml2pdf.go
Created February 6, 2018 08:26 — forked from MrSaints/go-qthtml2pdf.go
A basic HTML to PDF converter in Golang using Qt WebEngine 5.7. For a more production-ready converter, see: http://www.athenapdf.com/
package main
import (
"flag"
"fmt"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/webengine"
"github.com/therecipe/qt/widgets"
"os"