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
#!/usr/bin/python | |
import getpass | |
import paramiko | |
import socket | |
def main(): | |
password = getpass.getpass() | |
hosts = raw_input("Hosts: ").split(",") | |
command = raw_input("Command: ").strip() |
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
# create a rate limiter to allow the http request at max 1 token within 1 sec | |
# this is the best way to avoid DDOS on the server because multiple requests | |
# can happen in different Goroutines | |
rl := rate.NewLimiter(rate.Every(time.Second), 1) | |
# We want to set up a common base client to do all the requests | |
client := resty.New(). | |
SetTLSClientConfig(&tls.Config{...}). # setup TLS | |
SetTimeout(30 * time.Second). # client timeout | |
SetBaseURL(url). # base URL for all APIs |
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 SetupDatabase(t *testing.T) (func(), *sql.DB) { | |
pool, _ := dockertest.NewPool("") | |
# specify the container image here | |
postgres, _ := pool.RunWithOptions(&dockertest.RunOptions{ | |
Repository: "postgres", | |
Tag: "13.2", | |
Env: []string{ | |
"POSTGRES_USER=postgres", | |
"POSTGRES_PASSWORD=password", |