Skip to content

Instantly share code, notes, and snippets.

View gavrie's full-sized avatar

Gavrie Philipson gavrie

View GitHub Profile
@gavrie
gavrie / hack.sh
Created April 1, 2012 12:36 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#

Keybase proof

I hereby claim:

  • I am gavrie on github.
  • I am gavrie (https://keybase.io/gavrie) on keybase.
  • I have a public key whose fingerprint is 6B82 F023 43D1 F603 9023 ADC3 8BA1 C5BF C114 2B70

To claim this, I am signing this object:

# System authorization information
auth --enableshadow --passalgo=sha512
# Run the Setup Agent on first boot
firstboot --enable
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
@gavrie
gavrie / retry_test.go
Last active May 17, 2016 12:08
retry unit test
package retry_test
import (
"testing"
"time"
"github.com/gavrie/retry"
)
func TestBasic(t *testing.T) {
package retry
import "time"
type retrier struct {
timeout time.Duration
retries int
}
func New(timeout time.Duration, retries int) *retrier {
func (er *exponentialRetrier) nextTimeout() time.Duration {
er.retries--
t := er.timeout
er.timeout *= 2
log.Printf("Next timeout: %v\n", t)
return t
}
type retrier interface {
nextTimeout() time.Duration
keepTrying() bool
}
type basicRetrier struct {
// ...
virtual retrier
}
func NewBasic(timeout time.Duration, retries int) *basicRetrier {
br := &basicRetrier{
timeout: timeout,
retries: retries,
}
func (br *basicRetrier) TotalTimeout() (total time.Duration) {
r := *br // Make a copy to preserve unchanged original
for r.virtual.keepTrying() {
total += r.virtual.nextTimeout()
}
log.Printf("Total timeout: %v\n", total)
return total
}
@gavrie
gavrie / nmap-tls.md
Last active February 15, 2021 10:59
nmap TLS checks

Tools

Install nmap (and fix permissions):

snap install nmap
snap connect nmap:network-control

nmap supports XML output with the option -oX. Install xmllint for nicely formatting XML: