Skip to content

Instantly share code, notes, and snippets.

View jdunck's full-sized avatar

Jeremy Dunck jdunck

View GitHub Profile
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 15, 2025 08:03
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
# This is an example .wsgi file for serving up localwiki inside of a
# custom virtualenv.
#
#############################################################
# CHANGE THIS LINE to the absolute path of the virtualenv:
#############################################################
VIRTUAL_ENV_PATH = '/home/philip/projects/py_envs/localwiki'
import os
import sys
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@sfate
sfate / vim-on-heroku.sh
Created June 7, 2012 14:39 — forked from naaman/vim-on-heroku.sh
vim on heroku
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@eloraburns
eloraburns / gist:2757885
Created May 20, 2012 12:16
Function overloading in Python
#!/usr/bin/python
import inspect
from functools import wraps
from collections import defaultdict
# This time, we'll avoid using a class to hold the namespace. We'll just use
# the class that the functions are being defined in.
# AS A BONUS
# This means that it works for module-level functions, not just methods!
@griggheo
griggheo / gist:2698152
Created May 14, 2012 23:51
dynamodb batchwriteitem in boto
import os
import sys
import subprocess
import re
import optparse
import boto
dynamodb_conn = boto.connect_dynamodb(aws_access_key_id='MY_ACCESS_KEY_ID', aws_secret_access_key='MY_SECRET_ACCESS_KEY')
table_name = 'mytable'
dynamodb_table = dynamodb_conn.get_table(table_name)
@idan
idan / oauthlib_twitter_example.py
Created May 2, 2012 22:50
Requests + OAuth, sample usage
import requests
from requests.auth import OAuth1
url = u'https://api.twitter.com/1/account/settings.json'
client_key = u'...'
client_secret = u'...'
resource_owner_key = u'...'
resource_owner_secret = u'...'
# This module intentionally minimizes dependencies to mitigate breakage risk.
# Subset of Syslog's numerical severity codes (RFC 3164, Table 2)
SEVERITY =
ERROR: 3
WARN: 4
INFO: 6
DEBUG: 7
# Configuration
@dcarley
dcarley / README.md
Created February 1, 2012 10:49
VirtualBox NAT interface stops responding under load

VirtualBox NAT bug

Pushing a certain quantity/mixture of data through a VB guest's NAT interface causes all TCP/UDP connections to fail for a period of time thereafter.

The only way I've been able to reliably reproduce this is to use pip(1) to download a large list of Python packages. After a number of packages have been downloaded (14~20) pip will exit with an HTTP or DNS timeout. Inbound port-forwarded SSH connections will drop with:

Connection to 127.0.0.1 closed by remote host.

This appears most likely to occur with the Intel PRO/1000 MT Desktop (82540EM) NIC. It is harder to reproduce with PCnet-FAST III (Am79C973) NICs. It is not reproducible with host-only or bridged adapters.

@dgouldin
dgouldin / gist:1207636
Created September 9, 2011 23:49
Django templatetag to output the current page's querystring updated with the specified values.
from django import template
register = template.Library()
class UpdateQuerystringNode(template.Node):
def __init__(self, **kwargs):
self.kwargs = kwargs
def render(self, context):
query_dict = context['request'].GET.copy()