Skip to content

Instantly share code, notes, and snippets.

J. Elliot Taylor jaytaylor

Block or report user

Report or block jaytaylor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jaytaylor
jaytaylor / .gitconfig
Last active Aug 29, 2015
My .gitconfig file. Don't forget to install p4merge from http://filehost.perforce.com/perforce/r13.4/bin.macosx106x86/P4V.dmg and follow the instructions at http://www.andymcintosh.com/?p=33
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
@jaytaylor
jaytaylor / ipv4AddressToNumber.pl
Created Feb 4, 2014
IPv4 addressing tools to convert between IP address <=> IP Number.
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.
#
@jaytaylor
jaytaylor / softdeletion.py
Last active Aug 29, 2015
Django soft-deletion module.
View softdeletion.py
# -*- coding: utf-8 -*-
"""
Soft-deletion for django resources.
Originally found at: http://datahackermd.com/2013/django-soft-deletion/
"""
import logging
@jaytaylor
jaytaylor / django_postgres_cidr_example.py
Created May 21, 2014
Django + Postgres CIDR filtering
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])
@jaytaylor
jaytaylor / AutoFkShifterMixIn.py
Created May 21, 2014
Mix-in class for Django ORM objects to allow for more robust object instantiation from keyword arguments.
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)
@jaytaylor
jaytaylor / git-stats-overview.sh
Last active Aug 29, 2015
Git repository statistics: Get # of commits and lines changed since some previous point in time
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.
#
@jaytaylor
jaytaylor / asana_dump.py
Last active Aug 29, 2015 — forked from rogueleaderr/asana_dump.py
Use Asana's "export project to JSON" function and copy-paste contents to an "X.json" file. *Note* Requires external library: "unicdecode", available from https://pypi.python.org/pypi/Unidecode
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
@jaytaylor
jaytaylor / get_hn_saved_stories.sh
Created Jul 9, 2014
Get all your saved stories from HN
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}" \
@jaytaylor
jaytaylor / dataloop_post_install.sh
Last active Aug 29, 2015
DataLoop ubuntu post-install cleanup script.
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}
@jaytaylor
jaytaylor / build.sbt
Created Jul 31, 2014
Scala SBT `build.sbt` example of hooking/injecting arbitrary shell commands and using non-native libraries in the build definition via a task run after successful compilation.
View build.sbt
organization := "org.foo.bar"
name := "JustAnExample"
version := "1.0"
scalaVersion := "2.10.3"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
You can’t perform that action at this time.