View .gitconfig
# NB: Don't forget to install p4merge from
# http://filehost.perforce.com/perforce/r13.4/bin.macosx106x86/P4V.dmg
# and follow the configuration instructions at http://www.andymcintosh.com/?p=33
# Some interesting .git_config files here:
# http://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain
[user]
name = YOUR NAME HERE
email = YOUR EMAIL HERE
View ipv4AddressToNumber.pl
#!/usr/bin/env perl
##
# @author Jay Taylor [@jtaylor]
#
# @date 2014-02-04
#
# @description Converts an IPv4 address into an IP number, the unsigned 32-bit numeric representation of an IPv4 address.
#
View softdeletion.py
# -*- coding: utf-8 -*-
"""
Soft-deletion for django resources.
Originally found at: http://datahackermd.com/2013/django-soft-deletion/
"""
import logging
View django_postgres_cidr_example.py
ip_column_name = 'ip'
keyword = '63.0.0.0/24'
where = '{}::inet << %s::inet::cidr'.format(ip_column_name)
match = MyDjangoModel.objects.all()
match = match.extra(where=[where], params=[keyword])
View AutoFkShifterMixIn.py
class AutoFkShifterMixIn(object):
def __init__(self, *args, **kw):
"""Automatically translate any foreign keys to the the *_id field if an id rather than an object has been provided. Also removes m2m kwargs (they'll cause Django ORM to error out)."""
for m2m_field in filter(lambda f: f.name in kw, self._meta.many_to_many):
del kw[m2m_field.name]
for fk_field in filter(lambda f: isinstance(f, models.ForeignKey), self._meta.fields):
if fk_field.name in kw and isinstance(kw[fk_field.name], (int, long, str)):
kw['{}_id'.format(fk_field.name)] = kw.pop(fk_field.name)
super(AutoFkShifterMixIn, self).__init__(*args, **kw)
View git-stats-overview.sh
#!/usr/bin/env bash
set -e
##
# @author Jay Taylor [@jtaylor]
#
# @date 2014-06-28
#
# @description Git repository statistics: Get # of commits and lines changed since some previous point in time.
#
View asana_dump.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Use Asana's "export project to JSON" function and copy-paste contents to an "X.json" file."""
import codecs
import csv
import json
import pprint
import re
View get_hn_saved_stories.sh
#!/usr/bin/env bash
username='YOUR_HN_USERNAME'
cookie='user=HN_AUTH_COOKIE'
next="saved?id=${username}"
while ! [[ -z "${next}" ]]; do
echo "next=${next}"
next=$(curl "https://news.ycombinator.com/${next}" \
View dataloop_post_install.sh
#!/usr/bin/env bash
set -e -x
# Shutdown the dataloop agent.
sudo service dataloop-agent stop || true
# Kill stragglers in the even that the service control didn't work right.
agentPids=$(ps -ef | grep 'dataloop-lin-agent' | grep -v 'grep' | sed 's/ \+/ /g' | cut -d' ' -f2)
test -n "${agentPids}" && sudo kill -9 ${agentPids}
View build.sbt
organization := "org.foo.bar"
name := "JustAnExample"
version := "1.0"
scalaVersion := "2.10.3"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")