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
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/home/lion/.virtualenvs/test/lib/python2.6/site-packages/django/db/models/query.py", line 69, in __repr__ | |
data = list(self[:REPR_OUTPUT_SIZE + 1]) | |
File "/home/lion/.virtualenvs/test/lib/python2.6/site-packages/django/db/models/query.py", line 84, in __len__ | |
self._result_cache.extend(self._iter) | |
File "/home/lion/.virtualenvs/test/lib/python2.6/site-packages/django/db/models/query.py", line 273, in iterator | |
for row in compiler.results_iter(): | |
File "/home/lion/.virtualenvs/test/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter | |
for rows in self.execute_sql(MULTI): |
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
#include <cstdio> | |
#include <cstdlib> | |
#include <cassert> | |
#include <ctime> | |
#include <cmath> | |
#include <cstring> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; |
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 MetaA(type): | |
def __call__(cls, *args, **kwargs): | |
for name, class in cls.__dict__.iteritems(): | |
if issubclass(class.__class__, B): | |
# Do something | |
return # class A with modified fields | |
class B(object): | |
.... |
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
wlp2s0 IEEE 802.11bgn ESSID:"ASDF" | |
Mode:Managed Frequency:2.437 GHz Access Point: 123 | |
Bit Rate=54 Mb/s Tx-Power=16 dBm | |
Retry long limit:7 RTS thr:off Fragment thr:off | |
Encryption key:off | |
Power Management:off | |
Link Quality=57/70 Signal level=-53 dBm | |
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 | |
Tx excessive retries:0 Invalid misc:28 Missed beacon:0 |
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
Description='A wpa_supplicant configuration file based wireless connection' | |
Interface=wlp2s0 | |
Connection=wireless | |
Security=wpa-config | |
WPAConfigFile='/etc/wpa_supplicant/wpa_supplicant.conf' | |
IP=dhcp |
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
your_list | |
unique_d = {} | |
for i, el in enumerate(your_list): | |
unique_d.setdefault(el, i) | |
preserved_order_unique = map(lambda x: x[0], sorted([(key, val) for key, val in unique_d.iteritems()], lambda y: y[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
class MetaClass(type): | |
counter = 1 | |
def __new__(meta, name, bases, dct): | |
""" Gets called when we read in the class definition for which this is the metaclass of""" | |
print "MetaClass.__new__(%s, %s, %s, %s)" % (meta, name, bases, dct) | |
dct['class_num'] = meta.counter | |
meta.counter += 1 | |
return super(MetaClass, meta).__new__(meta, name, bases, dct) |
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
from functools import wraps | |
from json import dumps | |
from datetime import datetime | |
def timeout_cache(max_timeout): | |
def timeout_cache_inner(fn): | |
fn._cache = {} | |
fn._timeout = max_timeout | |
@wraps(fn) |
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 Measure(object): | |
def __init__(self): | |
self.__elapsed = None | |
def __enter__(self): | |
self.__start = time() | |
def __exit__(self, *args): | |
self.__elapsed = time() - self.__start |
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
from unittest import TestCase | |
from mock import patch | |
class IDontNeedTheRest(Exception): | |
pass | |
DEBUG = False |