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 <cstdio> | |
#include <cstdlib> | |
#include <cassert> | |
#include <ctime> | |
#include <cmath> | |
#include <cstring> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; |
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
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 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 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 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 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 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 |
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 sys | |
import os | |
from os.path import join | |
from mock import Mock, patch | |
from twisted.internet import defer | |
src_path = os.path.realpath(join(os.path.dirname(__file__), "../src/")) | |
current_path = os.path.realpath(os.path.dirname(__file__)) | |
sys.path.insert(0, current_path) | |
sys.path.insert(0, src_path) |
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 Data.List (nub) | |
class Monad m => MonadPlus m where | |
mzero :: m a | |
mplus :: m a -> m a -> m a | |
instance MonadPlus [] where | |
mzero = [] | |
mplus = (++) |
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 collections import defaultdict | |
from copy import deepcopy | |
daphne = defaultdict(set) | |
rdaphne = {} | |
maxx = defaultdict(set) | |
rmaxx = {} | |
mindy = defaultdict(set) | |
rmindy = {} |