- intro, download, install & setup
- basics, syntax
- control flow
- more types, data structures
- methods & interfaces
- concurrency
- nice to know stuff
- golang gotchas <-- especially if you are coming from python, ruby etc
- workspace
| upstream myapp { | |
| server 127.0.0.1:8081; | |
| } | |
| limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s; | |
| server { | |
| listen 443 ssl spdy; | |
| server_name _; | |
| #include <arpa/inet.h> | |
| #include <asm/byteorder.h> | |
| #include <assert.h> | |
| #include <errno.h> | |
| #include <net/ethernet.h> | |
| #include <netinet/ether.h> | |
| #include <netinet/icmp6.h> | |
| #include <netinet/ip6.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> |
System: Debian/Ubuntu/Fedora. Might work for others as well.
As mentioned here, to update a go version you will first need to uninstall the original version.
To uninstall, delete the /usr/local/go directory by:
| func main() { | |
| cmd := exec.Command("sh", "-c", "cd ../../bin/worker; ./run.sh") | |
| // some command output will be input into stderr | |
| // e.g. | |
| // cmd := exec.Command("../../bin/master_build") | |
| // stderr, err := cmd.StderrPipe() | |
| stdout, err := cmd.StdoutPipe() | |
| if err != nil { | |
| fmt.Println(err) | |
| } |
| #!/bin/bash | |
| PREFIX="$1" | |
| IFACE="$2" | |
| ip netns add jool | |
| ip link add name to_jool typ veth peer name to_world | |
| ip link set up dev to_jool | |
| ip link set dev to_world netns jool | |
| ip netns exec jool ip link set up dev to_world |
| package main | |
| import ( | |
| "io" | |
| "log" | |
| "net" | |
| "net/http" | |
| "sync" | |
| ) |
Have you ever stuck in a condition where you have to restore your mysql database from only an *.frm and *.ibd files? I have.
So what happen is somehow our mysql service is going down and can not be restarted. I try many things to no avail and getting tired of it.
And then I came across this page https://dev.mysql.com/doc/mysql-enterprise-backup/3.11/en/partial.restoring.single.html. I think probably I can just copy the *.frm and *.ibd file, wipe the current mysql data, reset the mysql, and restore those two files. Easy.
So I stupidly remove /var/lib/mysql/[schema_name], and also /var/lib/mysql/ib* file. Restart the mysql, and it start normally. Finally!
| #!/bin/bash | |
| curl https://www.cloudflare.com/ips-v4 > .ips-v4 | |
| curl https://www.cloudflare.com/ips-v6 > .ips-v6 | |
| firewall-cmd --new-zone=cloudflare --permanent | |
| firewall-cmd --reload | |
| for i in `<.ips-v4`; do firewall-cmd --zone=cloudflare --add-source=$i; done | |
| for i in `<.ips-v6`; do firewall-cmd --zone=cloudflare --add-source=$i; done |
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "net" | |
| "net/http" | |
| "syscall" | |
| ) |