For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
package main | |
/* | |
URL: https://github.com/mccoyst/myip/blob/master/myip.go | |
URL: http://changsijay.com/2013/07/28/golang-get-ip-address/ | |
*/ | |
import ( | |
"net" | |
"os" |
Find the commit history of the desired software and version in github. e.g. "https://github.com/Homebrew/homebrew-core/commits/master/Formula/git.rb" | |
Click `raw` button, get raw url e.g. "https://raw.githubusercontent.com/Homebrew/homebrew-core/6f85b5c82436b2f8beb3c0fd64f36d6f466cf0f7/Formula/git.rb" | |
brew unlink `formula` e.g. "brew unlink git" | |
brew install `url` | |
You can use `brew switch` switch version |
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |
func readLine(path string) { | |
inFile, _ := os.Open(path) | |
defer inFile.Close() | |
scanner := bufio.NewScanner(inFile) | |
scanner.Split(bufio.ScanLines) | |
for scanner.Scan() { | |
fmt.Println(scanner.Text()) | |
} | |
} |
import ( | |
"bufio" | |
"io" | |
) | |
type FileLineFunc func(line []byte) (isExit bool, err error) | |
func ReadLines(file io.Reader, bufLen int, f FileLineFunc) error { | |
buffer := make([]byte, 0, bufLen) | |
scanner := bufio.NewScanner(file) |
// Convert string to bytes array, don't allocate extra memory | |
// General: []byte(string), this may allocate memory more than len(string) | |
func StringToBytes(s string) []byte { | |
b := make([]byte, len(s)) | |
copy(b[:], s) | |
return b | |
} |
package main | |
import ( | |
"crypto" | |
"crypto/rsa" | |
"crypto/sha1" | |
"crypto/x509" | |
"encoding/base64" | |
"fmt" | |
) |
macos: | |
1. networksetup -getcomputername | |
2. scutil --get ComputerName | |
windows: | |
1. echo %ComputerName% |