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 / config.py
Created September 5, 2014 19:58
If I have multiple project roots I can update them all by simply changing the SOURCE variable at the top of my config.py
"""
Set this to the current project you're working on.
"""
SOURCE = 'MLSListings_new'
if SOURCE == 'GEPAR':
PROJECT_ROOT = 'C:\\Users\\cmcfarland\\Dropbox\\Homesnap\\Projects\\GEPAR\\'
sqlfile = PROJECT_ROOT + 'insert_template.sql'
@anxiousmodernman
anxiousmodernman / better.go
Last active August 29, 2015 14:09
Go lookin' all JavaScript
func myMethod (myThing myType) (retVal string, val int) {
val = 0
retVal = "Farhan"
}
func main() {
@anxiousmodernman
anxiousmodernman / bootyHadMeLike.js
Last active August 29, 2015 14:12
Booty had me like example
var _ = require('underscore');
function bootyService(booty) {
return function() {
if (booty.hadMeLike()) {
throw new BootyError('Damn');
}
@anxiousmodernman
anxiousmodernman / money-left.py
Last active August 29, 2015 14:13
Budget script
#/usr/bin/python3
from datetime import datetime
import sys
"""
Pass the amount you've spent from the command line like this:
$ python3 money-left.py 2000
/*
* 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
@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!
@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 / 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 / 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 / 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",
}