css3 display:flex 使用体会
display:flex感觉让布局容易了很多,作为初学者,发现有个坑,就是子元素对空间的分配,实际上是对父元素剩下的空间的分配,而不是对父元素所有空间的分配。
什么是剩余空间?如果父元素1000px,子元素a中写了几个字,占了100px,剩余空间就是900px。子元素b又写几个字,占了200px,就只剩下700px了。
涉及子元素几个属性:
flex-grow,后面带个数字,数字表明对剩余空间占得比例。
其他元素待查。
vue.js 几个小坑
无论如何,vue.js都是坑很少的了,并且大多数坑是js本身所导致的,并且cn.vuejs.org上也说明了,不过如果你没注意看这些坑边的警告,就可能掉进去半天找不到问题出口。
举例是:
new Vue({
el:'body',
data: {
obj: {x:1},
arr: [1,2,3,{y:2}],
}
})
1. data中的数据,如果是对象{},再次给它赋值会破坏数据-视图绑定。如:
this.obj = {} //破坏绑定
所以别这么做,需要增加新的属性,直接:
this.obj.newkey = 'newvalue'
删除属性可以:
delete this.obj.x
2. 如果是数组,则千万不能直接对索引值赋值,这也会破坏绑定。
this.arr[1] = 9 //破坏绑定
要这么做:
this.arr.$set(1,9)
如果要增加新的,用push或者unshift
this.arr[4] = 7 //破坏绑定
this.arr.push(7) //这样是OK的
3. 只要不是直接对数组索引值,对索引值下面的属性是可以这么做的:
this.arr[3].x = 11 //不会破坏绑定
4. 貌似与对象不同,数组可以赋值为空数组而不会破坏把绑定
this.arr = [] //没有问题
php7支持mongodb报错解决
php7支持mongodb
使用sudo pecl install mongodb安装的时候报错
configure: error: Cannot find OpenSSL's libraries
找到这篇文章:
http://languor.us/mongodb-linux-pecl-configure-error-cannot-find-openssls-libraries
改良一下:
apt-get install openssl
apt-get install libsasl2-dev
mkdir -p /usr/local/openssl/include/
ln -s /usr/include/openssl /usr/local/openssl/include/openssl
ln -s /usr/lib/x86_64-linux-gnu /usr/local/openssl/lib
其中“x86_64-linux-gnu”目录在我的电脑里面是“i386-linux-gnu”,你的电脑里面可能不一样,找一下libssl.a或libssl.so在的个目录就行了。
不再用phpmyadmin! adminer更好用
下载 https://www.adminer.org/#download
adminer是单个php文件,不需要什么配置什么的乱七八糟的东西,
放到服务器上就能用,
mysql远程连接总是不知道被什么挡下来,总是返回10061错误,那就有adminer吧!
JS居然支持中文编程
是的,你可以写:
var 变量 = 13
function 加(甲,乙){
return 甲 + 乙
}
var 丙 = 加(变量,9)
这样的内容
html提交个表单而已,居然有这么多技术
技术一,form
技术二,xhr也就是XMLHttpRequest也就是ajax技术,有js原生实现法和jquery ajax大法
技术三,formdata
技术四,fetch
上述技术越往后面越新
linux实时查看log变化
使用watch命令
watch -c -d -n 1 tail /var/log/nginx/error.log -n 5
上面命令的意思是查看tail命令的输出,-c彩色,-d显示差异,-n 1每秒钟更新一次。
linux定时任务cron和at
linux定时任务通过cron和at运行。
cron只能运行循环任务,如果是一次性任务,则要用at。
at语法灵活,如2分钟后运行一个脚本:
$at now + 2 minutes
>python t1.py
>ctrl+D
如果要运行一个文件的任务,使用:
at now -f filename
linux PATH立刻生效
linux的PATH要立刻生效,需要修改:
~/.bashrc
在里面增加一条:
BATH="/路径:/路径:"$PATH
下次新打开一个终端就生效了
php7连接mysql的函数mysql_connect已经被弃用了!
php7连接mysql的函数mysql_connect已经被弃用了!
大多数的php教程中还是用的mysql_connect,你会发现在php7中会报这个函数不存在。请用mysqli_connect替代。
PHP的交互式命令行
php -a
php7,php-fpm7,nginx在deepin(debian)上的安装配置
1. 安装
我是懒人,不习惯make/make install, 直接用aptitude安装了
$ sudo aptitude install nginx
$ sudo aptitude install php
$ sudo aptitude install php-fpm
目前是直接安装了最新版的php7、php-fpm7
2. 配置
php-fpm默认不需要配置,并且安装好后自动就启动了,可以使用
ps -aux | grep fpm
查看有没有启动。
安装的位置是:
/usr/sbin/php-fpm7.0
不过和旧版本的使用 fastcgi://127.0.0.1:9000的网络接口相比,新版本使用了Unix域套接字(Unix domain socket),是在文件系统里的文件,php-fpm的unix域套接字是:
unix:/run/php/php7.0-fpm.sock因此配置nginx.conf的时候,要使用这个。
Unix域套接字同样可以用netstat -apn | grep fpm查看。
重要的是配置nginx.conf
我的位置是在 /etc/nginx/nginx.conf
deepin安装的nginx.conf中,包含了配置/etc/nginx/sites-enabled/default,默认的配置文件其实在这,可以配置这个default文件。
sudo vim /etc/nginx/sites-enabled/default
在default中,默认包含了nginx的配置,所做的是取消井号#,修改一下就好了。
默认default中去掉无关说明,剩下的所有配置如下,需要修改的以粗体表示:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server
# listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
#}
}
修改为:
server {
listen 80 default_server;
listen [::]:80 default_server;
# 这儿是你自定义的www根目录
root /home/deepin/docs/wwwdir;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php; #增加index.php
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#去掉下面两行井号
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# 去掉下面这行井号,并修改为正确的unix套接字,可在shell中用sudo netstat -apn|grep php查看
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
}
3. 启动
/etc/init.d/php7.0-fpm restart
/etc/init.d/nginx restart
4. 测试
在配置的root目录下建一个index.php
内容是:
<?php phpinfo(); ?>
linux $() ${} $(()) (()) $....用法
| linux中shell变量$#,$@,$0,$1,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 $* 所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。 $@ 所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。 $# 添加到Shell的参数个数 $0 Shell本身的文件名 $1~$n 添加到Shell的各参数值。$1是第1参数、$2是第2参数…。 |
示例:
1 #!/bin/bash 2 # 3 printf "The complete list is %s\n" "$$" 4 printf "The complete list is %s\n" "$!" 5 printf "The complete list is %s\n" "$?" 6 printf "The complete list is %s\n" "$*" 7 printf "The complete list is %s\n" "$@" 8 printf "The complete list is %s\n" "$#" 9 printf "The complete list is %s\n" "$0"10 printf "The complete list is %s\n" "$1"11 printf "The complete list is %s\n" "$2 |
结果:
[Aric@localhost ~]$ bash params.sh 123456 QQThe complete list is 24249The complete list isThe complete list is 0The complete list is 123456 QQThe complete list is 123456The complete list is QQThe complete list is 2The complete list is params.shThe complete list is 123456The complete list is QQ |
再简单不过的时间管理:番茄工作法
很多时间管理致力于提高工作效率,减少打扰,番茄工作法是其中及其简便的一种。
一个番茄时段25分钟,计时开始后,排除一切干扰开始专一的一项工作。这项工作应该是简单的可以在25分钟内完成的。然后休息5分钟,继续下一个番茄时段。
这种方式蛮有效率,我想了一下可能的原因:
* 工作时段容易计算,工作+休息是半个小时,看着一个时钟就很清楚过去了多久还有多久,不需要特意的工具。
* 排除干扰,集中一项事务。人能高度集中注意力的时间不长。学校里面上课40分钟是有道理的。
* 一件简单能完成的工作。这督促人们去分解庞大的工作,不积跬步无以至千里。一步步都能完成一些工作,避免了一个庞大工作总是无法完成的挫败感。这与项目管理的WBS(Work breakdown structure)任务拆分、敏捷开发的sprint->user story->task的拆分思想都是一样的。
* 要集中注意力,就要休息好。中间一小段时间的休息更有利于集中注意力工作。