Skip to content

Instantly share code, notes, and snippets.

View mmcloughlin's full-sized avatar

Michael McLoughlin mmcloughlin

View GitHub Profile
@mmcloughlin
mmcloughlin / structtags.go
Created October 28, 2016 02:43
Golang Struct Tags
package main
import (
"fmt"
"reflect"
)
// PrintTags prints all tag values for the given struct.
func PrintTags(s interface{}, tag string) {
st := reflect.TypeOf(s)
@mmcloughlin
mmcloughlin / tor.go
Last active March 15, 2021 15:44
Tor from Golang
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"golang.org/x/net/proxy"
)
@mmcloughlin
mmcloughlin / httpgzip.go
Last active January 30, 2017 06:38
Attempt to understand how Golang's `net/http` package handles compressed responses
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
)
type Experiment struct {
@mmcloughlin
mmcloughlin / methodasfunc.go
Last active June 15, 2018 15:51
Golang method expressions satisfy function types
package main
import "fmt"
// GreetingFunc builds a greeting from a name.
type GreetingFunc func(string) string
// Formatted builds a greeting based on a printf-style format string.
type Formatted struct {
Format string
package overallsrace
import "fmt"
func Greeting(who string) string {
return fmt.Sprintf("Hello %s!", who)
}
@mmcloughlin
mmcloughlin / manners.py
Last active March 28, 2024 13:32
Example of __name__ == '__main__' in Python
def greet(who='World'):
print 'Hello {who}!'.format(who=who)
if __name__ == '__main__':
greet('World')
@mmcloughlin
mmcloughlin / AESNI.md
Last active October 24, 2017 16:52
Processor support for AES-NI and CLMUL-NI

AES GCM hardware acceleration requires both AES-NI and CLMUL-NI instructions. The existence of these instructions are indicated by bits 25 and 1 respectively of CPUID (ecx leaf 1). The existence of two feature bits raises the concern that they may not both be present together.

This script uses the instlatx64.atw.hu CPUID database to search for processors that have one of the instruction sets but not both.

Golang's color.RGBA seems to produce some odd artifacts.

package main
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
)
func main() {

Keybase proof

I hereby claim:

  • I am mmcloughlin on github.
  • I am mmcloughlin (https://keybase.io/mmcloughlin) on keybase.
  • I have a public key ASCktNRZHaWMYtNTT0DNEbBOeXsoHRmiBM0u4wz-Chtftwo

To claim this, I am signing this object: