From 9b6840f58e76ab15bcc2798a0c2ff73e712731b1 Mon Sep 17 00:00:00 2001 From: RainSun Date: Wed, 20 Nov 2019 22:11:03 +0800 Subject: [PATCH] update --- 20191120/20191120.md | 155 +++++++++++++++++++++++++++++++++++ Miscellaneous/animation.md | 8 +- Miscellaneous/docker.md | 2 +- Miscellaneous/linux.md | 1 - Miscellaneous/nginx.md | 161 +++++++++++++++++++++++++++++++++++++ 5 files changed, 321 insertions(+), 6 deletions(-) create mode 100644 20191120/20191120.md diff --git a/20191120/20191120.md b/20191120/20191120.md new file mode 100644 index 0000000..2a06989 --- /dev/null +++ b/20191120/20191120.md @@ -0,0 +1,155 @@ +# 20191120 + +![js](https://img.shields.io/badge/language-js-orange.svg) + +js 高级 + +怎样用面向对象的思想去编程 ---- 抽象 + +特指具体的某一个事物 ----- 对象 + +特征 ------- 属性 + +行为 ------- 方法 + +创建对象 方式 + * 字面量创建对象 + ```js + var obj = { + name: 'yingbo', + age: 18, + sex: '女', + eat: () => { + console.log('真好吃') + }, + run: () => { + console.log('跑的真快') + } + } + ``` + * 调用系统构造函数创建对象 + ```js + var obj1 = new Object() + object1.name = 'lisi' + object1.age = 20 + object1.sex = '男' + object1.eat = () => { + console.log('好吃') + } + object.run = () => { + console.log('能跑个鬼') + } + ``` + * 自定义构造函数创建对象 + ```js + function Person(name, age, sex) { + this.name = name + this.age = age + this.sex = sex + this.eat = () => { + console.log('是非常好吃') + } + this.run = () => { + console.log('是非常能跑的怪物') + } + } + var per = new Person('yingbo', 20, 'male') + + // 判断对象输入什么类型 instanceof + console.log(per instanceof Person) // boolean -> true + console.log(per instanceof Object) // boolean -> true always + ``` + * 姓名 年龄 性别 吃 …… + +创建一个新的系统构造函数 +```js +function Person(name, age, sex) { + this.name = name + this.age = age + this.sex = sex + this.sayHi = () =>{ + console.log('你好') + } +} +``` + +实例化 ----- 通过自定义构造函数创建对象 ---> 实例对象 +`var per = new Person('yingbo', 20, 'male')` +1. 开辟内存空间 +2. 改变 this 的指向为当前对象 +3. 设置对象的属性和方法值 +4. 返回 this 指向的对象 + +自定义构造函数的缺点 + +内存消耗严重 数据不共享 +```js +var per = new Person() +var per1 = new Person() +per.sayHi() +per1.sayHi() +console.log(per.sayHi == per1.sayHi) // -> false +``` +```js +sayHi() => { + console.log('你好') +} + +// sayHi = 'yingbo' -> 和上边的冲突 导致公共命名空间(全局变量)污染 下边定义的时候用的这个会报 not a function 的错误 但是可以解决不共享的问题 慎用 + +function Person(name, age, sex) { + this.name = name + this.age = age + this.sex = sex + this.sayHi = sayHi +} + +var per = new Person() +var per1 = new Person() +per.sayHi() +per1.sayHi() +console.log(per.sayHi == per1.sayHi) // -> true +``` + +工厂模式创建对象 +```js +function createObj(name, age) { + var obj = new Object() + obj.name = name + obj.age = age + obj.sayHi = () =>{ + console.log('你好哇') + } + return obj +} +var obj1 = createObj() +obj1.sayHi() +``` + +工厂模式和自定义构造函数的区别 (面试的时候回答 相同 -> 不同) +* 共同点 + * 都能创建对象 + * 都是函数 + * 都能传参数 +* 不同点 + * 函数名称大小写 + * 有无返回值 + * this -> 当前对象 (自定义) -> obj对象 (工厂) + * 是否需要new去实例化 + * 函数内是否有new + +* 实例对象和构造函数的关系 + * 实例对象是通过构造函数创建的 ---- 实例化一个对象/new一个对象 + * `console.dir()` 显示对象结构 + * 实例对象的构造器(构造函数) + * `console.log(per.constructor == Person) // true` 实例对象的构造器是指向的是创建他的构造函数 + * `console.log(per.constructor == Person.constructor) // false` + * `console.log(per.__proto__.constructor == Person.constructor) // false` + * `console.log(per.__proto__.constructor == Person.prototype.constructor) // true` + * `console.log(per.constructor == Person.prototype.constructor) // true` + * `Person.constructor` 指向的自己Person + +* 总结 + * 判断一个对象属于什么类型 实例对象 instanceof 构造函数 + * 可以通过构造器去判断 + \ No newline at end of file diff --git a/Miscellaneous/animation.md b/Miscellaneous/animation.md index 00d9c21..1ffa44e 100644 --- a/Miscellaneous/animation.md +++ b/Miscellaneous/animation.md @@ -11,10 +11,10 @@ animation 属性是一个简写属性,用于设置六个动画属性: /* 动画的速度曲线 */ animation-timing-function - linear 动画从头到尾的速度是相同的。 测试 - ease 默认。动画以低速开始,然后加快,在结束前变慢。 测试 - ease-in 动画以低速开始。 测试 - ease-out 动画以低速结束。 测试 + linear 动画从头到尾的速度是相同的。 + ease 默认。动画以低速开始,然后加快,在结束前变慢。 + ease-in 动画以低速开始。 + ease-out 动画以低速结束。 ease-in-out 动画以低速开始和结束。 /* 定义动画何时开始 ms */ diff --git a/Miscellaneous/docker.md b/Miscellaneous/docker.md index 0a98da6..a1906eb 100644 --- a/Miscellaneous/docker.md +++ b/Miscellaneous/docker.md @@ -9,7 +9,7 @@ `mkdir /home/pi/data/db/mongo` 运行容器 -`docker run -d --name rpi-mongodb3 -v /home/pi/data/db/mongo:/data.db -p 27017:27017 --restart=always andresvidal/rpi3-mongodb3 mongod --auth` +`docker run -d --name rpi-mongodb3 -v /home/pi/data/db/mongo:/data/db -p 27017:27017 --restart=always andresvidal/rpi3-mongodb3 mongod --auth` 命令格式:docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Usage: Run a command in a new container diff --git a/Miscellaneous/linux.md b/Miscellaneous/linux.md index 86bb308..43d8570 100644 --- a/Miscellaneous/linux.md +++ b/Miscellaneous/linux.md @@ -60,5 +60,4 @@ 修改文件权限 [链接]('https://blog.csdn.net/slwhy/article/details/78876237') - sudo chmod o+rwx /usr/local/bin/sunny \ No newline at end of file diff --git a/Miscellaneous/nginx.md b/Miscellaneous/nginx.md index 986734f..8c16d3d 100644 --- a/Miscellaneous/nginx.md +++ b/Miscellaneous/nginx.md @@ -32,4 +32,165 @@ server { upstream flask{ server 0.0.0.0:5000; } +``` + +极简印的nginx配置备份 +``` +server { + listen 80; + server_name qr.powerrain.cn; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + location / { + root /data/wwwroot; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /data/wwwroot; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root /usr/share/nginx/html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + location ~ \.php$ { + root /data/wwwroot; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + #location /qrcode { + # proxy_pass 0.0.0.0:5000; + #} +} + +server { + #SSL 访问端口号为 443 + listen 443 ssl http2; #填写绑定证书的域名 + server_name qr.powerrain.cn; + #证书文件名称 + ssl_certificate 1_qr.powerrain.cn_bundle.crt; + #私钥文件名称 + ssl_certificate_key 2_qr.powerrain.cn.key; + ssl_session_timeout 5m; + #请按照这个协议配置 + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + #请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。 + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + location / { + proxy_pass http://127.0.0.1:5000; + } + } + +server { + listen 80 http2; + server_name powerrian.cn; + location / { + root /data/wwwroot; + index index.html index.htm; + } +} +server { + listen 80 http2; + server_name www.powerrian.cn; + location / { + root /data/wwwroot; + index index.html index.htm; + } +} +``` + +精简一下 +``` +server { + listen 80; + server_name qr.powerrain.cn; + + location / { + root /data/wwwroot; + index index.html index.htm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /data/wwwroot; + } + + + + location ~ \.php$ { + root /data/wwwroot; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + +} + +server { + #SSL 访问端口号为 443 + listen 443 ssl http2; #填写绑定证书的域名 + server_name qr.powerrain.cn; + #证书文件名称 + ssl_certificate 1_qr.powerrain.cn_bundle.crt; + #私钥文件名称 + ssl_certificate_key 2_qr.powerrain.cn.key; + ssl_session_timeout 5m; + #请按照这个协议配置 + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + #请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。 + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + location / { + proxy_pass http://127.0.0.1:5000; + } +} + +server { + listen 80 http2; + server_name powerrian.cn; + location / { + root /data/wwwroot; + index index.html index.htm; + } +} + +server { + listen 80 http2; + server_name www.powerrian.cn; + location / { + root /data/wwwroot; + index index.html index.htm; + } +} + ``` \ No newline at end of file