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
In [69]: regex = re.compile(r"\{(.*\n?)\}", re.S) | |
In [70]: eee= re.findall(regex,"{ dsfdsads fdsdsafd dsddfs; { sdfssdaf; }}") | |
In [71]: eee | |
Out[71]: [' dsfdsads fdsdsafd dsddfs; { sdfssdaf; }'] | |
In [72]: eee= re.findall(regex,"{ dsfdsads fdsdsafd \n dsddfs; { sdfssdaf; }}") | |
In [73]: eee |
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
for (let i = 0; i < 10; i++) { | |
let read_img_path; | |
if (i === 0) { | |
read_img_path = "./blue_a.png" | |
} else { | |
read_img_path = "./blue_" + (i - 1) + ".png"; | |
} | |
let img_write_path = "./blue_" + i + ".png"; |
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
array[:, 1::] | |
serializer_array = np.apply_along_axis( | |
lambda x: (x[0], self._serializer.dumps(x[1:].tolist())), 1, array) | |
print(serializer_array) |
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
.. with r.pipeline() as pipe: | |
... while 1: | |
... try: | |
... # 关注一个key | |
... pipe.watch('xiaorui.cc') | |
... current_value = pipe.get('xiaorui.cc') | |
... next_value = int(current_value) + 1 | |
... #事物开始 | |
... pipe.multi() | |
... pipe.set('xiaorui.cc', next_value) |
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
def _transaction(watch_arg=None, use_pipe=True, ): | |
# """ | |
# wrapper class | |
# :return: | |
# """ | |
# | |
# def wrapper(func): | |
# """ | |
# :return: | |
# """ |
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
import pkgutil | |
def import_submodules(context, root_module, path): | |
""" | |
Import all submodules and register them in the ``context`` namespace. | |
for examples: | |
>>> import_submodules(locals(), __name__, __path__) |
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
#https://coderwall.com/p/jo39na/python-decorators-using-self | |
# todo it inlater | |
states = {"a":"b", "b":"c", "c":"d", "d","end"} | |
class Foo: | |
#skip some staff | |
def will_change_state(f): | |
def wrapper(*args): | |
ret = f(*args) |
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
$ gem update --system # 这里请翻墙一下 | |
$ gem -v | |
2.6.3 | |
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ | |
$ gem sources -l | |
https://gems.ruby-china.org | |
# 确保只有 gems.ruby-china.org |
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
import socket | |
import sys | |
import urllib.parse | |
from contextlib import closing | |
def check_address_port(tcp): | |
""" | |
:param tcp: | |
:return: | |
""" |
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
import importlib | |
import inspect | |
from functools import lru_cache | |
@lru_cache(maxsize=10240) | |
def loads_requests(): | |
commands = {} | |
modules_data = inspect.getmembers(importlib.import_module(__name__)) | |
for func_name, func in modules_data: | |
if inspect.isfunction(func) and func_name.startswith("On"): |