Skip to content

Instantly share code, notes, and snippets.

View golightlyb's full-sized avatar

Ben Sarah Golightly golightlyb

View GitHub Profile
@golightlyb
golightlyb / GetFQDN.go
Created January 23, 2020 07:25
Go / golang: GetFQDN gets a fully qualified domain name for a given host
// Use freely with source code level attribution (a comment in the source code linking to this page is fine)
package foo
import (
"fmt"
"net"
"os"
"strings"
)
@golightlyb
golightlyb / build.sh
Created September 16, 2019 14:40
Simple script to cross-compile a go project in parallel
# Requires GNU Parallel
# e.g. `sudo apt-get install parallel`
CC_WIN32=i686-w64-mingw32-gcc
CC_WIN64=x86_64-w64-mingw32-gcc
name=`basename \`pwd\``
tasks="
env GOOS=linux GOARCH=386 CGO_ENABLED=1 go build -trimpath -o bin/${name}32
env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -o bin/${name}64
@golightlyb
golightlyb / nc.py
Created July 7, 2016 18:25
simple python3 wrapper to netcat (nc)
'''
nc.py - simple python3 wrapper to netcat (nc)
=============================================
Introducton
-----------
Netcat (http://nc110.sourceforge.net/) is a simple Unix utility which reads and
writes data across network connections. If you are running Linux, you probably
have a version of netcat installed already.
# reuse freely
from datetime import datetime, timezone, timedelta
# usage: naturaltime.to_text(some_datetime)
def past(dt, dif):
if dif.days > 2:
@golightlyb
golightlyb / DebugMessageCallbackARB.c
Created May 19, 2014 05:20
DebugMessageCallbackARB arguments are garbled by some drivers. This is a limited safer version that will try to safely print /something/ useful
// DebugMessageCallbackARB arguments are garbled by some drivers. This is a limited safer version that will try to safely print /something/ useful
void FormatDebugOutputARB
(
int d0, // accepts buggy parameters in any order
int d1,
int d2,
int d3
)
{