This file contains hidden or 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 datetime import datetime | |
def random_date(start, end): | |
return datetime.fromtimestamp(random.randint(*map(lambda x: int(x.strftime('%s')), (start, end)))) |
This file contains hidden or 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
# http://programming.oreilly.com/2014/04/simplifying-django.html | |
import os | |
import sys | |
BASE_PATH = os.path.dirname(__file__) | |
from django.conf import settings | |
from django.conf.urls import patterns | |
from django.core.management import execute_from_command_line | |
This file contains hidden or 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
# https://icpc.kattis.com/problems/chopin | |
import sys | |
EXCEPTIONS = ('Ab minor', 'D# major', 'A# major', 'D# minor', 'A# minor', 'Gb major', 'C# major', 'Gb minor', 'Db minor', 'G# major') | |
inverse = lambda x: {'b': '#', '#': 'b'}[x] | |
alternate = lambda scale: '{0}{1}'.format(chr((((ord(scale[0]) + {'b': -1, '#': 1}[scale[1]]) - 65) % 7) + 65), inverse(scale[1])) |
This file contains hidden or 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 collections | |
>>> mydict = collections.defaultdict(list) | |
>>> mydict["hello"].append("world") | |
>>> mydict | |
defaultdict(<type 'list'>, {'hello': ['world']}) |
This file contains hidden or 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 wtforms | |
class MyForm(wtforms.form.Form): | |
first_name = wtforms.TextField(u'First Name') | |
form = MyForm(first_name="Hello", last_name="Ignored") |
This file contains hidden or 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
# antes de importar nada | |
from gevent import monkey | |
monkey.patch_socket() | |
import gevent | |
from gevent import socket | |
def InsertData(line, value): | |
data = line.split(',') |
This file contains hidden or 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
#!/bin/bash | |
# This hook is run after every virtualenv is activated. | |
projname=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') | |
projectdir=/Users/neo/Projects/${projname} | |
if [ -d $projectdir ]; then | |
cd $projectdir | |
fi |
This file contains hidden or 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 | |
""" | |
Rudimentary Spotify Web Proxy using mitmproxy. | |
Use it by your own responsibility!! | |
This was only entertainment!! | |
""" | |
import random | |
import hashlib |
This file contains hidden or 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
# ~/.osx — http://mths.be/osx | |
############################################################################### | |
# General UI/UX # | |
############################################################################### | |
# Menu bar: disable transparency | |
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false | |
# Expand save panel by default |
This file contains hidden or 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 Comment(db.EmbeddedDocument): | |
... | |
visibility = db.IntField(default=0) | |
mentions = db.ListField(db.GenericReferenceField()) | |
class Message(db.Document): | |
... | |
comments = db.ListField(db.EmbeddedDocumentField(Comment)) |
NewerOlder