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
def floor(x, y): | |
return (x - x % y) / float(y) | |
def ceil(x, y): | |
return floor(x - 1, y) + 1 | |
def integer_part(x, y): | |
if x * y >= 0: | |
return floor(x, y) | |
return ceil(x, y) |
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
''' | |
vc.py is a slight modification of virtualenvcontext, and it offers the possibility | |
to use the context manager without virtualenvwrapper. | |
This is useful while testing things, because it allows you to works with ad hoc | |
virtualenvs. | |
''' | |
## Modified from virtualenvcontext (C) 2011 Ralph Bean | |
## http://pypi.python.org/pypi/virtualenvcontext/ |
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 re | |
import os | |
import ast | |
import glob | |
import collections | |
class ImportVisitor(ast.NodeVisitor): | |
def __init__(self): | |
self.imports = [] | |
self.modules = collections.defaultdict(list) |
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/werkzeug.css_t | |
+++ b/pyg.css_t | |
@@ -7,8 +7,8 @@ | |
*/ | |
{% set page_width = '980px' %} | |
-{% set sidebar_width = '220px' %} | |
-{% set font_family = "Georgia, serif" %} | |
+{% set sidebar_width = '230px' %} | |
+{% set font_family = "'Ubuntu', serif" %} |
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 __future__ import division | |
import sys | |
class Person(object): | |
attrs = ('name', 'surname', 'birth', 'birth_place', 'gender', 'marital_status', 'address', 'job') | |
def __init__(self, name, surname, birth, birth_place, gender, marital_status, address, job): | |
kw = locals() |
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 | |
import time | |
import tarfile | |
import zipfile | |
def bytes2str(bytes): | |
if bytes < 0: return "0 B" | |
if bytes < 1024: return "%.2f B" % (bytes) | |
elif bytes < 1048576: return "%.2f Kb" % (bytes / 1024) | |
elif bytes < 1073741824: return "%.2f Mb" % (bytes / 1048576) |
NewerOlder