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
| // 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
| // 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://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
| # Get IP | |
| docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id | |
| # Remove stopped images/etc | |
| docker system prune | |
| docker image prune | |
| docker volume prune |
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 ( | |
| "bytes" | |
| "fmt" | |
| "io" | |
| "log" | |
| "mime/multipart" | |
| "net/http" | |
| "os" |
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
| Great article on subject: | |
| https://medium.freecodecamp.org/useful-tricks-you-might-not-know-about-git-stash-e8a9490f0a1a |
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://github.com/kkdai/pubsub/blob/master/.travis.yml | |
| - $HOME/gopath/bin/goveralls -coverprofile=coverage.cov -service=travis-ci | |
| - go test -bench=. -benchmem . | |
| - sh ./install_all_cmd.sh |
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
| if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { | |
| // path/to/whatever does not exist | |
| } | |
| if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) { | |
| // path/to/whatever exists | |
| } |
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 ( | |
| "bytes" | |
| "fmt" | |
| "os/exec" | |
| "strings" | |
| ) | |
| func main() { |