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://www.reddit.com/r/golang/comments/45mzie/dont_use_gos_default_http_client/ | |
// Go Source: https://golang.org/pkg/net/http/#Client | |
// Timeout specifies a time limit for requests made by this | |
// Client. The timeout includes connection time, any | |
// redirects, and reading the response body. The timer remains | |
// running after Get, Head, Post, or Do return and will | |
// interrupt reading of the Response.Body. | |
// | |
// A Timeout of zero means no timeout. |
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/48876324/gorilla-mux-golang-cache-static-files | |
package main | |
import ( | |
"associations" | |
"html/template" | |
"net/http" | |
"log" | |
"io/ioutil" |
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 ( | |
"net/http" | |
"github.com/gorilla/mux" | |
) | |
func homeHandler(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("Hello!")) |
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
var ( | |
SyncOutput = make(chan string) | |
SyncClients = make(map[*websocket.Conn]bool) | |
SyncClientsLock = sync.RWMutex{} | |
FileSyncing = false | |
FileSyncLock = sync.RWMutex{} | |
) | |
var upgrader = websocket.Upgrader{ | |
ReadBufferSize: 1024, |
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()) |
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
// 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
// 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
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
# 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 |