Skip to content

Instantly share code, notes, and snippets.

View bradmontgomery's full-sized avatar

Brad Montgomery bradmontgomery

View GitHub Profile
@jphalip
jphalip / goto.sh
Created July 10, 2013 16:10
Bash & zshell script for quickly accessing Python packages installed in the current virtualenv. Allows for tab completion. Associated blog post: http://julienphalip.com/post/55092823910/a-script-to-quickly-access-the-source-of-installed
# Author: Julien Phalip
# License: BSD
# Description: Change the current directory to the path of the given Python package.
function goto {
cd `python -c "import pkgutil; print(pkgutil.get_loader('$1').filename)"`
}
function _top_level_packages {
python -c "import pkgutil; print('\n'.join([name for loader, name, ispkg in sorted(pkgutil.iter_modules()) if ispkg]))"
@nova77
nova77 / clip_magic.py
Last active March 25, 2025 15:22
copy to clipboard ipython magic
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"
@KazuyaHayashi
KazuyaHayashi / all_userfeed.py
Created November 26, 2012 01:59
OAuth2 Service Accounts sample
import logging
import json
#logging.basicConfig(level=logging.DEBUG)
from oauth2client import client
import gdata.apps.service
from jwt_util import get_JWT, get_service_private_key, get_clientSecrets
@mariocesar
mariocesar / runserver.py
Created October 23, 2012 11:18
Runs the django dev server along with ´compass watch´ command. For fun and profit
import os
import subprocess
import atexit
import signal
from optparse import make_option
from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management.commands.runserver import Command as RunserverCommand
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 12, 2025 02:24
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%'
@fcurella
fcurella / django_postgis_on_os_x.md
Created July 27, 2012 15:22
Django and Postgis on OS X

Django and Postgis on OS X

Install Homebrew

Install a few things with homebrew:

Notice that some packages give you information at the end, read it carefully. To recall that info use brew info like this: $ brew info postgresql

$ brew install python --universal
@alhafoudh
alhafoudh / stickies-to-notes.rb
Created July 11, 2012 10:11
OSX 10.8 Mountain Lion - Migrate your stickies from Stickies.app to Notes.app
# Author: Ahmed Al Hafoudh <[email protected]
#
# Usage: ruby stickies-to-notes.rb
#
# Prerequisites:
# gem install rb-appscript
#
require 'appscript'
require 'osax'
@HenrikJoreteg
HenrikJoreteg / ajaxfileupload.js
Created April 26, 2012 19:47
AJAX file uploading using jQuery and XMLHttpRequest 2.0 and adding listener for progress updates
// grab your file object from a file input
$('#fileInput').change(function () {
sendFile(this.files[0]);
});
// can also be from a drag-from-desktop drop
$('dropZone')[0].ondrop = function (e) {
e.preventDefault();
sendFile(e.dataTransfer.files[0]);
};
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname IN ('public')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
{
"id": "base",
"packages": {
"ruby1.8-dev": "",
"swig": "",
"libssl-dev": "",
"git-core": "",
"tmux": "",
"sysstat": "",
"tcpdump": "",