Skip to content

Instantly share code, notes, and snippets.

@akovardin
akovardin / README.md
Created March 6, 2018 23:12 — forked from rjeczalik/README.md
Go, multiple packages and coveralls.io

Go, multiple packages and coveralls.io

Single profile for single Go package

For Go projects that consist of only one package, the following Travis configuration is enough to get started with coveralls.io. You may want to encrypt your $COVERALLS_TOKEN via Travis encryption keys though.

language: go
go:
 - 1.3.1
@akovardin
akovardin / testtip.go
Last active July 2, 2018 20:41
Test tips
package resources
import (
"net/http/httptest"
"strings"
"testing"
mocket "github.com/Selvatico/go-mocket"
"github.com/jinzhu/gorm"
"github.com/labstack/echo"
@akovardin
akovardin / md5-example.go
Last active July 26, 2018 17:31 — forked from sergiotapia/md5-example.go
Go MD5 string
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@akovardin
akovardin / tumblr-download.go
Last active July 2, 2018 20:40 — forked from indraniel/tumblr-download.go
Go and tumblr
/*
This is a go program to download pictures from a tumblr blog page.
To Build:
go build -o tumblr-download tumblr-download.go
To Run:
# download the photos on the first page of tumblr blog
@akovardin
akovardin / webcam.go
Last active July 2, 2018 20:41
Go and webcam
// Example program that uses blakjack/webcam library
package main
import (
"fmt"
"os"
"github.com/blackjack/webcam"
)
@akovardin
akovardin / error.go
Last active July 2, 2018 20:40
Errors are values
type reader struct {
r io.Reader
err error
}
func (r *reader) read(data interface{}) {
if r.err == nil {
r.err = binary.Read(r.r, binary.BigEndian, data)
}
}
@akovardin
akovardin / page_size.go
Last active July 2, 2018 20:42
OS page size
b := make([]byte, os.Getpagesize())
@akovardin
akovardin / ulimit.md
Last active July 2, 2018 20:43
Ulimit
  1. Check sysctl file-max limit:
$ cat /proc/sys/fs/file-max

If the limit is lower than your desired value, open the /etc/sysctl.conf and add this line at the end of file:

fs.file-max = 65536
@akovardin
akovardin / smtp-gmail-send.go
Last active February 18, 2019 10:02 — forked from jpillora/smtp-gmail-send.go
Send email using Go via GMail
package main
import (
"log"
"net/smtp"
)
func main() {
send("hello there")
}
@akovardin
akovardin / trap.md
Last active July 2, 2018 20:50
Its a Go trap