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 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 User(models.Model): | |
login = models.CharField(max_length=64) | |
@property | |
def info(self): | |
return UserInfo.objects.get_or_create(user=self)[0] | |
class UserInfo(models.Model): |
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
# for http://stackoverflow.com/questions/12674193/python-no-of-occurences-of-each-character-in-a-string | |
def xx(string): | |
i, d = 0, {} | |
while i < 127: | |
char = chr(i) | |
d[char] = string.count(char) | |
i += 1 | |
return d |
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 CompileListener(EventListener): | |
def on_post_save(self, view): | |
if isCoffee(view): | |
view.run_command("compile") | |
js_file = path.splitext(view.file_name())[0] + '.js' | |
for v in view.window().views(): | |
if v.file_name() == js_file: | |
v.run_command("revert") | |
break |
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 json | |
class Foo(object): | |
def __init__(self, **kwargs): | |
self.__dict__.update(kwargs) | |
class MyEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, Foo): |
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 BaseModel(object): | |
def __init__(self, params, **params2): | |
self._data = dict(params, params2) | |
def __getattr__(self, name): | |
try: | |
return self._data[name] | |
except KeyError: | |
raise AttributeError(self, 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
Process: rustup-init [8586] | |
Path: /private/var/folders/*/rustup-init | |
Identifier: rustup-init | |
Version: ??? | |
Code Type: X86-64 (Native) | |
Parent Process: sh [8567] | |
Responsible: rustup-init [8586] | |
User ID: 501 | |
Date/Time: 2016-08-23 14:59:03.304 +0300 |
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
trait MyServiceApi { | |
fn get_public_data(&self) -> PublicDataResponse; | |
fn get_private_data(&self) -> PrivateDataResponse; | |
fn post_private_data(&self, data: &PrivateData) | |
-> PostPrivateDataResponse; | |
} |