This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
) | |
// MyList is string slice | |
type MyList []string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
) | |
var ( | |
file = flag.String("file", "", "file-name") | |
count = flag.Int("count", 2, "count params") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
) | |
var ( | |
file = flag.String("file", "", "file-name") | |
count = flag.Int("count", 2, "count params") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
fmt.Println("len", len(os.Args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
a := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} | |
b := make([]*int, 10) | |
for i, v := range a { | |
b[i] = &v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Be careful if you are adding user to docker group. | |
1. As a root, create a file (owner root and group root) | |
$ touch /etc/foo | |
$ ls -l /etc/foo | |
-rw-r--r-- 1 root root 0 Dec 5 17:40 /etc/foo | |
2. Login as a non-root user belongs to docker group. In my example its user u1. | |
$ id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Modify /etc/ssh/sshd_config | |
ClientAliveInterval 120 | |
ClientAliveCountMax 720 | |
This will not kick you off even if you are inactive for 24 hours. After that it will kick you out. | |
$ sudo service ssh reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Take a backup of docker.service file. | |
$ cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.orig | |
2. Modify /lib/systemd/system/docker.service to tell docker to use our own directory | |
instead of default /var/lib/docker. In this example, I am using /p/var/lib/docker | |
Apply below patch. | |
$ diff -uP -N /lib/systemd/system/docker.service.orig /lib/systemd/system/docker.service | |
--- /lib/systemd/system/docker.service.orig 2018-12-05 21:24:20.544852391 -0800 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am on Ubuntu 16.04.5 LTS. | |
$ lsb_release -a | |
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 16.04.5 LTS | |
Release: 16.04 | |
Codename: xenial | |
I wanted to install latest protoc (which at the time of writing this is version 3.6.1). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
const BufferedChLen = 1024 | |
func consumer() chan<- int { |
NewerOlder