Skip to content

Instantly share code, notes, and snippets.

import csv
class SlugCSVWriter(object):
""" A CSV DictWriter that takes an OrderedDict for fieldnames.
The purpose of using an OrderedDict allows you to use a slug or
other unique value in your dictionary, but use non-unique names
for your fields.
"""
class NameModel(models.Model):
name = models.CharField()
other = models.ForeignKey('OtherModel')
class OtherModel(models.Model):
count = models.IntegerField
@property
def all_my_names(self):
def is_odd(num):
return bool(num % 2)
def test_is_odd():
assert_equal(is_odd(3), True)
assert_equal(is_odd(4), False)
@wraithan
wraithan / example.json
Created November 27, 2013 17:56
hapifis graph api idea
{
"success": true,
"graph_data": {
"<surveyor_name>": [{
"timestamp": "<truncated_timestamp>",
"count": <count>
}]
}
}
{
"ignore": ["E501", "E128"]
}
var net = require('net')
, duplexer = require('duplexer')
, through = require('through')
net.createServer(function(c) {
c.pipe(connection()).pipe(c)
}).listen(6668)
function connection() {
var socket = new net.Socket()
@wraithan
wraithan / logger.js
Last active December 27, 2015 19:49
wraps the logger with my own functions
var winston = require('winston')
, path = require('path')
winston.add(winston.transports.File)({filename: 'zenircbot.log'})
function get_logger(file) {
var process_dir = path.dirname(process.argv[1])
, filename = path.relative(process_dir, __filename)
, logger = {}
@wraithan
wraithan / goals.md
Last active December 19, 2015 05:59
Goals

3 Months

  • Maintain my eating habits.
  • Release ZenIRCBot 3.0.
  • Maintain 4 bugs per week for work.
  • 30-60 minutes of non commute walking/running/cycling 4 days a week.
  • 1 blog post a week for each of the following areas: tech, food, life.

6 Months

@wraithan
wraithan / gist:5905833
Last active December 19, 2015 05:39 — forked from rhelmer/gist:5905781
#!/bin/sh
BRANCH=`git rev-parse --abbrev-ref HEAD`
REMOTES=`git remote -v | awk '{print $2}' | uniq | sort`
if [ $# != 1 ]
then
echo 'Syntax: githubify <path_to_file>'
exit 1
fi
Host *.lxc
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ProxyCommand nc $(host -N0 $(echo %h | sed "s/\.lxc//g") 10.0.3.1 | tail -1 | awk '{print $NF}') %p
User ubuntu