Skip to content

Instantly share code, notes, and snippets.

View nooperpudd's full-sized avatar

Winton nooperpudd

  • China
View GitHub Profile
@nooperpudd
nooperpudd / regex.py
Created August 22, 2018 10:07
python regex
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
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";
@nooperpudd
nooperpudd / numpy.py
Created May 24, 2018 01:00
numpy array
array[:, 1::]
serializer_array = np.apply_along_axis(
lambda x: (x[0], self._serializer.dumps(x[1:].tolist())), 1, array)
print(serializer_array)
.. 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)
def _transaction(watch_arg=None, use_pipe=True, ):
# """
# wrapper class
# :return:
# """
#
# def wrapper(func):
# """
# :return:
# """
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__)
#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)
$ 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
@nooperpudd
nooperpudd / address.py
Created March 30, 2018 11:17
check address port is down or not
import socket
import sys
import urllib.parse
from contextlib import closing
def check_address_port(tcp):
"""
:param tcp:
:return:
"""
@nooperpudd
nooperpudd / loads_func.py
Last active January 7, 2018 09:34
load function
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"):