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 -*- | |
from itertools import chain | |
def test_really_in(y, xs): | |
for x in xs: | |
if y is x: return True | |
return False | |
def test_filtered_really_in(y, xs): |
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
# found this from Armin R. on Twitter, what a beautiful gem ;) | |
import ctypes | |
from types import DictProxyType, MethodType | |
# figure out side of _Py_ssize_t | |
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'): | |
_Py_ssize_t = ctypes.c_int64 | |
else: | |
_Py_ssize_t = ctypes.c_int |
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 | |
def test_method(method): | |
start_time = time.time() | |
result = method() | |
assert len(result) == 68888890, 'Method work no good: %s != 68888890' % len(result) | |
end_time = time.time() | |
print method.func_name, end_time - start_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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from cStringIO import StringIO | |
from UserString import MutableString | |
data = xrange(100000) | |
def test_naive_way(): | |
accum = '' | |
for x in data: |
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
## Descriptors | |
## Anything with __get__ and optionally __set__: | |
class classinstancemethod(object): | |
def __init__(self, func): | |
self.func = func | |
def __get__(self, obj, type=None): | |
def repl(*args, **kw): | |
return self.func(obj, type, *args, **kw) |
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 fabric.api import env, run, sudo, local, put | |
def production(): | |
"""Defines production environment""" | |
env.user = "deploy" | |
env.hosts = ['example.com',] | |
env.base_dir = "/var/www" | |
env.app_name = "app" | |
env.domain_name = "app.example.com" | |
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |
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
#include <sched.h> | |
#include <sys/time.h> | |
#include <signal.h> | |
#include <pthread.h> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <iostream> |
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 -*- | |
""" | |
(c) 2010 mahmoud abdelkader (http://blog.mahmoudimus.com/) | |
from blogpost: http://blog.mahmoudimus.com/reading-and-writing-null-terminated-csv-files-in-python | |
This file is released under the WTFPL License (http://sam.zoy.org/wtfpl/) | |
""" | |
import logging |
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
"""This plugin provides test timings to identify which tests might be | |
taking the most. From this information, it might be useful to couple | |
individual tests nose's `--with-profile` option to profile problematic | |
tests. | |
This plugin is heavily influenced by nose's `xunit` plugin. | |
Add this command to the way you execute nose:: | |
--with-test-timer |
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 TABLE adressen.land | |
( | |
isocode_2 character(2) not null, -- ISO 3166 ALPHA-2 | |
isocode_3 character(3) not null, -- ISO 3166 ALPHA-3 | |
name character varying not null, -- deutscher Name des Landes (international besser via ISO-Code ankoppeln!) // German name of the country | |
vorwahl integer default null, -- internationale Vorwahl // international phone code | |
null_bei_vorwahl boolean default FALSE, -- muss man die Null der Ortsvorwahl auch nach der internationalen Vorwahl wählen? // must one dial zero between international and local phone code? | |
vorwahl_lokal boolean default FALSE, -- muss man vor Ort die Vorwahl wählen? // must one dial the local phone code also locally? | |
tld character varying default NULL, -- Top Level Domain | |
kfz character varying default NULL, -- KFZ-Kennzeichen // car code |
OlderNewer