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 / 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 / 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 / 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 / git-tips.md
Last active July 2, 2018 20:41
Git tips

log

git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes ago'
git log --pretty=oneline --until='5 minutes ago'
git log --pretty=oneline --author=<your name>
git log --pretty=oneline --all
git log --all --pretty=format:"%h %cd %s (%an)" --since='7 days ago'
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
@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 / copy.go
Last active July 2, 2018 20:44
True file copy
package main
import (
"fmt"
"io"
"os"
)
//func main() {
// fmt.Printf("Copying %s to %s\n", os.Args[1], os.Args[2])
@akovardin
akovardin / buffer.go
Last active July 2, 2018 20:46
Lock free storage?
package buffer
import (
"time"
storage "github.com/propellerads/user_data/mockstorage"
)
type Item struct {
ip int64