Skip to content

Instantly share code, notes, and snippets.

View mantyr's full-sized avatar
🌴
study: coffee and woodwork

Oleg Shevelev mantyr

🌴
study: coffee and woodwork
View GitHub Profile
@mantyr
mantyr / run.sh
Last active August 29, 2015 14:23
How to understand the delay on time?
$ go get github.com/fiam/gounidecode/unidecode
$ go get github.com/rainycape/unidecode
$ time go test github.com/fiam/gounidecode/unidecode
ok github.com/fiam/gounidecode/unidecode 0.039s
real 0m9.629s
user 0m1.621s
sys 0m1.647s
@mantyr
mantyr / gentoo-locale-ru_RU.utf8.sh
Last active April 12, 2016 22:14
Set locale in Gentoo, utf8
# locale-gen
# eselect locale set ru_RU.utf8
# . /etc/profile
eselect сам создаст /etc/env.d/02locale и внесёт в него нужные данные.
. /etc/profile обновит настройки текущей консоли
www.oldnix.org/rus-gentoo-linux/ чуть более объёмная статья на эту тему без которой можно обойтись двумя строчками.
@mantyr
mantyr / linux_bash_commands.sh
Last active February 15, 2017 13:41
Linux bash commands
// удалить файлы старше 3 дней
find -type f -mtime +3 -exec rm -f {} \;
// для случаев когда удалённый ftp сервер работает с ошибками, а файлы получить как-то нужно:
// http://unix.stackexchange.com/questions/2525/sync-a-local-directory-with-a-remote-directory-in-linux
curlftpfs -r -s ftp.foobar.com /foo
rsync -a /foo/ /bar
umount /foo
// iTerm v2
@mantyr
mantyr / get_dir_program_bin.go
Last active April 16, 2016 15:22
Get directory of binary program
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func main() {
@mantyr
mantyr / Git.sh
Last active April 23, 2016 03:04
Git - tips and tricks
// изменить автора последнего коммита
git commit --amend --author=username@example.com
// запушить на github если там этот коммит уже был
git push origin master -f
// Изменение коммитов в Git - https://habrahabr.ru/post/201922/
Если нужно обновить свой форк данными из источника:
1. идём в свой форк, находим справа над списком файлов кнопку Compare
@mantyr
mantyr / go_len_chan.go
Last active August 5, 2021 15:34
Golang len(chan) - размер загруженности очереди (chan) не читая из неё
package main
import "fmt"
func main() {
c := make(chan int, 100)
for i := 0; i < 34; i++ {
c <- 0
}
fmt.Println(len(c)) // print "34"
@mantyr
mantyr / go_chunk_ip_mask.go
Created April 23, 2016 17:37
Golang - разбить ip диапазон на 4 части
// http://play.golang.org/p/JlYJXZnUxl
package main
import (
"fmt"
"net"
)
func inet_aton(ip string) (ip_int uint32) {
ip_byte := net.ParseIP(ip).To4()
@mantyr
mantyr / go_delete_old_key_map.go
Created June 1, 2016 17:36
Удаляем старые элементы в map, при этом следим что бы элементов было не больше N штук
// https://play.golang.org/p/sopEgcwRZC
package main
import (
"fmt"
"sync"
)
type Map struct {
sync.RWMutex
@mantyr
mantyr / golang_bench_diff.sh
Created August 19, 2016 09:36
Сравниваем бенчмарки в Golang
$ go test -run NONE -bench . -gcflags -ssa=0 > nossa.txt
testing: warning: no tests to run
$ go test -run NONE -bench . -gcflags -ssa=1 > ssa.txt
testing: warning: no tests to run
$ benchcmp nossa.txt ssa.txt
benchmark old ns/op new ns/op delta
BenchmarkAdd-4 2.45 11.4 +365.31%
https://github.com/golang/go/issues/15925
@mantyr
mantyr / gist:832eaa18042494273519af1cac166dc4
Created August 22, 2016 00:14
World of Tanks - как удалить:)
How To Uninstall CrossOver Mac - https://www.youtube.com/watch?v=lWS65hceXt0
Все обновления и временные файлы хранятся тут: /Users/$user/Documents/World_of_Tanks