Skip to content

Instantly share code, notes, and snippets.

View bradw2k's full-sized avatar

Brad Williams bradw2k

View GitHub Profile
@booherbg
booherbg / gist:f812c9145d157d8945b2
Last active February 25, 2022 23:44
Cross compiling a simple go server for windows

How to build Golang windows/arm static binaries from linux

Alternate title: Cross compiling Windows/Darwin/Linux amd64/386/arm all from linux

After fumbling around trying to figure out the go toolchain and cross compilation configuration, I ran across the wiki page on Go's homepage. It's super helpful, and worked out of the box. I'm including the necessary scripts here in case they get changed or lost, and we can help Google find it (since it's the first real source I've found that "Just Worked"). http://code.google.com/p/go-wiki/wiki/WindowsCrossCompiling

@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
@rmalayter
rmalayter / HMAC.sql
Last active October 11, 2023 07:55
HMAC function in Microsoft T-SQL
CREATE FUNCTION dbo.HMAC (
@algo VARCHAR(20)
,@key VARBINARY(MAX)
,@data VARBINARY(MAX)
)
/* This function only takes VARBINARY parameters instead of VARCHAR
to prevent problems with implicit conversion from NVARCHAR to VARCHAR
which result in incorrect hashes for inputs including non-ASCII characters.
Always cast @key and @data parameters to VARBINARY when using this function.
Tested against HMAC vectors for MD5 and SHA1 from RFC 2202 */