0%

1.鼠标悬停的实现方式

a)

1
2
3
test = browser.find_element_by_id("qmenu")
hover = ActionChains(browser).move_to_element(test)
hover.perform()

b)

1
2
3
4
5
6
from selenium.webdriver.common.action_chains import ActionChains
def hover(self):
wd = webdriver_connection.connection
element = wd.find_element_by_link_text(self.locator)
hov = ActionChains(wd).move_to_element(element)
hov.perform()

2.翻页功能

1
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

gitlab从8.1升级到8.7.4,ssh方式已经可以提交获取代码了,但是通过http方式还是502。

查询nginx后台日志显示 connect() to unix://var/opt/gitlab/gitlab-git-http-server/socket failed (13: Permission denied) 把nginx用户加到文件所在的组后,再次尝试依然是502,但是错误日志内容有了变化 connect() to unix://var/opt/gitlab/gitlab-git-http-server/socket failed (111: Connection refused) 连接拒绝了。google搜结果,在这里找到了答案。修改nginx配置,把 /var/opt/gitlab/gitlab-git-http-server/socket 替换为 /var/opt/gitlab/gitlab-workhorse/socket 就可以了。

1.使用cp时强制覆盖,两种方案:(来源)
a) /bin/cp -rf /zzz/zzz/* /xxx/xxx
b) /bin/cp -rf /zzz/zzz/* /xxx/xxx
原来当使用root登陆时,环境变量中会有一条 alias cp = cp -i ,用于防止管理员误操作。

2.crontab环境变量
crontab执行命令时,并不适用当前用户的环境变量,编写任务时最好使用全路径。确实需要环境变量时,可以在crontab文件的指令中直接执行 source ~/.bash_profile/etc/profile等加载用户环境变量。
3.crontab中的run-parts
运行指定目录中的所有脚本,注意脚本文件中不能含有’.’,因为不含有任何参数的run-parts将会忽略他们。例如backup.sh这个脚本是不会被执行的。

Nginx出现的413 Request Entity Too Large错误,这个错误一般在上传文件的时候出现,打开nginx主配置文件nginx.conf,找到http{}段,添加
解决方法就是
打开nginx主配置文件nginx.conf,一般在/usr/local/nginx/conf/nginx.conf这个位置,找到http{}段,修改或者添加
代码如下 复制代码
client_max_body_size 2m;
然后重启nginx,
代码如下 复制代码

sudo /etc/init.d/nginxd reload
即可。
要是以php运行的话,这个大小client_max_body_size要和php.ini中的如下值的最大值差不多或者稍大,这样就不会因为提交数据大小不一致出现错误。
代码如下 复制代码
post_max_size = 2M
upload_max_filesize = 2M
重启NGINX
代码如下 复制代码
kill -HUP cat /usr/local/nginx/nginx.pid
恢复正常

除非特别声明,PHP100新闻均为原创或投稿报道,转载请注明作者及原文链接
原文地址: http://www.php100.com/html/program/nginx/2013/0905/5516.html

PHP模版文件打开后出现”Parse error: syntax error, unexpected end of file in ‘file path’”,在stackoverflow找到了解决方法。

在代码的行尾要尽量避免这种

1
{?>

和这种代码

1
<?php}

要使用空格分开,像这样

1
2
{ ?>
<?php {

还要避免使用 <? 而应该使用 <?php

原文DIRECT SQL QUERIES IN MAGENTO有点长,直接转过来了。
Magento’s use of data models provide a great way to access and modify data. Using aptly named methods and clever abstraction, Varien hide away the complex SQL needed to perform data operations. While this makes learning models easier, it often impacts the speed of the operation and therefore the responsiveness of your site. This is especially true when saving models that use the EAV architecture. More often that not, this cannot be avoided, however there are some situations where executing direct SQL queries would be simpler and much quicker leading to a more optimised Magento installation. An example of this is updating product prices globally in Magento. It would be easy enough to write some Magento code that looped through all products and modified the price. On a large data set, saving each individual product can take a long time and therefore make the system unusable. To combat this, it is possible to issue a direct SQL query which could update 1000’s of products in 1 or 2 seconds.

阅读全文 »

转载自:为 SSL 站点启用 Certificate Transparency 功能
下载 nginx 源代码和 nginx-ct 的源代码:

1
2
3
4
wget http://nginx.org/download/nginx-1.9.6.tar.gz
wget -O nginx-ct.zip https://github.com/grahamedgecombe/nginx-ct/archive/master.zip
tar zxf nginx-1.9.6.tar.gz
unzip nginx-ct.zip

编译 nginx ( 你也可以带上你自己的参数,加上 ssl 和 ct module 就可以)

1
2
cd nginx-1.9.6/
./configure --with-http_v2_module --with-http_ssl_module --add-module=../nginx-ct-master

创建 SCT 的文件夹

1
mkdir /etc/ssl/scts/

下载证书提交工具

1
2
3
4
5
wget -O ct-submit.zip https://github.com/grahamedgecombe/ct-submit/archive/master.zip
unzip ct-submit.zip
cd ct-submit-master/
# 请确保已经安装 go 语言
go build

将证书提交到 Certificate Transparency Log 服务器,假设你的 SSL 证书在 /etc/ssl/server.crt (带证书链的)

1
2
3
4
5
6
7
8
9
sudo sh -c "./ct-submit-master ct.googleapis.com/aviator \
</etc/ssl/server.crt \
>/etc/ssl/scts/aviator.sct"
sudo sh -c "./ct-submit-master ct.googleapis.com/pilot \
</etc/ssl/server.crt \
>/etc/ssl/scts/pilot.sct"
sudo sh -c "./ct-submit-master ct.googleapis.com/rocketeer \
</etc/ssl/server.crt \
>/etc/ssl/scts/rocketeer.sct"

然后在 nginx 配置中添加

1
2
ssl_ct on;
ssl_ct_static_scts /etc/ssl/scts;

以上内容转载自:为 SSL 站点启用 Certificate Transparency 功能
可能因为使用的linux发行版不一样,我用的是centos,在执行nginx的configure时需要指定openssl的源码路径(openssl 1.0.2+,我用的是 openssl-1.0.2f,奇怪的版本号),否则会有未定义函数的报错。

--with-openssl=/path/to/openssl

Magento在xml文件中block的type解释。结果也是在网上搜到的,按照 type="A/B"的格式来解释。
答案转自链接

1
<block type="page/html" name="root" output="toHtml" template="example/view.phtml"> 

A是一个模块的别名。在这个例子里,’page’是Mage_Page_block(在文件app/code/core/Mage/Page/etc/config.xml中定义)。
B是A模块中的一个class名,每个词的首字母大写。在这个例子中,html转换为Html,是Mage_Page_block_Html的别名。这个文件大概在app/code/core/Mage/Page/Block/Html.php ,因为在Magento中,类名可以直接转换为路径。
如果用model别名替换block别名结果则是Mage_Page_model。换成resource models和helpers也是一样的。自己写的模块如果包含block、models、helpers也应该在配置文件里(config/)定义。
链接

Warning: include(SoapClient.php): failed to open stream: No such file or directory

新部署magento时,出现上面一条错误,原因是未安装php-soap,安装php-soap就没有错误了,要根据已安装的php版本来选择。

通过下面的指令可以挂载目录,并指定所属用户和用户组

sudo mount -t vboxsf -o uid=1000,gid=1000 host_shared_folder /path/to/local/