Skip to content

Instantly share code, notes, and snippets.

View schollz's full-sized avatar
🎺

Zack schollz

🎺
View GitHub Profile
@schollz
schollz / udp_client.go
Created December 20, 2019 18:05 — forked from reterVision/udp_client.go
A dummy UDP hole punching sample in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
@schollz
schollz / chanhopper.sh
Created August 8, 2018 14:26 — forked from hit0ri/chanhopper.sh
Wi-Fi channel hopper
#!/bin/bash
msg() {
printf -- '%s\n' "$@"
}
err() {
printf -- 'error: %s\n' "$@" >&2
exit 1
}
@schollz
schollz / main.go
Created June 25, 2018 02:11 — forked from dopey/main.go
How to generate secure random strings in golang with crypto/rand.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
// Adapted from https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
@schollz
schollz / unfix-all-the-toolbars.user.js
Created March 4, 2018 23:57
GreaseMonkey script to remove "position: fixed" from webpages
// ==UserScript==
// @name unfix-all-the-toolbars
// @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such.
// @namespace http://inf.ufrgs.br/~vbuaraujo/
// @include *
// @version 1.2
// @grant none
// ==/UserScript==
@schollz
schollz / bluetooth.sh
Created February 17, 2018 20:53 — forked from RamonGilabert/bluetooth.sh
Bluetoothctl automation
#!/usr/bin/expect -f
set prompt "#"
set address [lindex $argv 0]
spawn sudo bluetoothctl -a
expect -re $prompt
send "remove $address\r"
sleep 1
expect -re $prompt
@schollz
schollz / ttldict.py
Created December 28, 2017 11:44 — forked from pythonhacker/ttldict.py
A Python dictionary type with keys having specific time to live (TTL)
import threading
import time
class TTLDict(dict):
""" A dictionary with keys having specific time to live """
def __init__(self, ttl=5):
self._ttl = ttl
# Internal key mapping keys of _d
# to times of access
@schollz
schollz / docker-cleanup-resources.md
Created December 14, 2017 12:34 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@schollz
schollz / HaversinFormula.go
Created November 7, 2017 17:23 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@schollz
schollz / run.sh
Created October 16, 2017 12:39 — forked from miguelmota/config.sh
IPFS change port
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/9001
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
@schollz
schollz / README.md
Created February 14, 2017 15:13 — forked from mattn/README.md
jsonstore vs bolt
c:\dev\go-sandbox\jsonstore>go test -bench . -count 10
goos: windows
goarch: amd64
BenchmarkJsonstore-4        2000            897051 ns/op
BenchmarkJsonstore-4        2000            885050 ns/op
BenchmarkJsonstore-4        2000           1131564 ns/op
BenchmarkJsonstore-4        2000            839048 ns/op
BenchmarkJsonstore-4        2000            919052 ns/op
BenchmarkJsonstore-4        2000            838547 ns/op