首页 文章 精选 留言 我的

精选列表

搜索[基因多效性],共10000篇文章
优秀的个人博客,低调大师

Python规范:提高可读性

PEP 8 规范 PEP 是 Python Enhancement Proposal 的缩写,翻译过来叫“Python 增强规范”。 缩进规范 PEP 8 规范告诉我们,请选择四个空格的缩进,不要使用 Tab,更不要 Tab 和空格混着用。 第二个要注意的是,每行最大长度请限制在 79 个字符。 空行规范 PEP 8 规定,全局的类和函数的上方需要空两个空行,而类的函数之间需要空一个空行。 空格规范 函数的参数列表中,调用函数的参数列表中会出现逗号,请注意逗号后要跟一个空格,这是英语的使用习惯,也能让每个参数独立阅读,更清晰。 冒号后面也要跟一个空格。 在#后、注释前加一个空格。 操作符,例如+,-,*,/,&,|,=,==,!=,请在两边都保留空格。不过与此对应,括号内的两端并不需要空格。 换行规范 控制每行的最大长度不超过 79 个字符,但是有时候,函数调用逻辑过长而不得不超过这个数字时按以下规范: def solve1(this_is_the_first_parameter, this_is_the_second_parameter, this_is_the_third_parameter, this_is_the_forth_parameter, this_is_the_fifth_parameter, this_is_the_sixth_parameter): return (this_is_the_first_parameter + this_is_the_second_parameter + this_is_the_third_parameter + this_is_the_forth_parameter + this_is_the_fifth_parameter + this_is_the_sixth_parameter) def solve2(this_is_the_first_parameter, this_is_the_second_parameter, this_is_the_third_parameter, this_is_the_forth_parameter, this_is_the_fifth_parameter, this_is_the_sixth_parameter): return this_is_the_first_parameter + this_is_the_second_parameter + this_is_the_third_parameter + \ this_is_the_forth_parameter + this_is_the_fifth_parameter + this_is_the_sixth_parameter (top_secret_func(param1=12345678, param2=12345678, param3=12345678, param4=12345678, param5=12345678).check() .launch_nuclear_missile().wait()) top_secret_func(param1=12345678, param2=12345678, param3=12345678, param4=12345678, param5=12345678).check() \ .launch_nuclear_missile().wait() 1.通过括号来将过长的运算进行封装. 2.通过换行符来实现. 文档规范 import 尽量放在开头. 不要使用 import 一次导入多个模块. from module import func 这样的语句,请确保 func 在本文件中不会出现命名冲突。或者通过 from module import func as new_func 来进行重命名,从而避免冲突。 注释规范 行注释并不是很推荐的方式。 文档描述 docstring 的写法,它是用三个双引号开始、三个双引号结尾。我们首先用一句话简单说明这个函数做什么,然后跟一段话来详细解释;再往后是参数列表、参数格式、返回值格式。 class SpatialDropout2D(Dropout): """Spatial 2D version of Dropout. This version performs the same function as Dropout, however it drops entire 2D feature maps instead of individual elements. If adjacent pixels within feature maps are strongly correlated (as is normally the case in early convolution layers) then regular dropout will not regularize the activations and will otherwise just result in an effective learning rate decrease. In this case, SpatialDropout2D will help promote independence between feature maps and should be used instead. Arguments: rate: float between 0 and 1. Fraction of the input units to drop. data_format: 'channels_first' or 'channels_last'. In 'channels_first' mode, the channels dimension (the depth) is at index 1, in 'channels_last' mode is it at index 3. It defaults to the `image_data_format` value found in your Keras config file at `~/.keras/keras.json`. If you never set it, then it will be "channels_last". Input shape: 4D tensor with shape: `(samples, channels, rows, cols)` if data_format='channels_first' or 4D tensor with shape: `(samples, rows, cols, channels)` if data_format='channels_last'. Output shape: Same as input References: - [Efficient Object Localization Using Convolutional Networks](https://arxiv.org/abs/1411.4280) """ def __init__(self, rate, data_format=None, **kwargs): super(SpatialDropout2D, self).__init__(rate, **kwargs) if data_format is None: data_format = K.image_data_format() if data_format not in {'channels_last', 'channels_first'}: raise ValueError('data_format must be in ' '{"channels_last", "channels_first"}') self.data_format = data_format self.input_spec = InputSpec(ndim=4) 命名规范 变量使用小写,通过下划线串联起来,例如:data_format、input_spec、image_data_set。唯一可以使用单字符的地方是迭代,比如 for i in range(n) 这种,为了精简可以使用。如果是类的私有变量,请记得前面增加两个下划线。 常量,最好的做法是全部大写,并通过下划线连接,例如:WAIT_TIME、SERVER_ADDRESS、PORT_NUMBER。 函数名,同样也请使用小写的方式,通过下划线连接起来,例如:launch_nuclear_missile()、check_input_validation()。 类名,则应该首字母大写,然后合并起来,例如:class SpatialDropout2D()、class FeatureSet()。 代码分解技巧 不写重复代码。 如: if i_am_rich: money = 100 send(money) else: money = 10 send(money) 都有send函数,可改为: if i_am_rich: money = 100 else: money = 10 send(money) 代码嵌套过深: #Python学习交流QQ群:857662006 def send(money): if is_server_dead: LOG('server dead') return else: if is_server_timed_out: LOG('server timed out') return else: result = get_result_from_server() if result == MONEY_IS_NOT_ENOUGH: LOG('you do not have enough money') return else: if result == TRANSACTION_SUCCEED: LOG('OK') return else: LOG('something wrong') return 可改为: def send(money): if is_server_dead: LOG('server dead') return if is_server_timed_out: LOG('server timed out') return result = get_result_from_server() if result == MONET_IS_NOT_ENOUGH: LOG('you do not have enough money') return if result == TRANSACTION_SUCCEED: LOG('OK') return LOG('something wrong') 以一个简单的二分搜索来举例说明。给定一个非递减整数数组,和一个 target,要求找到数组中最小的一个数 x,可以满足 x*x > target。一旦不存在,则返回 -1。 代码实现如果如下所示,那么可以再以一个函数只干一件事情的原则再优化下。 def solve(arr, target): l, r = 0, len(arr) - 1 ret = -1 while l <= r: m = (l + r) // 2 if arr[m] * arr[m] > target: ret = m r = m - 1 else: l = m + 1 if ret == -1: return -1 else: return arr[ret] print(solve([1, 2, 3, 4, 5, 6], 8)) print(solve([1, 2, 3, 4, 5, 6], 9)) print(solve([1, 2, 3, 4, 5, 6], 0)) print(solve([1, 2, 3, 4, 5, 6], 40)) 优化如下: def comp(x, target): return x * x > target def binary_search(arr, target): l, r = 0, len(arr) - 1 ret = -1 while l <= r: m = (l + r) // 2 if comp(arr[m], target): ret = m r = m - 1 else: l = m + 1 return ret def solve(arr, target): id = binary_search(arr, target) if id != -1: return arr[id] return -1 print(solve([1, 2, 3, 4, 5, 6], 8)) print(solve([1, 2, 3, 4, 5, 6], 9)) print(solve([1, 2, 3, 4, 5, 6], 0)) print(solve([1, 2, 3, 4, 5, 6], 40)) 类中属性很多时可以抽出相同特性的单独作为类,如: class Person: def __init__(self, name, sex, age, job_title, job_description, company_name): self.name = name self.sex = sex self.age = age self.job_title = job_title self.job_description = description self.company_name = company_name job_title , job_description , company_name 都与工作有关,表达是同一个意义实体,就可以抽出单独作为类: class Person: def __init__(self, name, sex, age, job_title, job_description, company_name): self.name = name self.sex = sex self.age = age self.job = Job(job_title, job_description, company_name) class Job: def __init__(self, job_title, job_description, company_name): self.job_title = job_title self.job_description = description self.company_name = company_name

优秀的个人博客,低调大师

Linux中周期性任务

用途: 按照设置的时间间隔为用户反复执行某一项固定的系统任务 软件包: cronie , crontabs 系统服务 crond 日志文件 : /var/log/crond 启动计划任务,并且设置开机自启 systemctl start crond [root@openstack ~]# systemctl enable crond 编辑: crontab -e -u 用户名 格式 : 分 时 日 月 周 任务命令行(绝对路径) 查看 : crontab -l ]# crontab -l 50 21 * /usr/sbin/poweroff清除 : crontab -r -u 用户名 # crontab -r -u root[root@openstack ~]# crontab -l no crontab for root

优秀的个人博客,低调大师

阶段性总结_学习笔记

从11月6日到12月6日, 一个月从入门到放弃 目前为止,学习了 FHS,linux文件架构标准 / /boot /dev /opt /mnt /media /proc /tmp /usr /etc /lib 等等 文件的查找 locate find。 文本处理工具 cat,tac,grep,sed,wc,sort,uniqc,tr,cut,paste,diff,head,tail,less,more, 文件的操作 cp,mv,rm,mkdir,rmdir,touch,file,stat,tree,ls,ln vi及vim工具的使用 压缩解压缩 tar,gzip,bz2,xz,cpio 用户、组、文件权限的管理 useradd usermod userdel finger,id,chsh,chfn passwd groupadd,groupmod,groupdel newuser,newgrp, chmod,chown,chgrp, lsattr,chattr,getfacl,setfacl 磁盘及文件系统管理 fdisk,gdisk,parted,partx,partprobe,kpartx mkfs,tune2fs,dume2fs,blk,lsblk,df,dh,dd mount,umount 高级文件系统管理 quota, raid,lvm mdadm bash shell脚本编写初级 linux基础命令 type,who,tty,which,whatis,where,hash,history,date,man, lscpu,free, 软件包管理 rpm,yum 通配符glob,管道符|,正则表达式 man 7 glob bash的快捷操作方式。 本文转自 lajifeiwomoshu 51CTO博客,原文链接:http://blog.51cto.com/lajifeiwomoshu/2048503

优秀的个人博客,低调大师

zabbix3.0.4监控nginx性

在zabbixagentd客户端上,查看nginx是否加载了–with-http_stub_status_module。因为zabbix监控nginx是根据nginx的Stub Status模块,抓取Status模块所提供的数据。假如以前没开启,现在想启用StubStatus 模块,在编译nginx 的时候要加上参数 –with-http_stub_status_module,执行./configure && make就可以了,不用make install。不过,一般情况下都是安装了的。 检查with-http_stub_status_module有没有安装 nginx status 开启方法: server{ ... location/status{ stub_statuson; access_logoff; allow123.123.123.123;#zabbix服务器IP地址,一般是内网地址。 allow127.0.0.1; denyall; } 在nginx配置文件中: 启动nginx [root@iZ25sh42s8wZvhosts]#/usr/local/nginx/sbin/nginx-t nginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisok nginx:configurationfile/usr/local/nginx/conf/nginx.conftestissuccessful [root@iZ25sh42s8wZvhosts]#/etc/init.d/nginxreload ReloadingNginx:[OK] 用curl做测试 状态页面各项数据的意义:active connections – 当前 Nginx 正处理的活动连接数。serveraccepts handled requests — 总共处理了 233851 个连接 , 成功创建 233851 次握手 (证明中间没有失败的 ), 总共处理了 687942 个请求 ( 平均每次握手处理了 2.94 个数据请求 )。reading — nginx 读取到客户端的 Header 信息数。writing — nginx 返回给客户端的 Header 信息数。waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading + writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接。 zabbix-agent 配置 有3个步骤,首先是编写获取Nginx信息脚本,接着配置中增加key信息,然后重启agent 服务。 ①编写Nginx监控脚本,记住路径,后面配置需要用到,注意脚本权限问题,agent运行用户要能执行。 mkidr -p /usr/local/zabbix-agent/scripts/ cd /usr/local/zabbix-agent/scripts vi nginx-check.sh #!/bin/bash ################################## # Zabbix monitoring script # # nginx: # - anything available via nginx stub-status module # ################################## # Contact: # vincent.viallet@gmail.com # Zabbix requested parameter ZBX_REQ_DATA="$1" ZBX_REQ_DATA_URL="$2" # Nginx defaults NGINX_STATUS_DEFAULT_URL="http://bbs.jzq.pub/nginx-status" #(这里写网站的域名) WGET_BIN="/usr/bin/wget" # # Error handling: # - need to be displayable in Zabbix (avoid NOT_SUPPORTED) # - items need to be of type "float" (allow negative + float) # ERROR_NO_ACCESS_FILE="-0.9900" ERROR_NO_ACCESS="-0.9901" ERROR_WRONG_PARAM="-0.9902" ERROR_DATA="-0.9903" # either can not connect / bad host / bad port # Handle host and port if non-default if [ ! -z "$ZBX_REQ_DATA_URL" ]; then URL="$ZBX_REQ_DATA_URL" else URL="$NGINX_STATUS_DEFAULT_URL" fi # save the nginx stats in a variable for future parsing NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null) # error during retrieve if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then echo $ERROR_DATA exit 1 fi # # Extract data from nginx stats # case $ZBX_REQ_DATA in active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d' ';; accepted_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' ';; handled_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' ';; handled_requests) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f4 -d' ';; reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d' ';; writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d' ';; waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d' ';; *) echo $ERROR_WRONG_PARAM; exit 1;; esac exit 0 ~ chmodo+x/usr/local/zabbix-agent/scripts/nginx-check.sh agent的配置文件 /etc/zabbix/zabbix_agentd.conf 中定义了其他key的包含目录 Include=/etc/zabbix/zabbix_agentd.d/, 如果没有这个配置请自己添加下。接着在 /etc/zabbix/zabbix_agentd.d/ 目录新建一个文件 nginx-params.conf, 内容如下 加入以下内容: UserParameter=nginx[*],/usr/local/zabbix-agent/scripts/nginx-check.sh "$1" /etc/init.d/zabbix-agent restart 模板文件比较长留一个下载地址https://github.com/jizhang/zabbix-templates/blob/master/nginx/nginx-template.xml 在新建的主机--选择该模板。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册