Skip to content

Instantly share code, notes, and snippets.

View anxiousmodernman's full-sized avatar
🎺
ready for a ska revival

Coleman McFarland anxiousmodernman

🎺
ready for a ska revival
View GitHub Profile
@anxiousmodernman
anxiousmodernman / containers.sls
Last active July 8, 2016 18:24
How to configure Docker Hub
deciphernow/odrive:latest:
dockerng.image_present:
- insecure_registry: True
- name: deciphernow/odrive:latest
@anxiousmodernman
anxiousmodernman / cookie_jar_golang.go
Created March 13, 2016 17:51 — forked from varver/cookie_jar_golang.go
Login to a website with this golang code using persistent cookies or cookie jar .
@anxiousmodernman
anxiousmodernman / openssl_conn.go
Created February 5, 2016 17:54
golang openssl example
// NewOpenSSLTransport returns a TCP connection establish with OpenSSL.
func NewOpenSSLTransport(trustPath, certPath, keyPath, host, port string, dialOpts *OpenSSLDialOptions) (*openssl.Conn, error) {
// Default to flag 0
if dialOpts == nil {
dialOpts = &OpenSSLDialOptions{}
}
ctx, err := openssl.NewCtx()
if err != nil {
@anxiousmodernman
anxiousmodernman / doing_a_build_involving_npm.sh
Last active December 3, 2015 03:37
Is this a good idea
npm_install()
{
cd $PROJECT_HOME # package.json in here
if npm install
then
return 0
else
@anxiousmodernman
anxiousmodernman / s3upload.go
Created August 9, 2015 16:39
S3 upload with Go
func performUpload(path string) {
fmt.Println("uploading:", path)
// call this in a goroutine from the main service UploadToS3
creds := credentials.NewStaticCredentials(awsAccessKeyID, secretAccessKey, "")
// TODO extract this into a config provider
awsConfig := &aws.Config{
Credentials: creds,
Region: "us-east-1",
}
@anxiousmodernman
anxiousmodernman / bigsql.go
Last active August 29, 2015 14:26
large SQL result to CSV
// ReportExporter Contains required methods for extracting csv data from SQL queries
type ReportExporter interface {
FromSqlRow(*sql.Rows) error
ToStrings() []string
}
// Report A type for holding metadata to instantiate the right csv schema as well
// as write the correct output filename
type Report struct {
SQL string
@anxiousmodernman
anxiousmodernman / xml_helper.go
Created July 7, 2015 01:12
Additional charsets in xml_helper
package client
import (
"encoding/xml"
"io"
"github.com/paulrosania/go-charset/charset"
_ "github.com/paulrosania/go-charset/data"
)
@anxiousmodernman
anxiousmodernman / betterParts.js
Last active August 29, 2015 14:21
How Douglas Crockford Makes JS objects
/*
* spec parameter is some JSON object with all the params you need
*/
function constructor(spec) {
var that = other_constructor(spec),
member,
@anxiousmodernman
anxiousmodernman / sliceofslice.go
Last active August 29, 2015 14:21
Slice of Slice
package main
import "fmt"
type IndentationStack []([]string) // type to represent a slice of slice-of-string
// can be written like [][]string, i think, but parens make it more clear
func main() {
var stack IndentationStack
stack = make([]([]string), 4) // initialize a slice of slices, length 4, inner slices have length 0!
/*
* For posterity, since I'm always looking this up.
*/
private void EnsureListingIsVisble(string key)
{
// turn off 2 + 8 bits
Listing listing = ListingsToAuditDictionary[key];
listing.IDX = listing.IDX ^ (int)ListingIdxEnum.NotSignedInNoListing; // 2