Skip to content

Instantly share code, notes, and snippets.

View tom-hoover's full-sized avatar

Tom Hoover tom-hoover

  • Valcom, Inc.
  • Roanoke, Virginia, USA, Earth
View GitHub Profile
@tom-hoover
tom-hoover / gist:800b116e444ba5b48fb0e2fc19322cb0
Created January 18, 2021 21:31
golang map implementing CIDR conversion table
var cidrDict = map[string]int{
"128.0.0.0": 1,
"192.0.0.0": 2,
"224.0.0.0": 3,
"240.0.0.0": 4,
"248.0.0.0": 5,
"252.0.0.0": 6,
"254.0.0.0": 7,
"255.0.0.0": 8,
"255.128.0.0": 9,
@tom-hoover
tom-hoover / golang-nuts.go
Created October 22, 2020 13:20 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@tom-hoover
tom-hoover / golang-tls.md
Created October 22, 2020 11:30 — forked from 6174/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@tom-hoover
tom-hoover / redirectExample.go
Created October 22, 2020 11:30 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@tom-hoover
tom-hoover / gist:6ccc4a4e3322f3a741c1ce4b18b239b2
Created September 16, 2020 09:25
command line Ubuntu release upgrade
sudo do-release-upgrade -d