jeffsui / jeffsui.github.io Goto Github PK
View Code? Open in Web Editor NEWpinghailinfeng's blog main website
Home Page: http://jeffsui.github.io
pinghailinfeng's blog main website
Home Page: http://jeffsui.github.io
jmeter -n -t test.jmx -j logs/test.log -l report/result.csv
jmeter -r remote_server_ip -n -t test.jmx -j logs/test.log -l report/result.csv
或者
jmeter -R remotes_server -n -t test.jmx -j logs/test.log -l report/result.csv
remotes_server 由JMETER_HOME\bin\jmeter.properties中remote_hosts 指定
jmeter -H 127.0.0.1 -P 8888 -n -t test.jmx -j logs/test.log -l report/result.csv
jmeter -g report/result.csv -j report/run-board.log -e -o report/dashboard
通过jenkins
生成jmeter
测试报告后发现,在最新版本的Chrome
、Firefox
中页面样式无法加载。
低版本的浏览器例如猎豹、ie8等可以正常加载。
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none';script-src 'unsafe-inline' http://code.jquery.com/jquery-2.1.0.min.js; img-src dohko.hpeswlab.net 'self' data: ; style-src 'unsafe-inline' 'self';");
或者
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","");
here is an example about “Universal Description, Discovery and Integration,UDDI”
python3.6.5
django
根据官方路线图 django1.11是最后一个支持python2.7的版本了,以后只支持python3.x
此处我安装的版本是2.0.4
mysqlclient
pip install mysqlclient
windows下mysql-python安装出错
注意:根据自己python版本下载对应的安装包
django
django startproject mysite
http://localhost:8000
使用git bash
执行创建超级管理员,提示信息如下:
Superuser creationskipped due to not running in a TTY. You can run manage.pycreatesuperuser in yourproject to create one manually.
1.打开cmd
2. python manage.py createsuperuser
3. 访问管理员路径 http://127.0.1.1:8000/admin
所以设置ALLOWED_HOSTS = [ ‘192.168.0.33’]
eg_sshd
镜像FROM ubuntu:16.04
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
$ docker build -t eg_sshd .
$ docker run -d -P --name test_sshd eg_sshd
$ docker port test_sshd 22
现在就可以通过 root
用户 登陆docker宿主机 下的容器了,类似下面的操作:
$ ssh [email protected] -p 49154
# The password is ``screencast``.
root@f38c87f2a42d:/#
$ docker stop test_sshd
$ docker rm test_sshd
$ docker rmi eg_sshd
原文地址: https://docs.docker.com/engine/examples/running_ssh_service/#run-a-test_sshd-container
git pull 失败 ,提示:fatal: refusing to merge unrelated histories
关于这个问题,可以参考。
在进行git pull 时,添加一个可选项
git pull origin master --allow-unrelated-histories
Since git2.9版本
参考:Git报错:fatal: Authentication failed for XXX
解决方案:
git config --system --unset credential.helper
git bash
backspace does not work参考:
windows-version-of-rxvt-backspace-key-doesnt-work-as-expected
backspace-does-not-work-git-bash
解决方案:
vim .bashrc
TERM = xterm-256color
重启git bash
搞定
错误是因为本地保存密码,但是你输入的用户名密码错误导致
git config --system --unset credential.helper
#输入正确的用户名密码
git push
wget https://bootstrap.pypa.io/get-pip.py
错误:
httpconnectionpool(host='pypi.python.org' port=443) read timed out
github
源码安装wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
同样是timeout。
yum -y install epel-release
yum install -y python-pip
备注: centos官方源不包括 python-pip
,EPEL源才支持
pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
npm
是 nodejs
的包管理器,包含安装,查看,更新,卸载...操作的工具。
全局安装:npm install -g module_name
本地安装: npm install module_name
全局卸载:npm uninstall -g module_name
本地卸载: npm uninstall module_name
全局查看: npm list -g --depth=1
本地查看: npm list
查看某个包的信息: npm info bootstrap
检查更新: npm outdated
执行更新: npm update
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.13.6</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<finalName>java.xxx</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
下面的代码
AppiumDriver<MobileElement> driver;
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4823/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
一直报androiddriver无法识别的error,后来发现根本就是jar包没有引用的问题。
参考:
不能初始化androiddriver
the-type-org-openqa-selenium-remote-http-httpclientfactory-cannot-be-resolved
#【错误描述】
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: XXX(application name)
#【解决问题】
创建应用后在settings.py文件INSTALLED_APPS手动注册应用导致该错误。
django == 2.2.4 不需要手动注册
django创建应用的时候已经帮你注册了xx.apps.XXConfig了
<!DOCTYPE html>
<html>
<head>
<title>一列水平居中布局</title>
<meta charset="utf-8">
</head>
<body>
<div class="one-center-col">一列布局</div>
</body>
</html>
css代码
<style>
.one-center-col {
width: 1000px;
height: 700px;
background-color: grey;
margin: 0 auto;
}
</style>
其中对于宽度固定的元素,只需要设置该元素的css样式(margin:0 auto;)就可以实现让该元素在其父元素的宽度下水平居中对齐显示。
网页布局常见左右两列布局,如果已知左右两列的宽度是固定值,则可以使用float浮动方式完成基本布局排版。
html代码:
<div class="container">
<div class="leftbox">左侧列</div>
<div class="rightbox">右侧列</div>
</div>
css代码
.leftbox {
width: 300px;
height: 100%;
background-color: #aadddd;
float: left;
}
.rightbox {
width: 700px;
height: 100%;
background-color: #f08844;
float: right;
}
两列布局,当已知列的宽度时,可以使用浮动属性来达到左右布局的效果,仅需设置float:left和float:right就可以轻松达到页面布局效果。
<div class="container">
<div class="leftbox">左侧列</div>
<div class="midbox">中间列</div>
<div class="rightbox">右侧列</div>
</div>
css代码
.leftbox {
width: 300px;
float: left;
}
.midbox {
width: 400px;
float: left;
}
.rightbox {
width: 300px;
float: right;
}
leftbox和midbox设置左浮动,rightbox设置右浮动。但关键的是,三个子元素的总宽度不能大于或者等于父元素的宽度。
mvn archetype:create 创建Maven项目
mvn archetype:create -DgroupId=idoall.org -DartifactId=helloworld -DpackageName=idoall.org 创建Maven的普通java项目,在命令行使用Maven Archetype 插件
mvn archetype:generate 创建Maven项目
mvn compile 编译源代码
mvn deploy 发布项目
mvn test-compile 编译测试源代码
mvn test 运行应用程序中的单元测试
mvn site 生成项目相关信息的网站
mvn clean 清除项目目录中的生成结果
mvn package 根据项目生成的jar
mvn install 在本地Repository中安装jar
mvn eclipse:eclipse 生成eclipse项目文件
mvn dependency:resolve 打印出已解决依赖的列表
mvn dependency:tree 打印整个依赖树
mvnjetty:run 启动jetty服务
mvntomcat:run 启动tomcat服务
mvn clean package -Dmaven.test.skip=true:清除以前的包后重新打包,跳过测试类
mvn install assembly:assembly 构建装配Maven Assembly 插件是一个用来创建你应用程序特有分发包的插件
mvn clean install 删除再编译
examlple
mvn archetype:generate -DgroupId=linfeng.org -DartifactId=linfeng.org.helloworld -DpackageName=linfeng.org -Dversion=1.0-SNAPSHOT
如果本地还没有建版本库,要用这个功能,先进入要放版本库的目录,在命令行执行几条命令:
$ git init <project>
$ cd <project>
$ git remote add origin ssh://<user>@<repository's url>
$ git config core.sparsecheckout true
$ echo "path1/" >> .git/info/sparse-checkout
$ echo "path2/" >> .git/info/sparse-checkout
$ git pull origin master
第一条命令git init ,先建立一个空的版本库,用实际的目录名替代。
第二条命令cd ,进入创建的新的版本库的目录。
第三条命令git remote add origin ssh://@<repository's url>,添加远程库的地址。
第四条命令git config core.sparsecheckout true,打开sparse checkout功能。
第五第六条命令echo "path1/" >> .git/info/sparse-checkout,添加2个目录到checkout的列表。路径是版本库下的相对路径,也可以用文本编辑器编辑这个文件。
第七条命令git pull origin master,拉取远程的 master 分支,也可以拉其他分支。
如果只拉取最近一次的变更,忽略以前的变更记录,在拉取时可以加参数depth,如git pull --depth=1 origin master (浅克隆)
如果以后修改了 .git/info/sparse-checkout,增加或删除部分目录,可以执行如下命令重新Checkout
git checkout master
要关闭 sparse checkout功 能,仅仅修改设置,将core.sparsecheckout设为false是不生效的,需要修改 .git/info/sparse-checkout 文件,用一个”*“号替代其中的内容,然后执行 checkout 或 read-tree 命令。
子目录的匹配
在 sparse-checkout 文件中,如果目录名称前带斜杠,如/docs/,将只匹配项目根目录下的docs目录,如果目录名称前不带斜杠,如docs/,其他目录下如果也有这个名称的目录,如test/docs/也能被匹配。
而如果写了多级目录,如docs/05/,则不管前面是否带有斜杠,都只匹配项目根目录下的目录,如test/docs/05/不能被匹配。
通配符 ““ (星号)
在 sparse-checkout 文件中,支持通配符 ““,如可以写成以下格式:
*docs/
index.*
*.gif
排除项 “!” (感叹号)
在 sparse-checkout 文件中,也支持排除项 “!”,如只想排除排除项目下的 “docs” 目录,可以按如下格式写:
/*
!/docs/
要注意一点:如果要关闭sparsecheckout功能,全取整个项目库,可以写一个”“号,但如果有排除项,必须写”/“,同时排除项要写在通配符后面。
$ npm -v
5.6.0
$ node -v
v8.11.1
npm install -g pxt
pxt target microbit
npm install
pxt serve
http://localhost:3232/#local_token=fb4dc404-38cf-4f48-e3d9-babf4b7b7c95&wsport=3233
how to install and use docker on ubuntu
sudo apt-get update
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-get update
apt-cache policy docker-engine
docker-engine:
Installed: (none)
Candidate: 1.13.0-0~ubuntu-xenial
Version table:
1.13.0-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.6-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.5-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.4-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.3-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.2-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.1-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.0-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.2-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.1-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.0-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
sudo apt-get install -y docker-engine
查看docker 状态
sudo systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2017-01-25 19:59:56 CST; 25s ago
Docs: https://docs.docker.com
Main PID: 10303 (dockerd)
CGroup: /system.slice/docker.service
├─10303 /usr/bin/dockerd -H fd://
└─10314 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-cont
Jan 25 19:59:56 ubuntu dockerd[10303]: time="2017-01-25T19:59:56.065911464+08:00" level=
JupyterLab是Jupyter Notebook的增强版本,看起来更像是一个IDE。
pip install jupyterlab
jupyter lab
JupyterLab
会在自动在浏览器中打开. See our documentation for additional details.
jupyter notebook list
输出
http://localhost:8888/?token=c8de56fa... :: /Users/you/notebooks
您可以通过运行以下命令列出当前安装的扩展:
jupyter labextension list
通过运行以下命令卸载扩展:
jupyter labextension uninstall my-extension
其中my-extension是扩展名列表中的打印名称。您也可以使用此命令卸载核心扩展(以后可以随时重新安装核心扩展)。
https://jupyterlab.readthedocs.io/en/latest/user/extensions.html
https://github.com/jupyterlab/jupyterlab#getting-help
https://gitter.im/jupyterlab/jupyterlab
http://jupyterlab.github.io/jupyterlab/
npm install -g appium
npm install -g appium-doctor
python install Appium-Python-Client
$ python -m pip install Appium-Python-Client
Collecting Appium-Python-Client
Downloading Appium-Python-Client-0.24.tar.gz
Collecting selenium>=2.47.0 (from Appium-Python-Client)
Downloading selenium-3.4.3-py2.py3-none-any.whl (931kB)
100% |████████████████████████████████| 942kB 63kB/s
Installing collected packages: selenium, Appium-Python-Client
Running setup.py install for Appium-Python-Client ... done
Successfully installed Appium-Python-Client-0.24 selenium-3.4.3
selenium
版本import selenium
selenium.__version__
默认安装了最新版的selenium3.4.3
python -m pip install -I selenium==3.0.2
命令行启动Appim
直接运行appium
一个简单的测试脚本AppiumTest.py
from appium import webdriver
des = {}
des['platformName'] = 'Android'
des['platformVersion'] = '6.0'
des['deviceName'] = 'Android Emulator'
des['app'] = "E:\\apk\\xxx.apk"
webdriver.Remote('http://localhost:4723/wd/hub', des)
python AppiumTest.py
adb devices
显示未授权,导致错误 This adb server's $ADB_VENDOR_KEYS is not set
,重新打开USB调试选项即可。des['platformVersion'] = '4.2'
导致错误 查看当前platform版本,修改为6.0
https://www.daocloud.io/mirror#accelerator-doc
docker-machine ssh default
sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=加速地址 |g" /var/lib/boot2docker/profile
exit
docker-machine restart default
这里的加速地址是daodocker分配给你的,替换即可
docker-machine restart
Micro:bit 是一款由英国广播电视公司(BBC)推出的专为青少年编程教育设计的微型电脑开发板。2016年3月-6月,microbit在英国全线铺开,BBC在线上线下配套了大量的项目教程资源和活动,每一位7年级的在校学生(11-12岁)都能免费获取一块microbit开发板用于编程学习,受益的学生数量约有百万。BBC希望通过micro:bit驱动青少年参与到创造性的硬件制作和软件编程中去,而不是每天沉浸在各式的娱乐和消费中。
http://mc.dfrobot.com.cn/portal.php?mod=topic&topicid=6
micro:bit能做什么
创客社区
于MIT Scratch3.0的青少年编程软件。支持图形化编程及python编程。支持硬件实时运行与硬件脱机上传运行两种模式
支持micro:bit的python编辑器
以DaoClound为例,注册账号,然后在https://www.daocloud.io/mirror 就可以看到DaoClound提供给您的镜像加速的URL。然后到PowerShell中去依次执行:
docker-machine ssh default
sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=加速地址 |g" /var/lib/boot2docker/profile
exit
docker-machine restart default
然后随便pull 一个镜像,体验飞一般的感觉吧!
webjar
是一个将前端开发资源打包发布的应用。访问官网获取帮助文档。
Spring Boot
自动映射资源请求路径从 /webjars
到 /META-INF/resources/webjars
所包含的jar包和静态资源。
springmvc
中可以这样配置
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
}
}
<dependencies>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
``
# 页面引入样式和javascript
<dependencies>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.30</version>
</dependency>
</dependencies>
页面通过这种方式引入
<link rel='stylesheet' href='/webjars/bootstrap/css/bootstrap.min.css'>
@ResponseBody
@RequestMapping(value = "/webjarsjs", produces = "application/javascript")
public String webjarjs() {
return RequireJS.getSetupJavaScript("/webjars/");
}
页面模板中需要这样引入
<script src="/webjarsjs"></script>
<script data-main="/js/app" src="/webjars/requirejs/require.min.js"></script>
Http Request
添加Content-Type: application/json; charset=utf-8,否则登录请求的响应结果就会失败.
Http Response
# The encoding to be used if none is provided (default ISO-8859-1)
#sampleresult.default.encoding=ISO-8859-1
step1:指定请求节点下,新建后置控制器"BeanShell PostProcessor"
step2:其脚本框中输入:prev.setDataEncoding("UTF-8");
step3:保存
python
for vscode 插件因为系统里存在python2 和 python3 两个版本,vscode默认是python2.
可以通过 ctrl+shift+p
,选择python workspace Interpreter
查看
ctrl+shift+b
,建立task.json,下面是我的配置
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "python3",
"command": "python3",
"type": "shell",
"args": [
"$(files)"
],
"presentation":{
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"options": {
"env":{
"PYTHONIOENCODING":"UTF-8"
}
}
}
]
}
其中:
"showOutput": "always"
该属性已经1.14版本中被弃用,因此替换成presentation
"options": {
"env":{
"PYTHONIOENCODING":"UTF-8"
}
}
该属性用于解决windows控制台乱码问题
测试下面的代码
import sys
print(sys.stdout.encoding)
用ctrl+shift+B
输出 cp936
ctrl+F5
输出 utf-8
PYTHONIOENCODING=UTF-8
经过我实际测试, 方案一是通用解决方案,但是命令行下python
2仍然是乱码,方案二是终极解决方案,一句话windows
下真蛋疼。
项目地址:
Chkbugreport
下载地址
springboot 中引入了Thymeleaf模板引擎,因此在开发过程中,如果你修改了页面模板或者代码,springboot是不会自动加载变更的。这里的变更分为两种,一是修改java文件,需要重新编译代码;二是修改页面,不需要重新编译,但是会重新加载页面。
另一个应用场景就是发布应用的时候,通过jar包部署你的应用。
thymeleaf
依赖<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
devtools
依赖<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
通常是application.properties
spring.thymeleaf.cache=false
<!-- 用于将应用打成可直接运行的jar(该jar就是用于生产环境中的jar) 值得注意的是,如果没有引用spring-boot-starter-parent做parent,
且采用了上述的第二种方式,这里也要做出相应的改动 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
</configuration>
</plugin>
模板及静态资源默认配置如下
window下使用pip
安装asyncio
的时候报错
windows7 x64 ,python2.7 ,VS2012
windows下使用pip安装包的时候需要机器装有vs2008
如果不想装VS2008的话,可以安装一个Micorsoft Visual C++ Compiler for Python 2.7的包
D:\tools\Android\android-sdk\platform-tools;D:\tools\Android\android-sdk\tools
adb
adb devices
adb devices unauthorized
adb kill-server
adb start-server
重复刚才1-3的步骤
USB连接具体的解决办法如下:
1、打开拨号界面,输入: *#*#2846579#*#*。自动进入工程菜单,选择后台设置——>usb端口设置——>生产模式。
2、打开调试
设置--系统和更新--开发者选项--打开调试
3、USB连接方式
选择传输文件
4、在设置中搜索HDB,打开允许HiSuite通过HDB连接设备
5、回到adb命令下查看是否已经连接上了呢
facebook
非常著名的react脚手架项目,对于初学react的人很有用。
github项目地址
npm install create-react-app -g
create-react-app my-app
经过漫长的等待,如果没报错,恭喜你创建成功
npm start
#启动服务 默认是http://localhost:3000
npm test
#测试当前的应用
npm run build
#编译当前应用 发布
报错内容:
verbose stack SyntaxError: Unexpected end of input at 1:68246
1806 verbose stack ","chalk":"^1.1.3","coveralls":"^2.11.11","cpr":"^2.0.0","cross-spawn
1806 verbose stack ^
1806 verbose stack at Object.parseJSON (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\node_modules\jju\lib\parse.js:745:13)
1806 verbose stack at parse (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\index.js:10:13)
1806 verbose stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
1806 verbose stack at <anonymous>
1806 verbose stack at process._tickCallback (internal/process/next_tick.js:169:7)
解决方案:
执行 npm clean cache --force
命令,重新创建,成功!
因为和gogs服务端口冲突,修改默认的3000端口。
查阅文档
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/scripts/start.js
中明确默认的启动端口3000
当然可以通过这样的方式启动 npm start port
Go ahead and open the command prompt and type in:
c:>chcp
to check the encoding of the command. By me it's
Active code page: 852
Now open the Python.sublime-build (C:\Users\User\AppData\Roaming\Sublime Text 2\Packages\User) build system and add the encoding:
{
"cmd": ["c:\\python33\\python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding": "cp852"
}
This should cut it.
windows版mongo shell 地址
mongo "mongodb+srv://cluster0-3kquf.mongodb.net/test" --username admin
SQLite数据库是一款非常小巧的嵌入式开源数据库软件,也就是说
没有独立的维护进程,所有的维护都来自于程序本身。
在python中,使用sqlite3创建数据库的连接,当我们指定的数据库文件不存在的时候
连接对象会自动创建数据库文件;如果数据库文件已经存在,则连接对象不会再创建
数据库文件,而是直接打开该数据库文件。
连接对象可以是硬盘上面的数据库文件,也可以是建立在内存中的,在内存中的数据库
执行完任何操作后,都不需要提交事务的(commit)
创建在硬盘上面: conn = sqlite3.connect('c:\\test\\test.db')
创建在内存上面: conn = sqlite3.connect('"memory:')
下面我们一硬盘上面创建数据库文件为例来具体说明:
conn = sqlite3.connect('c:\\test\\hongten.db')
其中conn对象是数据库链接对象,而对于数据库链接对象来说,具有以下操作:
commit() --事务提交
rollback() --事务回滚
close() --关闭一个数据库链接
cursor() --创建一个游标
cu = conn.cursor()
这样我们就创建了一个游标对象:cu
在sqlite3中,所有sql语句的执行都要在游标对象的参与下完成
对于游标对象cu,具有以下具体操作:
execute() --执行一条sql语句
executemany() --执行多条sql语句
close() --游标关闭
fetchone() --从结果中取出一条记录
fetchmany() --从结果中取出多条记录
fetchall() --从结果中取出所有记录
scroll() --游标滚动
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-03-14 16:10:24
# @Author : Jeff.Sui ([email protected])
# @Link : http://example.org
# @Version : $Id$
import sqlite3
con = sqlite3.connect(":memory:")
c = con.cursor()
# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("INSERT INTO stocks VALUES (?,?,?,?,?)", ('2006-03-27','BUY','RHAT',100,60.14))
# Larger example that inserts many records at a time
purchases = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
('2006-04-06', 'SELL', 'IBM', 500, 53.00),
('2006-04-07', 'SELL', 'MSFT', 500, 74.00),
('2006-04-08', 'SELL', 'IBM', 500, 54.00),
('2006-04-09', 'SELL', 'MSFT', 500, 73.00),
('2006-04-10', 'SELL', 'MSFT', 500, 75.00),
('2006-04-12', 'SELL', 'IBM', 500, 55.00),
]
c.executemany('INSERT INTO stocks VALUES (?,?,?,?,?)', purchases)
# Save (commit) the changes
con.commit()
# Do this instead
t = ('RHAT',)
c.execute('SELECT * FROM stocks WHERE symbol=?', t)
#print(c.fetchone())
#for row in c.execute('SELECT * FROM stocks ORDER BY price'):
# print(row)
#for row in c.execute('SELECT * FROM stocks LIMIT 5 OFFSET 0'):
# print(row)
for row in c.execute('SELECT * FROM stocks LIMIT 5 OFFSET 1'):
print(row)
#Select Top N * From
# ====================================================================================
# SQLite 日期 & 时间
# ====================================================================================
print('='*30)
print('SQLite 日期 & 时间')
print('='*30)
# 计算当前日期
c.execute("SELECT date('now')")
print(c.fetchone())
# 计算当前月份的最后一天:
c.execute("SELECT date('now','start of month','+1 month','-1 day');")
print(c.fetchone())
# 计算给定 UNIX 时间戳 1092941466 的日期和时间:
c.execute("SELECT datetime(1092941466, 'unixepoch');")
print(c.fetchone())
# 计算给定 UNIX 时间戳 1092941466 相对本地时区的日期和时间:
c.execute("SELECT datetime(1092941466, 'unixepoch', 'localtime');")
print(c.fetchone())
# 计算当前的 UNIX 时间戳:
c.execute("SELECT datetime(1092941466, 'unixepoch', 'localtime');")
print(c.fetchone())
# 计算美国"独立宣言"签署以来的天数:
c.execute("SELECT julianday('now') - julianday('1776-07-04');")
print(c.fetchone())
# 计算从 2004 年某一特定时刻以来的秒数:
c.execute("SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');")
print(c.fetchone())
# 计算当年 10 月的第一个星期二的日期:
c.execute("SELECT date('now','start of year','+9 months','weekday 2');")
print(c.fetchone())
# 计算从 UNIX 纪元算起的以秒为单位的时间(类似 strftime('%s','now') ,不同的是这里有包括小数部分):
c.execute("SELECT (julianday('now') - 2440587.5)*86400.0;")
print(c.fetchone())
# 在 UTC 与本地时间值之间进行转换,当格式化日期时,使用 utc 或 localtime 修饰符,如下所示:
c.execute("SELECT time('12:00', 'localtime');")
print(c.fetchone())
#
c.execute("SELECT time('12:00', 'utc');")
print(c.fetchone())
con.close()
# ====================================================================================
# SQLite 常用函数
# ====================================================================================
print('='*30)
print('SQLite 常用函数')
print('='*30)
con = sqlite3.connect(":memory:")
c = con.cursor()
# Create table
c.execute('''CREATE TABLE COMPANY
(ID integer, NAME text, AGE integer, ADDRESS text, SALARY real)''')
# Larger example that inserts many records at a time
purchases = [(1,'Paul',32,'California',20000.0),
(2,'Allen',25,'Texas',15000.0),
(3,'Teddy',23,'Norway',20000.0),
(4,'Mark',25,'Rich-Mond',65000.0),
(5,'David',27,'Texas',85000.0),
(6,'Kim',22,'South-Hall',45000.0),
(7,'James',24,'Houston',10000.0)]
c.executemany('INSERT INTO COMPANY VALUES (?,?,?,?,?)', purchases)
# Save (commit) the changes
con.commit()
# 返回数据库表最后 n 行记录
# 先计算一个数据库表中的行数
c.execute("SELECT count(*) FROM COMPANY;")
last = c.fetchone()[0]
n = 5
c.execute("SELECT * FROM COMPANY LIMIT ? OFFSET ?;", (n, last-n))
for row in c:
print(row)
# 计算一个数据库表中的行数
c.execute("SELECT count(*) FROM COMPANY;")
print(c.fetchone())
# 选择某列的最大值
c.execute("SELECT max(salary) FROM COMPANY;")
print(c.fetchone())
# 选择某列的最小值
c.execute("SELECT min(salary) FROM COMPANY;")
print(c.fetchone())
# 计算某列的平均值
c.execute("SELECT avg(salary) FROM COMPANY;")
print(c.fetchone())
# 为一个数值列计算总和
c.execute("SELECT sum(salary) FROM COMPANY;")
print(c.fetchone())
# 返回一个介于 -9223372036854775808 和 +9223372036854775807 之间的伪随机整数
c.execute("SELECT random() AS Random;")
print(c.fetchone())
# 返回数值参数的绝对值
c.execute("SELECT abs(5), abs(-15), abs(NULL), abs(0), abs('ABC');")
print(c.fetchone())
# 把字符串转换为大写字母
c.execute("SELECT upper(name) FROM COMPANY;")
print(c.fetchone())
# 把字符串转换为小写字母
c.execute("SELECT lower(name) FROM COMPANY;")
print(c.fetchone())
# 返回字符串的长度
c.execute("SELECT name, length(name) FROM COMPANY;")
print(c.fetchone())
# 返回 SQLite 库的版本
c.execute("SELECT sqlite_version() AS 'SQLite Version';")
print(c.fetchone())
#
c.execute("SELECT CURRENT_TIMESTAMP;")
print(c.fetchone())
Git常用命令
Clone远程仓库
git clone ssh://remote_repo_url
git clone https://remote_repo_url
本地初始化
git init #本地仓库初始化,已经clone的项目不需要初始化
git init --bare #服务器端初始化,一般不需要
本地配置
git config user.name xxx #配置提交人
git config user.email [email protected] #配置邮箱
三个级别System、Global、当前项目。原则上如果在自己电脑上提交,只需配置一次即可
添加文件到版本库
git add file_name #添加单个文件
git add . #添加目录下所有新增,修改文件
git add *.txt #添加所有新增,修改,扩展名为txt的文件
提交变更到本地仓库
git commit #执行该命令后,会实用默认VIM编辑器,填写提交信息,原则上信息不能为空
git commit -a #提交所有已删除、已修改、新增文件到本地仓库
git commit -m #不打开编辑器,-m 后面的内容就是提交信息
git commit --amend
撤销修改
git commit --amend #撤回上次commit message
git checkout -- file_name #撤回单个文件,此时未commit
git reset --hard HEAD~1 #撤回上次提交,此时已经commit
#此时 通过git log 命令查看,这次提交已经不存在了
7.删除文件
git rm file_name #删除文件
git rm --cached file_name #删除暂存区文件
比较
git diff
git diff --cached #比较暂存区
git diff sha1 sha2 #比较两次commit
git diff branch_1 branch_2 #比较两个分支
查看状态
git status #三种状态 未跟踪、已修改|删除|添加、已提交
查看日志
git log --oneline #只显示提交日志基本信息
git log -p -1 #查看上一次提交的详细信息
git log sha1 #查看某个提交的信息
git log --graph --oneline --decorate --all
git shortlog #按照提交人分组查看提交
查看配置
git config --list #查看当前Git配置信息
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" #自定义查看分支记录(合并)
git config --global alias.hist "log --pretty=format:"%C(auto)%h %ad | %C(auto)%s%d %Cblue(%an)" --graph --date=short" #自定义查看提交记录
忽略文件
touch .gitignore
vim .gitignore
常用内容:
文件名 例如: a.c a.swp ....
文件扩展名或者目录,如*.java
如果不想提交.gitignore文件到远程仓库,只需在.gitignore文件第一行加入.gitignore即可。
具体可以参考官方文档
对于IDE,可以参考这个网站生成对应的忽略文件列表 gitignore ,输入关键字即可
分支
git checkout -b 本地分支名 #建立一个本地分支并切换
git checkout 本地分支 #切换已经存在的分支
git branch 分支名 #建立分支不切换
git branch #查看本地分支
git branch -av #查看本地和远程分支
git branch -d 分支名 #删除本地分支
git merge branch_name #合并本地分支
同步远程分支
git fetch 远程分支名
git pull 远程分支名
推送远程分支
git push origin master # 推送到远程master分支
暂存
git stash #暂存当前工作区内容
git stash list #查看当前暂存区
git stash pop #从栈顶取出并移除出暂存区
git stash apply stash@{0} #从栈顶取出不清空暂存区
git stash clear #清空暂存区
17 .补丁
git format-patch -n #生成补丁,n代表提交的次数
git am patch_file #打补丁
标签Tag
git tag -a -m "description" #打标签
git push origin version-number #推送标签到远程仓库
git push --tags #推送所有本地标签到远程仓库
处理冲突
#容易出现冲突几种操作:1.合并分支 2.同步远程分支 3.rebase分支
#解决冲突基本流程:出现冲突的双方协商后,由出现冲突的人员修改文件后,重新执行操作(merage,commit) ,再推送到远程仓库,其他人再同步远程仓库。
$ git merge mydev
Auto-merging a.c
CONFLICT (add/add): Merge conflict in a.c
Automatic merge failed; fix conflicts and then commit the result.
def _locate_element(self, selector):
"""
to locate element by selector
:arg
selector should be passed by an example with "i,xxx"
"x,//*[@id='langs']/button"
:returns
DOM element
"""
if self.by_char not in selector:
return self.base_driver.find_element_by_id(selector)
selector_by = selector.split(self.by_char)[0].strip()
selector_value = selector.split(self.by_char)[1].strip()
if selector_by == "i" or selector_by == 'id':
element = self.base_driver.find_element_by_id(selector_value)
elif selector_by == "n" or selector_by == 'name':
element = self.base_driver.find_element_by_name(selector_value)
elif selector_by == "c" or selector_by == 'class_name':
element = self.base_driver.find_element_by_class_name(selector_value)
elif selector_by == "l" or selector_by == 'link_text':
element = self.base_driver.find_element_by_link_text(selector_value)
elif selector_by == "p" or selector_by == 'partial_link_text':
element = self.base_driver.find_element_by_partial_link_text(selector_value)
elif selector_by == "t" or selector_by == 'tag_name':
element = self.base_driver.find_element_by_tag_name(selector_value)
elif selector_by == "x" or selector_by == 'xpath':
element = self.base_driver.find_element_by_xpath(selector_value)
elif selector_by == "s" or selector_by == 'css_selector':
element = self.base_driver.find_element_by_css_selector(selector_value)
else:
raise NameError("Please enter a valid type of targeting elements.")
return element
certutil -hashfile yourfilename.ext MD5
certutil -hashfile yourfilename.ext SHA1
certutil -hashfile yourfilename.ext SHA256
>>> dic = {}
>>> type(dic)
<type 'dict'>
另一种形式:
temp = dict()
temp['name'] = 'xiaoming'
>>> dic = {'spam':1, 'egg':2, 'bar':3}
>>> dic
{'bar': 3, 'egg': 2, 'spam': 1}
>>> dic = dict(spam = 1, egg = 2, bar =3)
>>> dic
{'bar': 3, 'egg': 2, 'spam': 1}
>>> list = [('spam', 1), ('egg', 2), ('bar', 3)]
>>> dic = dict(list)
>>> dic
{'bar': 3, 'egg': 2, 'spam': 1}
>>> dic = dict(zip('abc', [1, 2, 3]))
>>> dic
{'a': 1, 'c': 3, 'b': 2}
>>> dic = {i:2*i for i in range(3)}
>>> dic
{0: 0, 1: 2, 2: 4}
>>> dic = dict.fromkeys(range(3), 'x')
>>> dic
{0: 'x', 1: 'x', 2: 'x'}
>>> list = ['x', 1, 'y', 2, 'z', 3]
>>> dic = dict(zip(list[::2], list[1::2]))
>>> dic
{'y': 2, 'x': 1, 'z': 3}
xshell 是 windows下 非常实用的终端工具, 自带的主题有点丑 ,记录两个配色方案。
[ubuntu]
text(bold)=ffffff
magenta(bold)=ad7fa8
text=ffffff
white(bold)=eeeeec
green=4e9a06
red(bold)=ef2929
green(bold)=8ae234
black(bold)=555753
red=cc0000
blue=3465a4
black=000000
blue(bold)=729fcf
yellow(bold)=fce94f
cyan(bold)=34e2e2
yellow=c4a000
magenta=75507b
background=300a24
white=d3d7cf
cyan=06989a
[Names]
count=1
name0=ubuntu
[Names]
count=1
name0=Solarized Dark
[Solarized Dark]
text(bold)=839496
magenta(bold)=6c71c4
text=00ff40
white(bold)=fdf6e3
green=859900
red(bold)=cb4b16
green(bold)=586e75
black(bold)=073642
red=dc322f
blue=268bd2
black=002b36
blue(bold)=839496
yellow(bold)=657b83
cyan(bold)=93a1a1
yellow=b58900
magenta=dd3682
background=042028
white=eee8d5
cyan=2aa198
默认mysql字符编码集Latin1,不支持中文,插入数据乱码,查询结果乱码,查询字符串输入中文乱码等等情况,这些都和mysql字符集有关。
系统变量:
– character_set_server:默认的内部操作字符集
– character_set_client:客户端来源数据使用的字符集
– character_set_connection:连接层字符集
– character_set_results:查询结果字符集
– character_set_database:当前选中数据库的默认字符集
– character_set_system:系统元数据(字段名等)字符集
– 还有以collation_开头的同上面对应的变量,用来描述字符序。
SET NAMES 'utf8';
如 default-character-set = utf8
character_set_server = utf8
修改完后,重启mysql的服务
mysql -u 用户名 -p 密码 -h 远程主机ip -P 端口号 数据库名
SHOW VARIABLES `like%`
set character_set_client=utf8
set character_set_connection=utf8
set character_set_results = utf8;
参考文档:
Mysql字符集设置
Configuring Application Character Set and Collation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<script>
function cal_words(){
var length = document.getElementById("ta").value.length;
document.getElementById("num").innerHTML = length;
}
</script>
</head>
<body>
<div class ="reply" >
<textarea id="ta" onKeyUp="cal_words()">
</textarea>
<div>字数:<span id="num">0</span></div>
</div>
</body>
安装pyecharts时,出现'ModuleNotFoundError: No module named 'pyecharts_snapshot',试了几次都无法解决,突然想到,"pyecharts_snapshot"会不会也是一个第三方库,毕竟异常信息都写着"No module",抱着试试的心态,没想到成功解决问题。
解决方案:pip install pyecharts_snapshot
cd d:\tools\nexus-3.3.2-02-win64\nexus-3.3.2-02\bin
nexus /run #启动nexus
nexus /stop #停止nexus服务
nexus /install #安装nexus到系统服务
....
admin/admin123
在http://repo.maven.apache.org/maven2/.index/ 中下载
nexus-maven-repository-index.gz
nexus-maven-repository-index.properties
然后再下载一个indexer-cli-5.1.0.jar
indexer的下载地址:http://maven.outofmemory.cn/org.apache.maven.indexer/indexer-cli/5.x.x/
--- to be continued
ctrl+shift+P 无法安装插件,弹出一个错误提示信息:
“There is no package available for installation ”
可以重新安装Package Control,下载地址:https://github.com/wbond/package_control
安装步骤:
Click the Preferences > Browse Packages… menu
Browse up a folder and then into the Installed Packages/ folder
Download Package Control.sublime-package and copy it into the Installed Packages/ directory
Restart Sublime Text
验证是否安装成功:
ctrl+shift+P
下载channel_v3.json文件到本机指定位置,不要有非法字符,中午字符。
配置Package Control 的用户自定义配置
首选项-->插件配置-->Package Control-->Setting (Default)
修改此处
"channels":
[
**"D:\\Programing\\channel_v3.json"**
],
问题描述:
https://www.robertkehoe.com/2015/03/fix-node-gyp-rebuild-error-on-windows/
问题解决:
stackoverflow 上类似的问题
https://stackoverflow.com/questions/35293117/npm-install-that-requires-node-gyp-fails-on-windows
npm install -g windows-build-tools
npm install --save autoit
function isNative (Ctor) {
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
}
MDN上在关于Function.prototype.toString()一章上是这么说的:
If the toString() method is called on built-in function objects or a function created by Function.prototype.bind, toString() returns a native function string which looks like
"function () { [native code] }"
微软MSDN上关于toString Method (Object) (JavaScript)一章中是这么说的:
The toString method is a member of all built-in JavaScript objects. How it behaves depends on the object type:
结论:当一个对象为JavaScript运行时build-in object (内建对象),并且类型为Function类型时,对其调用toString()方法后,返回的结果字符串就是如下:
"function functionname( ) { [native code] }"
$ npm -v
5.3.0
$ node -v
v8.4.0
操作系统:win7 x64
命令行 运行 `istanbul cover _mocha"
报错:
error :No coverage information was collected, exit without writing coverage information
mocha
你执行的是全局安装,那么这是win7不支持内置js脚本执行的问题。istanbul cover C:/Users/Mr.Sui/AppData/Roaming/npm/node_modules/mocha/bin/_mocha test/main.test.js
"scripts": {
"test": "mocha",
"test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha"
}
命令行执行 npm run test-cov
即可
结果如下:
$ npm run test-cov
> [email protected] test-cov D:\code\javascript
> istanbul cover ./node_modules/mocha/bin/_mocha
test/main.test.js
√ should equal 55 when n == 10
√ should equal 1 when n === 1
√ should equal 0 when n === 0
√ should throw when n > 10
√ should throw when n < 0
√ should throw when n isnt Number
6 passing (39ms)
=============================================================================
Writing coverage object [D:\code\javascript\coverage\coverage.json]
Writing coverage reports at [D:\code\javascript\coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 87.5% ( 14/16 )
Branches : 91.67% ( 11/12 )
Functions : 100% ( 1/1 )
Lines : 87.5% ( 14/16 )
================================================================================
Ctrl + L:左对齐
Ctrl + E:居中对齐
Ctrl + R:右对齐
Ctrl + B:加粗
Ctrl + I:斜体
Ctrl + U:给文字添加下划线
Ctrl + T: 给文字添加删除线
Ctrl + Shift + A:(选中文字)切换字母大小写
Ctrl + Shift + L:添加项目符号和编号(多按几次会出现不同的符号)
Ctrl + Shift + <:(选中文字)减小字号
Ctrl + Shift + > :(选中文字)增大字号
Ctrl + = :(选中文字)变为下标
Ctrl + Shift + = :(选中文字)变为上标
Ctrl + 1:(选中多行)设置行距为单倍行距
Ctrl + 2:(选中多行)设置行距为双倍行距
Ctrl + 5:(选中多行)设置行距为1.5倍行距
Ctrl + N:创建新便笺
Ctrl + D:删除便笺
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.