Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Aaron Schlesinger arschles

🏠
Working from home
View GitHub Profile
@arschles
arschles / install-gh-cli.sh
Last active Mar 18, 2020
How to install the GitHub CLI without Homebrew
View install-gh-cli.sh
#!/bin/bash
echo "This will install the GitHub CLI (gh) onto your system"
echo "When this is done, you'll have a new 'gh' command line tool..."
echo "in your /usr/local/bin directory. On most Mac and Linux systems..."
echo "That directory will be in your 'PATH' environment variable..."
echo "If it isn't, please add it. You can temporarily do so by running this:"
echo "\n export PATH=\"/usr/local/bin:\$PATH\""
RELEASE="0.6.2"
@arschles
arschles / delete.sh
Created Mar 17, 2020
Delete GlobalProtect on Mac OS X
View delete.sh
ps -ef | grep GlobalProtect
# take note of the GlobalProtect PID, store in $GP_PID
sudo kill -9 $GP_PID
sudo rm -f /Library/LaunchAgends/com.paloaltonetworks.gp.*
# this will restart the machine. Continue below after it comes back
sudo shutdown -r now
# finally, clear the staging kernel cache
sudo kextcache --clear-staging
@arschles
arschles / .envrc
Last active Oct 5, 2019
Installing PhantomOS on Azure, kinda
View .envrc
export RES_GROUP=photon
export AZURE_STORAGE_ACCOUNT=photonimages
export AZURE_STORAGE_CONTAINER_NAME=photonimages
export BLOB_NAME=photon3.vhd
export ADMIN_USERNAME=arschles
export VM_NAME=photon3
export LOCATION=eastus2
export PHOTON_VHD_PATH=photon3.vhd
@arschles
arschles / 00-install-gnome-core.sh
Last active Oct 4, 2019
Set up Gnome and VNC server on an Azure Ubuntu Server VM
View 00-install-gnome-core.sh
#!/bin/bash
set pipefail
set -eou
apt install gnome-core ubuntu-gnome-desktop
echo "Now go and click 'reboot' on your VM in the portal"
@arschles
arschles / app_fmwk.md
Last active Aug 21, 2019
Vecty/GopherJS Web App Framework
View app_fmwk.md

Web App Framework with Vecty & GopherJS

This document describes a web app framework targeted for Vecty & GopherJS.

Goals:

  • Go is the primary language for all frontend and backend tasks. An app developer should be able to write full-feaured web applications using only Go and without any HTML/Javascript/CSS knowledge or expertise
  • The framework handles and compiles Go code targeting the frontend and backend
    • Framework can build frontend code into HTMl/JS/CSS or Web Assembly (WASM). In both cases, the resulting app is a SPA
    • Framework design might enable classic web apps with multiple routes, but that's not a design goal
View get_with_retry.go
package main
import (
"context"
"fmt"
"time"
)
// adaptation of
// https://github.com/Azure/aks-engine/blob/f61205726c139d286c427b3403942a079eb1b26d/test/e2e/kubernetes/pod/pod.go#L289
@arschles
arschles / westeurope.sh
Last active Apr 3, 2019
Testing Athens /list endpoints
View westeurope.sh
az container create \
--resource-group remotedesktop \
--name athenstesteu \
--image gomods/athens:canary \
--restart-policy OnFailure \
--location westeurope
# apk add -U curl
# time curl athens-westeurope.westeurope.azurecontainer.io:3000/cloud.google.com/go/@v/list
az container exec -g remotedesktop -n athenstesteu --exec-command ash
@arschles
arschles / log_entry.go
Last active Sep 11, 2018
Threading Log Entries Down the Stack in Athens
View log_entry.go
func newLogEntry(req *http.Request, lggr *log.Logger) logrus.Entry {
return lggr.WithFields(logrus.Fields{
"http-method": req.Method,
"http-path": req.URL.Path,
"http-url": req.URL.String(),
})
}
@arschles
arschles / keep-cool-with-fans.go
Last active Aug 28, 2018
Fan-out and Fan-in with Go
View keep-cool-with-fans.go
package fans
// this code was inspired by https://talks.golang.org/2012/concurrency.slide#36
//
// it uses the context package (which wasn't available when that presentation was made) instead of a timer to
// do timeouts
import (
"context"
"time"
@arschles
arschles / more-resources.md
Last active Aug 28, 2018
Tuning an HTTP Client for Great Good!
View more-resources.md

Other Go Libraries to Help With Doing HTTP Clients

  • ctxhttp - use HTTP clients but do requests timeouts with a context
    • httptrace - a good library to pair with ctxhttp; you can use this to trace requests up to the server. this is pretty advanced usage, so I recommend you go here once you have basic performance issues sorted out
  • fasthttp - slightly easier-to-use HTTP client. you still have to deal with connection pool details though. still useful if you like the API better
  • go-cleanhttp - battle-tested HTTP client. useful to compare against the above code
  • gorequest - nicer API, not as geared toward load testing. recommend against this for load tests, but for business logic it's good
You can’t perform that action at this time.