Skip to content

Instantly share code, notes, and snippets.

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
In [1]: from core.models import *
In [2]: s = Station.objects.order_by('?')[0]
In [3]: s.meta
Out[3]:
{u'artists': [{u'album_image_url': u'http://cdn.7static.com/static/img/sleeveart/00/004/046/0000404645_50.jpg',
u'name': u'Avril Lavigne',
u'slug': u'avril-lavigne'},
{u'album_image_url': u'http://cdn.7static.com/static/img/sleeveart/00/008/305/0000830535_50.jpg',
post_data = None if post_args is None else urllib.urlencode(post_args)
file = urllib.urlopen("https://graph.facebook.com/" + path + "?" +
urllib.urlencode(args), post_data)
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.javier(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 6.71 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.auston(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 13.9 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.auston(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 14.3 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.gor(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 10.1 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.abunsen(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
10000 loops, best of 3: 57.5 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.gor(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 10.1 usec per loop
☁ [tmp] ⚡ python -mtimeit 'import get_aprox; get_aprox.javier(120, [33, 50, 52, 75, 100, 175, 180, 182, 200, 350])'
100000 loops, best of 3: 6.45 usec per loop
Requirement already satisfied (use --upgrade to upgrade): celery in /Users/igor/.virtualenvs/guide/lib/python2.7/site-packages
Downloading/unpacking billiard>=2.7.3.14 (from celery)
Running setup.py egg_info for package billiard
warning: no files found matching '*.py' under directory 'Lib'
Downloading/unpacking python-dateutil>=1.5,<2.0 (from celery)
Running setup.py egg_info for package python-dateutil
Downloading/unpacking kombu>=2.4.7,<3.0 (from celery)
Running setup.py egg_info for package kombu
@igorgue
igorgue / get_aprox.py
Created June 6, 2012 21:53
Get aprox number in a list
#!/usr/bin/env python
"""
Create a program that given a requested number gives you
the nearest number in a list.
Considerations:
- The list needs to only contain integers
This example is useful when you have only a certain number of
images sizes available and you have to pick one for your station
function preexec {
cmdstats "${1}"
}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534129.919037}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534131.236584}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534132.251363}
{"full_command": "ls", "command": "ls", "time": 1338534133.3364}
{"full_command": "tail -f cmdstats.log", "command": "tail", "time": 1338534137.823144}
{"full_command": "git st", "command": "git", "time": 1338534148.520755}
{"full_command": "ls", "command": "ls", "time": 1338534182.321932}
{"full_command": "git st", "command": "git", "time": 1338563800.889613}
{"full_command": "clear", "command": "clear", "time": 1338563802.092856}
{"full_command": "ls", "command": "ls", "time": 1338564151.801845}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534129.919037}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534131.236584}
{"full_command": "cat cmdstats.log", "command": "cat", "time": 1338534132.251363}
{"full_command": "ls", "command": "ls", "time": 1338534133.3364}
{"full_command": "tail -f cmdstats.log", "command": "tail", "time": 1338534137.823144}
{"full_command": "git st", "command": "git", "time": 1338534148.520755}
{"full_command": "ls", "command": "ls", "time": 1338534182.321932}
{"full_command": "git st", "command": "git", "time": 1338563800.889613}
{"full_command": "clear", "command": "clear", "time": 1338563802.092856}
{"full_command": "ls", "command": "ls", "time": 1338564151.801845}