Skip to content

Instantly share code, notes, and snippets.

View bradleypeabody's full-sized avatar

Brad Peabody bradleypeabody

View GitHub Profile
@bradleypeabody
bradleypeabody / webserver-ident-username.go
Last active June 14, 2016 18:46
Use ident to get username of incoming connection
// Example in Go of using the ident protocol to extract the username of the connecting user.
// The idea is to use this on corporate networks to identify users logged in to a Windows
// RDP machine by their ActiveDirectory username.
// NOTE: For Windows, this is a good ident server https://sourceforge.net/projects/retinascan/
// that supports multiple users and all that good stuff.
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@bradleypeabody
bradleypeabody / arp-macos.go
Created June 14, 2016 18:47
Read arp table using cgo on macos
package main
import (
"fmt"
"time"
)
/*
// Ideas and much code from:
@bradleypeabody
bradleypeabody / HD77480-parallax-propeller.c
Last active October 21, 2019 13:44
HD44780 (or compatible) LCD driver in C for Parallax Propeller, hacked together from PropWare's implementation
// WHY THIS MONSTROSITY EXISTS:
// PropWare has an excellent HD44780 LCD driver written in C++.
// I wanted something that was simpler, without the dependencies, and in C.
// So I took the basic implementation from PropWare and threw this
// together. I removed 8-bit support (4-bit mode is usually all you need) and
// it assumes 16x2 (although that is easy to change - see HD44780_init()).
// This is actually 3 files, you can see the big separator below.
// First is the header, then the library C code, then a demo program.
// You can just copy and paste what you need right
// into SimpleIDE or other Propeller C build setup and it will
@bradleypeabody
bradleypeabody / symlink_windows_example.go
Last active March 13, 2021 20:02
Implementing Symlink in go on Windows
@bradleypeabody
bradleypeabody / ecdsa-more-curves.go
Created August 2, 2016 16:52
Example of supporting additional elliptic curves for ECDSA to sign and verify with different key sizes. (Example uses curves with bit sizes smaller than P224 to achieve shorter signatures. Signatures are compatible with standard stuff like OpenSSL.)
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJP6dPlVi2B9S5MmQBuhJ18/AG1xXylLWJJLI/OabafFLDYP/opvv1gjLNLk7J84vfQE+LIm7LGXkENb1H15RxAQb1IqLCUvrogFAdtVjyKTisaoQJIgtl2mxf4R3yK2Z05omrf5/njNO5b+oNz0rFxICm8rGw0ls3BvnvTcAwgyGSFJCZTpqJnC0k9mRA4vNYQlpnbPJaYDZfQKQuwzcZ2Le2rpRifOvcLtY2Xa4u4hka6+0jim1XgE+HSkYQqK/y6oIGGI0tisaimvJy19xmcEmfriyjrZkqIlxZorwFWVy4MPDkQuhE/ttzErzeJ7ExQLmwNtrPLJ+1GFR543Gt bradpeabody@Brads-MacBook-Pro.local
@bradleypeabody
bradleypeabody / gist:185b1d7ed6c0c2ab6cec
Last active November 29, 2023 22:08
golang, convert UTF-16 to UTF-8 string
package main
// http://play.golang.org/p/fVf7duRtdH
import "fmt"
import "unicode/utf16"
import "unicode/utf8"
import "bytes"
func main() {