This file contains hidden or 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
# Source: https://devtalk.nvidia.com/default/topic/1049266/headless-os/ | |
# WARNING: This could render your system unbootable. Use at your own risk, and backup first. | |
sudo systemctl enable multi-user.target | |
sudo systemctl set-default multi-user.target | |
sudo apt remove whoopsie | |
sudo apt remove unattended-upgrades |
This file contains hidden or 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
// Source: https://stackoverflow.com/questions/17948827/reusing-http-connections-in-golang | |
// It is the caller's responsibility to | |
// close Body. The default HTTP client's Transport may not | |
// reuse HTTP/1.x "keep-alive" TCP connections if the Body is | |
// not read to completion and closed. | |
package main | |
import ( |
This file contains hidden or 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
// Source: https://stackoverflow.com/questions/17959732/why-is-go-https-client-not-reusing-connections | |
import "time" | |
requests_per_second := 5 | |
throttle := time.Tick(1000000000 / requests_per_second) | |
for i := 0; i < 16; i += 1 { | |
<-throttle | |
go serveQueue() |
This file contains hidden or 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 ( | |
"log" | |
"net/http" | |
"time" | |
"github.com/alexellis/faas/gateway/metrics" | |
"github.com/gorilla/mux" | |
"github.com/prometheus/client_golang/prometheus" |
This file contains hidden or 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
# https://github.com/tonsky/FiraCode/wiki | |
# Fonts | |
brew tap caskroom/fonts | |
brew cask install font-fira-code | |
# ZSH | |
brew install zsh-syntax-highlighting zsh-autosuggestions | |
brew install fasd | |
brew install ripgrep |
This file contains hidden or 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
HTTP Status Codes (General) | |
2xx = Success | |
3xx = Redirect | |
4xx = User error | |
5xx = Server error | |
Success codes: | |
200 - OK | |
201 - Created | |
202 - Accepted (Mostly used for DELETE) |
This file contains hidden or 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
// Source: https://stackoverflow.com/questions/41947307/how-to-return-hash-and-bytes-in-one-step-in-go | |
hasher := sha256.New() | |
f, err := os.Open(fname) | |
data := io.TeeReader(f, hasher) | |
// Now read from data as usual, which is still a stream. |
This file contains hidden or 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
// Source: https://stackoverflow.com/questions/9996767/showing-custom-404-error-page-with-standard-http-package | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func main() { |
This file contains hidden or 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
res, err := c.httpClient.Do(req) | |
dump, _ := httputil.DumpResponse(res, true) | |
fmt.Printf("DUMP: %q\n", dump) |
This file contains hidden or 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
s := &http.Server{ | |
Addr: ":8080", | |
Handler: myHandler, | |
ReadTimeout: 10 * time.Second, | |
WriteTimeout: 10 * time.Second, | |
MaxHeaderBytes: 1 << 20, | |
} | |
log.Fatal(s.ListenAndServe()) |