bad

JS编程规范

假装没事ソ 提交于 2019-12-19 04:12:48
  在第一家公司用C++时,公司有着严格的代码规范,甚至到了严苛的地步,现在回想起来,对它充满感激。一个好的习惯让你收益终身。   之后使用JS/TS却没有为自己定一套编程规范,所幸为时不晚,在这里参考airbnb公司代码规范。    -----该规范转载至阮一峰大大的ES入门   1.块级作用域   1)let 取代var   ES6 提出了两个新的声明变量的命令: let 和 const 。其中, let 完全可以取代 var ,因为两者语义相同,而且 let 没有副作用。    'use strict'; if (true) { let x = 'hello'; } for (let i = 0; i < 10; i++) { console.log(i); }      上面代码如果用 var 替代 let ,实际上就声明了两个全局变量,这显然不是本意。变量应该只在其声明的代码块内有效, var 命令做不到这一点。   var 命令存在变量提升效用, let 命令没有这个问题。 'use strict'; if (true) { console.log(x); // ReferenceError let x = 'hello'; }      上面代码如果使用 var 替代 let , console.log 那一行就不会报错,而是会输出 undefined

WOE(证据权重)为何这样计算?

前提是你 提交于 2019-12-15 19:44:35
更多大数据分析、 建模 等内容请关注公众号《 bigdata modeling 》 By 小石头 1、概念回顾 先简单回顾一下WOE的含义。假设x是类别变量或分箱处理过的连续变量,含R个类别或分段,取值为{C1, ..., Cr, ..., CR};y是目标变量,取值为0(Good)或1(Bad)。x和y的频数表如下: WOE的定义如下: 变量x第r类的WOE为: WOE是变量x第r类中Bad与Good的比率与整个样本中Bad与Good的比率的比值的对数,其衡量第r类对Bad和Good的比率的影响程度。WOE等于0,表示该类别中Bad与Good的比率与整体样本中Bad与Good的比率相等,说明该类别完全没有区分度;WOE大于0,表示该类别中Bad与Good的比率大于整体样本中Bad与Good的比率;WOE小于0,表示该类别中Bad与Good的比率小于整体样本中Bad与Good的比率。 2、理论推导 那么,WOE为何这样计算?从上面的WOE定义可以发现,WOE编码是有监督方法,所以计算变量x的WOE可以看做用x拟合y的优化过程。将x的WOE写成 ,其中 是二元虚拟变量,如果变量x取第r类,则 ,否则 。 (1)定义如下模型: (2)定义对数损失函数: (3)整体样本上的损失为: (4) 损失最小化,即令偏导=0: 因此,WOE是使损失最小化的编码方式,计算WOE就是一次单变量建模过程

学习Express之nginx配置负载均衡

故事扮演 提交于 2019-12-04 13:39:20
关于 express-demo 关于 部署 express-demo 虽然 PM2 已有负载均衡的功能,但是他只对多进程之间进行处理,如果是多个服务器之间,就无法办到了,这里我们选用 nginx 。 服务器准备 s0:CentOS,172.16.70.175,nginx 服务器 s1: CentOS, 172.16.70.174,web 服务器 s2: CentOS, 172.16.70.173,web 服务器 1、配置 s1,s2 由于之前已有说明,这不再细说。参考: http://my.oschina.net/songzhu/blog/610337 修改 s1 服务器的 config.js 内容为: var config = { server:"172.16.70.174" }; module.exports = config; 重启 web pm2 restart pm2-start.json 修改 s2 服务器的 config.js 内容为: var config = { server:"172.16.70.173" }; module.exports = config; 重启 web pm2 restart pm2-start.json 2、配置 s0 安装 nginx $ rpm -ivh http://nginx.org/packages/centos/7/x86

django配置apache服务器(下)

限于喜欢 提交于 2019-12-03 23:57:26
接着上篇django在apache上需要下载 mod_wsgi.so 把扩张名whl改成zip,解压后会有mod-wsgi.so放在\Apache24\modules下, 在文件conf/httd.conf中添加: LoadModule wsgi_module modules/mod_wsgi.so 这个按文件中的格式添加就行。 启动apache,如果能启动起来就说明配置对了。 否则就错了。最常见的错误就是mod_wsgi.so版本问题 。上面的那个网站版本不全,可以在这里下载: http://download.csdn.net/detail/copter/9192361 别人编译好的各个版本。 启动后就要配置django项目,有两种方法:在httpd.conf直接配置;在django创建个文件,在httpd.conf中包含进去。两种添加的内容都是一样的,推荐后者,扩张性更好: ----------------------------------------------------------------------------------- 1.。。。。直接在httpd.conf直接配置 WSGIScriptAlias / "C:/Users/liuxi_001/Desktop/web/MyBlog/MyBlog/wsgi.py" WSGIPythonPath "C:/Users

278. First Bad Version

折月煮酒 提交于 2019-12-03 16:14:52
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad. You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

How do I replace bad words with php?

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some text i need to filter out a list of bad words in like: $bad_words = array( 'word1' => 'gosh', 'word2' => 'darn', ); I can loop through these and replace one at a time but that is slow right? Is there a better way? 回答1: Yes there is. Use preg_replace_callback() :

Preventing bad access crash for popViewControllerAnimated in uinavigationcontroller setup

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So, under low memory, my root view is unloaded. That's expected and accounted for. However, how do I deal with modal/pushed view controllers who need to be popped, since they reference the main navigationController? I have a custom Done button in a pushed view controller, which calls [self.navigationController popViewControllerAnimated:YES]. If the root view has been unloaded, this gives a bad access error. Is there a better way to do this? My setup is AppDelegate has a NavigationController this NavigationController has a view controller

LeetCode_278. First Bad Version

会有一股神秘感。 提交于 2019-12-03 03:57:19
278. First Bad Version Easy You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad. You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the

Google oauth2 and 400 bad request: Bug on Google side?

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have Google oauth2 working fine on our website. However, often Chrome users complaint about 400 Bad request and we were able to reproduce it now. Based on the investigation, it indeed looks like a bug on Google side: It only happens with users who were authenticated earlier and logged-in with multiple accounts on GMail It doesn't happen when the same user uses incognito window. This problem is universal and not only with our website. At this moment, I am not able to login using google oauth2 on any website including StackOverflow.

Finding non-numeric rows in dataframe in pandas?

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a large dataframe in pandas that apart from the column used as index is supposed to have only numeric values: df = pd.DataFrame({'a': [1, 2, 3, 'bad', 5], 'b': [0.1, 0.2, 0.3, 0.4, 0.5], 'item': ['a', 'b', 'c', 'd', 'e']}) df = df.set_index('item') How can I find the row of the dataframe df that has a non-numeric value in it? In this example it's the fourth row in the dataframe, which has the string 'bad' in the a column. How can this row be found programmatically? 回答1: You could use np.isreal to check the type of each element (