Skip to content

Instantly share code, notes, and snippets.

View mantyr's full-sized avatar
🌴
Looking for a startup

Oleg Shevelev mantyr

🌴
Looking for a startup
View GitHub Profile
@mantyr
mantyr / mysql.sh
Created October 19, 2016 02:25
MySQL settings
mysql> set global max_connections = 1000;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)
@mantyr
mantyr / go_startstop.go
Last active August 22, 2016 11:03
Example start/stop/finish goroutine
package main
import (
"github.com/mantyr/startstop"
)
type Parser struct {
startstop.StartStop // Start(), Stop(), Finish(), status, err := Next(), GetStatus()
// ... other vars
@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
@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 / 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 / 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_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 / 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 / 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 / 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