This file contains 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
"vim.leader": " ", | |
"vim.foldfix": true, | |
"vim.smartRelativeLine": true, | |
"vim.useSystemClipboard": true, | |
"vim.normalModeKeyBindings": [ | |
{ | |
"before": [ | |
"<leader>", | |
"w" | |
], |
This file contains 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
import json | |
import pytz | |
from pycountry import countries | |
def list_timezones_for_country(country_code): | |
try: | |
return pytz.country_timezones[country_code] | |
except KeyError: | |
return None |
This file contains 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
\usepackage{titlesec} | |
\titleformat{\section}[block]{\Large\bfseries\filcenter}{}{1em}{} | |
\titleformat{\subsection}[hang]{\filcenter\bfseries}{}{1em}{} |
This file contains 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
unc remoteRun(user string, addr string, privateKey string, cmd string) (string, error) { | |
// privateKey could be read from a file, or retrieved from another storage | |
// source, such as the Secret Service / GNOME Keyring | |
key, err := ssh.ParsePrivateKey([]byte(privateKey)) | |
if err != nil { | |
return "", err | |
} | |
// Authentication | |
config := &ssh.ClientConfig{ | |
User: user, |
This file contains 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
func respondWithErrorMsg(w http.ResponseWriter, code int, msg string) { | |
respondWithJSON(w, code, map[string]string{"error": msg}) | |
} | |
func respondWithError(w http.ResponseWriter, code int, err error) { | |
respondWithJSON(w, code, map[string]string{"error": err.Error()}) | |
} | |
// respondWithJSON converts the payload into JSON and responds with it |
This file contains 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
func retry(attempts int, sleep time.Duration, f func() error) (err error) { | |
for i := 0; i < attempts; i++ { | |
if i > 0 { | |
log.Println("retrying after error:", err) | |
time.Sleep(sleep) | |
sleep *= 2 | |
} | |
err = f() | |
if err == nil { | |
return nil |
This file contains 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
ticker := time.NewTicker(70 * time.Second) | |
quit := make(chan struct{}) | |
go func() { | |
for { | |
select { | |
case <-ticker.C: | |
// do the task here | |
case <-quit: | |
ticker.Stop() | |
return |