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 MyClass { | |
static final MyClass _singleton = new MyClass._internal(); | |
factory MyClass() { | |
return _singleton; | |
} | |
MyClass._internal() { | |
... // initialization logic here | |
} |
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 events import Events # Note you must pip install events | |
class Person: | |
def __init__(self, name: str, age: int, city: str): | |
self.__events = Events(('on_name_changed', 'on_age_changed', 'on_location_changed')) | |
self.on_name_changed = self.__events.on_name_changed | |
self.on_age_changed = self.__events.on_age_changed | |
self.on_location_changed = self.__events.on_location_changed |
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 concurrent.futures | |
import os | |
import re | |
from timeit import timeit | |
import requests | |
from tqdm import tqdm | |
URLS = 'urls' |
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
Moved to | |
https://github.com/romannurik/android-swipetodismiss |
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 itertools import tee | |
def lazy_sort(v, key=lambda x: x): | |
v = iter(v) | |
try: | |
pivot = next(v) | |
except StopIteration: | |
return | |
v_pre, v_pos = tee(v) | |
yield from lazy_sort((item for item in v_pre if key(item) < key(pivot)), key) |
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 copy | |
from cerberus import Validator | |
from cerberus import errors | |
from collections import Mapping, Sequence | |
class ObjectValidator(Validator): | |
def __init__(self, *args, **kwargs): |
NewerOlder