Skip to content

Instantly share code, notes, and snippets.

# Pure
# by Sindre Sorhus
# https://github.com/sindresorhus/pure
# MIT License
# For my own and others sanity
# git:
# %b => current branch
# %a => current action (rebase/merge)
# prompt:
class DummyStorage(FileSystemStorage):
def _open(self, name, mode='rb'):
try:
return File(open(self.path(name), mode))
except IOError:
name = '/home/andre/Imagens/placeholder.jpg'
return File(open(name), mode)
DEFAULT_FILE_STORAGE = 'geral.custom_settings.DummyStorage'
@dvl
dvl / fabfile.py
Last active September 9, 2015 17:23
# -*- coding: utf-8 -*-
from fabric.api import (
env,
serial,
settings,
sudo,
task,
warn_only,
)
@dvl
dvl / akamai.py
Last active August 29, 2015 14:27
# -*- coding: utf-8 -*-
import time
from Crypto.Hash import HMAC, SHA256
class AkamaiSecureToken(object):
"""
Gera um assinatura para ser utilizada junto com o Akamai, para autenticar
# -*- coding: utf-8 -*-
import base64
import hashlib
import time
HOST = 'localhost'
URL = 'http://{}:1935/'.format(HOST)
STREAM = 'live/myStream'
START_TIME = int(time.time())
@dvl
dvl / a.out
Last active August 29, 2015 14:23
$ python test.py
4 0 LOAD_CONST 3 ('aaaaaaaaaaaaaaaaaaaa')
3 STORE_FAST 0 (a)
5 6 LOAD_CONST 4 ('aaaaaaaaaaaaaaaaaaaa')
9 STORE_FAST 1 (b)
7 12 LOAD_FAST 0 (a)
15 LOAD_FAST 1 (b)
18 COMPARE_OP 8 (is)
FROM buildpack-deps:jessie
RUN apt-get purge -y python.*
ENV LANG C.UTF-8
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
26DEA9D4613391EF3E25C9FF0A5B101836580288
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
alphabet = {
".-": "A",
"-...": "B",
"-.-.": "C",
"-..": "D",
".": "E",
"..-.": "F",
"--.": "G",
"....": "H",
"..": "I",
@dvl
dvl / udjango.py
Last active August 29, 2015 14:21
mininal Django app
# -*- coding: utf-8 -*-
from django.conf import settings
settings.configure(
DEBUG=True,
SECRET_KEY='th1s_1s_s3cr37',
ROOT_URLCONF=__name__,
)
# -*- coding: utf-8 -*-
from django.conf.urls import include, url
from django.contrib import admin
# Text to put at the end of each page's <title>.
admin.site.site_title = 'Administração Infobusca'
# Text to put in each page's <h1>.
admin.site.site_header = 'Infobusca'