Skip to content

Instantly share code, notes, and snippets.

View hackerzhut's full-sized avatar

Sara hackerzhut

View GitHub Profile
package main
import (
"crypto/tls"
"fmt"
"net"
"os"
"bytes"
"io"
)
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@hackerzhut
hackerzhut / logger.go
Created April 19, 2019 09:18
Ideal Logger Interface
type Logger interface {
// all levels + Prin
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
Debug(v ...interface{})
Debugf(format string, v ...interface{})
Debugln(v ...interface{})
Info(v ...interface{})
Infof(format string, v ...interface{})
@hackerzhut
hackerzhut / init.linux.sh
Created April 29, 2019 11:26
Linux init script
#!/usr/bin/env bash
set -u
INIT_PATH=$(cd $(dirname $0) && pwd)
INSTALL_DOCKER=0
help() {
cat << EOF
usage: $0 [OPTIONS]
@hackerzhut
hackerzhut / color.go
Created May 2, 2019 11:55
Color Console
package console
import "fmt"
const (
TextBlack = iota + 30
TextRed
TextGreen
TextYellow
TextBlue
@hackerzhut
hackerzhut / cert.go
Created May 6, 2019 15:28
Verify x509 certificates
package main
import (
"crypto/x509"
"encoding/pem"
"fmt"
"log"
)
func main() {
func mergeMaps(x1, x2 map[string]interface{}) interface{} {
for k, v2 := range x2 {
if v1, ok := x1[k]; ok {
if m1, ok := v1.(map[string]interface{}); ok {
if m2, ok := v2.(map[string]interface{}); ok {
x1[k] = mergeMaps(m1, m2)
continue
}
}
}
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@hackerzhut
hackerzhut / b62.go
Created May 11, 2019 10:08 — forked from 607011/b62.go
Performance comparison of various base62 encoder techniques in Go
package main
import (
"fmt"
"math"
"reflect"
"runtime"
"sort"
"time"
)
@hackerzhut
hackerzhut / README.txt
Created May 16, 2019 03:31 — forked from ncw/README.txt
Client side certificates with go
This demonstrates how to make client side certificates with go
First generate the certificates with
./makecert.sh test@test.com
Run the server in one terminal
go run server.go