This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kevin-U6Vc:vumi(develop) kevin$ vagrant up | |
[default] VM already created. Booting if its not already running... | |
kevin-U6Vc:vumi(develop) kevin$ vagrant up | |
[default] VM already created. Booting if its not already running... | |
[default] Provisioning enabled with puppet... | |
[default] Running any VM customizations... | |
[default] Clearing any previously set forwarded ports... | |
[default] Forwarding ports... | |
[default] -- supervisord: 9010 => 9010 (adapter 1) | |
[default] -- ssh: 22 => 2222 (adapter 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a generator | |
# 'pairs' now hold an object that generates ((k, v), (k, v), ) it passed into a for loop | |
pairs = ((f.slug, f.name) for f in FacilityType.objects.all())) | |
# tuple(pairs) actually run the generator and turn the result into a tuple | |
# if the tuple is empty, 'or' replace it with a default value to avoid an empty choice | |
# of course this is a result you don't want in prod, but it's handy for dev with an empty DB | |
# if you want to make that production friendly, you must be sure to forbid none as a value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ugettext as _, ugettext_lazy as __ | |
class FeatureType(models.Model): | |
class Meta: | |
verbose_name = __("FeatureType") | |
verbose_name_plural = __("FeatureTypes") | |
ordering = ('name',) | |
name = models.CharField(max_length=75) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mkvirtualenv vumi --no-site-packages | |
git clone git://github.com/praekelt/vumi.git | |
cd vumi | |
sudo apt-get install rabbitmq-server python-psychopg2 | |
sudo ./rabbitmq.setup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# separate the signature from the data | |
try: | |
l = signed_request.split('.', 2) | |
encoded_sig = str(l[0]) | |
payload = str(l[1]) | |
except IndexError: | |
raise ParsingError("'signed_request' malformed") | |
# pad them with "=" to make them valid base64 data if they are too short |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# vim: ai ts=4 sts=4 et sw=4 | |
""" | |
Decorators to facilitate authentifications and redirections in Facebook | |
apps | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment: | |
Request Method: GET | |
Request URL: http://gunicorn_passthrough/video/47701/go-for-it?chunk=1&page=6 | |
Traceback: | |
File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response | |
178. response = middleware_method(request, response) | |
File "/home/project/.virtualenvs/project/lib/python2.7/site-packages/django/middleware/cache.py" in process_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A virtual host using mix of IP-, name-, and port-based configuration | |
# | |
server { | |
listen 80; | |
server_name str1.domain.com | |
# Limit bandwidth for web videos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 4; | |
worker_cpu_affinity 0001 0010 0100 1000; | |
worker_rlimit_nofile 16384; | |
events { | |
worker_connections 2048; | |
use epoll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from math import * | |
MAXSTEPS = 300 | |
NUM_DRUNKARDS = 20000 | |
J = 12 | |
JSQR = J ** 2 | |
DIRECTIONS = 1 | |
random.seed() |
OlderNewer