Skip to content

Instantly share code, notes, and snippets.


Keybase proof [12/159]

I hereby claim:

  • I am nagyman on github.
  • I am nagyman ( on keybase.
  • I have a public key ASD0s6T8yscXHLdt7SSC1rtZTtkP9D6FitSlpwZqITNNtwo

To claim this, I am signing this object:

View tmux.conf
# Change the bindings prefix from Control+b to Control+a
set -g prefix C-a
# Press the binding twice to toggle between windows
bind-key C-a last-window
# Helpful for nested tmux sessions
bind-key a send-prefix
# Press C-a Escape to enter copy mode
import csv
import json
from collections import defaultdict
with open('trello_export.json', "r") as f:
json_data =
data = json.loads(json_data)
cards = data['cards']
actions = data['actions']
View requirements.json
"type": "CHECKIN",
"name": "Arrival Flight Details", // client facing name
"message": "Arrival flight number, date, and time are required for this product.", // this is really a developer message
"internal": false,
"details": [
"body": "We're missing your flight number", // might be null, so what do we do here?
"detail_type": {

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
Nagyman / jActivityTracker.js
Created Oct 4, 2013
jquery activity tracking plugin for google analytics events
View jActivityTracker.js
* Searches for elements with an 'activity' attribute and pushes the activity
* to the Google Tag Manager (GTM) dataLayer. GTM must be configured to capture
* the event data, which is structured as follows:
* {
* 'event': 'eventCategory', // The primary divisions of the types of Events you have on your site.
* 'eventAction': 'action', // For example, you could define Play or Pause as Actions for a Video
* 'eventLabel': 'label', // An optional descriptor that you can use to provide further granularity. You can specify any string for a label.
* 'eventValue': 10 // An optional numerical variable.
import os
import logging
from compressor.filters import CompilerFilter
from django.conf import settings
logger = logging.getLogger(__name__)
class SassMapFilter(CompilerFilter):
from trips.models import *
import matplotlib.pyplot as plt
counts = []
for t in Trip.objects.published():
plt.title("Visited Countries")
plt.xlabel("Number of Countries")
Nagyman / gist:5452466
Created Apr 24, 2013
Errors deploying gapi-web to staging
View gist:5452466
[devgapi01.gadventures.internal] out: Traceback (most recent call last):
[devgapi01.gadventures.internal] out: File "/var/www/gapi-web/gapi_docs/gext/", line 251, in make_rst
[devgapi01.gadventures.internal] out: response = self.make_request(uri, method.lower(), accept=accept)
[devgapi01.gadventures.internal] out: File "/var/www/gapi-web/gapi_docs/gext/", line 134, in make_request
[devgapi01.gadventures.internal] out: auth_key = self.gapi_config.PASSTHROUGH_AUTHENTICATION_KEYS[0]
[devgapi01.gadventures.internal] out: AttributeError: 'DefaultConfig' object has no attribute 'PASSTHROUGH_AUTHENTICATION_KEYS'
Nagyman / createinitialrevisions.diff
Created Jul 18, 2012
django-reversion createinitialrevisions performance improvement
View createinitialrevisions.diff
from optparse import make_option
+from django.db import reset_queries
from django.core.exceptions import ImproperlyConfigured
from import BaseCommand
from import CommandError
@@ -93,17 +94,28 @@ class Command(BaseCommand):
live_objs = live_objs.exclude(
pk__in = list(versioned_pk_queryset.values_list("object_id", flat=True).iterator())