Skip to content

Instantly share code, notes, and snippets.

View armsnyder's full-sized avatar

Adam Snyder armsnyder

  • Seattle, WA
View GitHub Profile
// This is the serverless function that handles Discord commands.
const AWS = require('aws-sdk')
const nacl = require('tweetnacl')
const https = require('https')
const axios = require('axios')
const { Rcon } = require('rcon-client')
const { PUBLIC_KEY, INSTANCE_ID, SERVER_ADDRESS, SERVER_PASS, RCON_PORT, RCON_PASS } = process.env
@armsnyder
armsnyder / do_with_retries.go
Last active May 12, 2021 19:09
Go helper function for retrying an operation with a constant retry interval
func doWithRetries(
ctx context.Context, fn func(ctx context.Context) error, retries int, interval, timeout time.Duration,
) error {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
for i := 0; i <= retries; i++ {
if err := fn(ctx); err == nil {
return nil
}

Keybase proof

I hereby claim:

  • I am armsnyder on github.
  • I am armsnyder (https://keybase.io/armsnyder) on keybase.
  • I have a public key whose fingerprint is 7927 4B5F 58DB 9FD0 6063 A94E 6ACD 3BE8 2CD4 829D

To claim this, I am signing this object: