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 os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") | |
from raven.utils.wsgi import ( | |
get_current_url, get_headers, get_environ) | |
class Sentry(object): | |
def __init__(self, application): | |
self.application = application |
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
api: | |
build: . | |
command: python manage.py runserver 0.0.0.0:80 | |
environment: | |
DJANGO_SETTINGS_MODULE: local_settings_api_service | |
ports: | |
- "80:80" | |
volumes: | |
- .:/usr/src | |
links: |
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 disqus/nginx:python2.7-light | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
# First compile numpy by itself so we never have to do this again | |
COPY requirements/numpy.txt requirements/numpy.txt | |
RUN pip install --no-cache-dir -r requirements/numpy.txt | |
# Install dev stuff early becaues they prob don't change |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"net/url" | |
"os/exec" | |
"time" |
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
class A(object): | |
def hook(self, f): | |
def intime(*args): | |
print intime.atime | |
intime.atime += 1 | |
return f(*args) | |
intime.atime = 0 | |
return intime | |
>>> f = A().hook(lambda b: b + 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
from django.db import models | |
class DeviceA(object): | |
def do_something(self, string='Hello'): | |
print "Device A something '%s'" % string | |
def do_something_else(self): | |
print "Device A something else" | |
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
>>> f1 = lambda i: '%s' % i | |
>>> f2 = lambda i: '%s'.format(i) | |
>>> import dis | |
>>> dis.dis(f1) | |
1 0 LOAD_CONST 1 ('%s') | |
3 LOAD_FAST 0 (i) | |
6 BINARY_MODULO | |
7 RETURN_VALUE | |
>>> dis.dis(f2) | |
1 0 LOAD_CONST 1 ('%s') |
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
foo = map(lambda s: { | |
# lol my lambda's body is indented | |
s = s.upper() | |
print s | |
return s | |
}, ['does', 'the', 'lambda', 'implicitly', 'end', 'after', 'toplevel', 'returns?']) |
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
location /xml { | |
rewrite ^/xml/(.*)$ /$1; | |
proxy_pass http://xml.test.com; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_max_temp_file_size 0; |
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
var secret_key = 'abcdefghijklmnopqrstuvwxyz'; | |
var hash = crypto.createHash('sha1'); | |
hash.update(secret_key); | |
console.log(unsign_value('8a8d431c4bee603699e3fd3e9593a3264af0f57c', 'value1')); | |
function unsign_value(signature, value) | |
{ | |
var hmac = crypto.createHmac('sha1', hash.digest()); | |
hmac.update(value); | |
console.log(signature); |
NewerOlder