configuring a remote for a fork 查看远程状态 git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) 添加一个将被同步给 fork 远程的上游仓库 git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git 再次查看远程状态 git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push) syncing a fork 从原仓库fetch数据到本地,并会被存储在本地分支upstream/master git fetch upstream # remote: Counting objects: 75, done. # remote: Compressing objects: 100% (53/53), done.
Read More →
#!/bin/sh if [ $# -lt 1 ] then echo Usage:xx exit 1 fi NAME=$1 echo $1 PID=`ps -ef|grep $NAME$ |grep -v $0 |awk '{print $2}'` echo $PID kill -9 $PID echo killed
@functools.lru_cache()此行为关键 import time from functools import wraps import functools def clock(func): @wraps(func) def clocked(*args, **kwargs): start = time.time() result = func(*args, **kwargs) elapsed = time.time() - start name = func.__name__ args_list = [] if args: args_list.append(','.join(repr(arg) for arg in args)) if kwargs: pairs = ['%s=%r' % (k, w) for k, w in sorted(kwargs.items())] args_list.append(','.join(pairs)) args_str = ','.join(args_list) print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, args_str, result)) return result return clocked @functools.
Read More →
1.ulimit -c unlimited 2./proc/sys/kernel/core_pattern 2.或者/etc/sysctl.conf中添加kernel.core_pattern=core_%e_%p或sysctl -w kernel.core_pattern=core_%e_%p 3.查看/etc/security/limits.conf * soft core unlimited //所有用户 <user-login-id> soft core unlimited //设置某个用户 还有hard core需要考虑$sysctl -a|grep core_pattern kernel.core_pattern = |/usr/libexec/abrt-hook-ccpp /var/cache/abrt %p %s %u %c
“abrtd” creates a sub-directory (named something like “ccpp-1279914365-14618”) in the directory “/var/cache/abrt” as shown in the value of the variable. This also means that the core files will also be stored in that sub-directory in the “/var/cache/abrt” directory (in addition to the current directory where application was run).
Read More →
并不是所有的装饰器都使用了@wraps,因此这里的方案并不全部适用。特别的,内置的装饰器@staticmethod和@classmethod就没有遵循这个约定(它们把原始函数存储在属性func中)
dis模块反编译
double小数前后加起来的有效数字只有16位,当给定的double有效数在16位以内转换为字符串不会丢失精度
Code:
char precisionStr[100] = {0}; double precisionTest = 11.437565871234012; sprintf(precisionStr, "%.20f", precisionTest); cout << "precision----" << precisionStr << endl; precisionTest = 119.437565871234012; sprintf(precisionStr, "%.20f", precisionTest); cout << "precision----" << precisionStr << endl; Output:
precision----11.43756587123401224915 precision----119.43756587123401402550
switch_dict = { 'char': lambda x: 'i am char' + x, 'double': lambda x: 'i am double' + x, 'int': lambda x: 'i am int' + x } print(switch_dict['char']('999'))