Skip to content

Instantly share code, notes, and snippets.

# All bindings refer to the current screen.
config defaultToCurrentScreen true
# Nudge/resize commands refer to % of screen sice.
config nudgePercentOf screenSize
config resizePercentOf screenSize
# my old divvy bindings (might wanna replace these some day?)
# corners: q/e/z/c for nw/ne/sw/se, quarter screen
alias resize-quarter resize:screenSizeX/2;screenSizeY/2
@jnoller
jnoller / gist:3848238
Created October 7, 2012 12:25
Updated DjangoCon US 2012 Torrent Links/Information
Original Torrent was missing a single talk; revised all the things.
Supplement Torrent from original Torrent File: http://goo.gl/Rckdg
Magnet: magnet:?xt=urn:btih:d4ecb90b455d557000c86953b9352094c994a864&dn=DjangoCon%20US%202012&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80
Updated Torrent (Full Conference): http://goo.gl/RK0yX
Magnet Link: magnet:?xt=urn:btih:be8aa997451566a9698eb4b6c54c45794c9a8419&dn=DjangoCon%20US%202012-Supplement&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80
@epicserve
epicserve / factories.py
Created October 3, 2012 19:37
Example Factory-boy (https://github.com/dnerdy/factory_boy) factory that uses a file field.
from django.template.defaultfilters import slugify
from django.contrib.sites.models import Site
from django.core.files import File
from taggit.models import Tag
from .models import Photo
import factory
import os
TEST_MEDIA_PATH = os.path.join(os.path.dirname(__file__), 'tests', 'test_media')
TEST_PHOTO_PATH = os.path.join(TEST_MEDIA_PATH, 'test_photo.png')
@jefftriplett
jefftriplett / gist:3715280
Created September 13, 2012 15:53
Perfect example of why my boss is an asshole. An optimizingly correct and performance tuned asshole.
# example from: http://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python
$ python -m timeit "x=(1,2,3,4,5,6,7,8)"
10000000 loops, best of 3: 0.0571 usec per loop
$ python -m timeit "x=[1,2,3,4,5,6,7,8]"
1000000 loops, best of 3: 0.254 usec per loop
$ python -m timeit -s "x=(1,2,3,4,5,6,7,8)" "y=x[3]"
10000000 loops, best of 3: 0.0758 usec per loop
@acdha
acdha / active_value_filter.py
Created August 31, 2012 20:14
Django admin list_filter which filters out values which are not used in the current queryset
from django.contrib.admin import FieldListFilter
from django.utils.translation import ugettext as _
class ActiveValueFilter(FieldListFilter):
"""list_filter which displays only the values for a field which are in use
This is handy when a large range has been filtered in some way which means
most of the potential values aren't currently in use. This requires a
queryset field or annotation named "item_count" to be present so it can
@jefftriplett
jefftriplett / output.txt
Last active October 9, 2015 18:18
uses pip + pypi to see what is upgradeable
$ ./pip.sh outdated
Fabric (1.4.3 != 1.5.1)
gunicorn (0.17.0 != 0.17.2)
$ ./pip.sh install -U gunicorn
Downloading/unpacking gunicorn==0.17.2
Using download cache from /Users/jefftriplett/.pip/download_cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fg%2Fgunicorn%2Fgunicorn-0.17.2.tar.gz
Running setup.py egg_info for package gunicorn
Installing collected packages: gunicorn
@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
@jacobian
jacobian / wsgi.py
Created July 9, 2012 21:28
Auth a whole django site
import os
import barrel
REALM = "PRIVATE"
USERS = [('jacob', 'hunter2')]
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = barrel.cooper.basicauth(users=USERS, realm=REALM)(get_wsgi_application())
{
"auto_complete": false,
"auto_complete_commit_on_tab": false,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment",
"auto_complete_size_limit": 4194304,
"auto_complete_triggers":
[
{
"characters": "<",
@jefftriplett
jefftriplett / fabfile.py
Created May 4, 2012 01:25
A very basic python + fabric + boto script for setting up a VPN using EC2
'''
Warning! Your mileage may vary
Based on:
- Read this for EC2 setup info and the approach - http://www.dikant.de/2010/10/08/setting-up-a-vpn-server-on-amazon-ec2/
- https://gist.github.com/1130401
- EC2 fabric bits via - https://github.com/slacy/fabric-ec2
'''