Skip to content

Instantly share code, notes, and snippets.

Zach Peters zpeters

Block or report user

Report or block zpeters

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#!/usr/bin/env python3
import subprocess
OUTPUT =['/usr/sbin/apcaccess'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
d = dict()
for item in OUTPUT.splitlines():
s = item.split(":")
k = s[0].strip()
v = s[1].strip()
zpeters / AmIPwned.ex
Last active Oct 30, 2018
Example Pwned
View AmIPwned.ex
defmodule ExHaveibeenpwned do
@moduledoc """
get_all_for_account("", [truncateresponse: true, domain: ""])
use Tesla
plug Tesla.Middleware.BaseUrl, ""
plug Tesla.Middleware.Headers, [
{"User-Agent", "ex_haveibeenpwned"}
zpeters / more.go
Created Oct 28, 2018
More examples
View more.go
func main() {
var rootCmd = &cobra.Command{}
var cmdVersion = &cobra.Command{
Use: "version",
Short: "Get the current version",
Run: func(cmd *cobra.Command, args []string) {
View uploadfile.go
func uploadFile(p serial.Port, filename string) (err error) {
log.Printf("Uploading file: %s\n", filename)
_, destFileName := filepath.Split(filename)
log.Printf("Destination name: %s\n", destFileName)
file, err := os.Open(filename)
if err != nil {
defer file.Close()
View sendcommand.go
func sendCommand(p serial.Port, cmd string) (out string, err error) {
err = writeSerial(p, cmd)
_ = readSerial(p)
out = readSerial(p)
return out, err
View readserial.go
func readSerial(p serial.Port) string {
buf := make([]byte, 1024)
r, err := p.Read(buf)
if err != nil {
log.Printf("Can't read from serial port\n")
return strings.TrimSpace(string(buf[:r]))
zpeters / readwrite.go
Created Oct 28, 2018
Read/write to wifimcu
View readwrite.go
package main
import ""
import "log"
func main() {
c := &serial.Config{Name: "/dev/ttyUSB0", Baud: 115200}
s, err := serial.OpenPort(c)
if err != nil {
zpeters / writefile.lua
Created Oct 28, 2018
Example write file lua
View writefile.lua"test.lua","w+")
file.writeline("print('hello world!')");
View webex_teams.ex
## TODO this is gross
defp maybe_retry(response) do
if response.status_code == 429 do
Logger.debug fn -> "*** Got a Retry-After ***" end
m = Enum.into(response.headers, %{})
if Map.has_key?(m, "Retry-After") do
retry = Map.fetch!(m, "Retry-After")
wait_time = String.to_integer(retry)
Logger.debug fn -> "Retry after seconds #{wait_time}" end
zpeters / webex_teams.ex
Created Oct 6, 2018
http get function with a check for retry
View webex_teams.ex
def get(path) do
url = generate_url(path)
headers = generate_headers()
options = []
response = HTTPoison.get!(url, headers, options)
Logger.debug fn -> "Get Response: #{inspect(response)}" end
if maybe_retry(response) do
You can’t perform that action at this time.