Da'sBlog


  • 首页

  • 分类

  • 归档

  • compass中文手册

  • 搜索
close
Da'sBlog

《TypeScript 中文入门教程》 8、函数

发表于 2017-06-13

转载:《TypeScript 中文入门教程》 8、函数

版权
文章转载自:https://github.com/zhongsp

介绍

函数是JavaScript应用程序的基础。 它帮助你实现抽象层,模拟类,信息隐藏和模块。 在TypeScript里,虽然已经支持类,命名空间和模块,但函数仍然是主要的定义行为的地方。 TypeScript为JavaScript函数添加了额外的功能,让我们可以更容易的使用。

函数

和JavaScript一样,TypeScript函数可以创建有名字的函数和匿名函数。 你可以随意选择适合应用程序的方式,不论是定义一系列API函数还是只使用一次的函数。

阅读全文 »
Da'sBlog

linux-ubuntu-ansible

发表于 2017-06-07
1
2
3
4
5
6
fatal error: openssl/opensslv.h: No such file or directory
fatal error: ffi.h: No such file or directory
apt-get install libffi-dev
apt-get install libssl-dev

ansible 2.4.0
config file =
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.4.0-py2.7.egg/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

阅读全文 »
Da'sBlog

linux-ubuntu-samba配置

发表于 2017-06-06 | 分类于 linux

首先下载服务器包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#sudo apt-get install samba
启动Samba服务器只需执行如下命令:
#sudo /etc/init.d/samba start
关闭Samba服务器:
#sudo /etc/init.d/samba stop
重新启动Samba服务器:
#sudo /etc/init.d/samba restart
root 15043 0.0 0.5 240004 5936 ? Ss 16:22 0:00 /usr/sbin/nmbd -D
root 15086 0.0 1.0 332036 10924 ? Ss 16:22 0:00 /usr/sbin/smbd -D
root 15093 0.0 0.5 329808 5736 ? S 16:22 0:00 /usr/sbin/smbd -D
root 15100 0.0 0.6 332036 6312 ? S 16:22 0:00 /usr/sbin/smbd -D
root 15157 0.0 1.5 344944 15648 ? S 16:27 0:00 /usr/sbin/smbd -D
阅读全文 »
Da'sBlog

linux-lsyncd同步备份文件

发表于 2017-06-06 | 分类于 linux

最近一直搞服务器文件备份,思量再三,rsync inotify-tools配置太麻烦,索性转成lsyncd。配置简单,运行快。效率提高不少。

直接打开https://github.com/axkibe/lsyncd/releases下载安装就好。

1
2
3
4
5
6
7
8
9
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/
# make && make install
--"--"是lua的注释标记
--mkdir /usr/local/lsyncd
--cd /usr/local/lsyncd
--vim lsyncd.lua --注意:lua语法的规则
--vim lsyncd.sunhao.conf --注意:后缀换成conf也可以,就是一个配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--文件配置语法lsyncd.sunhao.conf
settings{
logfile = "/var/log/lsyncd.log", --日志路径
statusFile = "/var/log/lsyncd-status.log", --状态文件
pidfile = "/var/run/lsyncd.pid", --pid文件路径
statusInterval = 1, --状态文件写入最短时间
nodaemon = false, --daemon运行
maxProcesses = 1, --最大进程
maxDelays = 1 --最大延迟
}
--多host同步
servers = {
"192.168.1.10", --前置服务器
--"192.168.1.13" --静态服务器
}
--同步规则
for _, server in ipairs(servers) do --迭代servers
sync{
default.rsyncssh, --默认rsync+ssh,rsync版本需要升级3以上版本
source = "/www/apache2/sunhao/html/", --源目录
delete = true,
host = server,
targetdir = "/www/sunhao/html/", --目标目录
exclude={
".txt" --排除
},
rsync = {
binary = "/usr/bin/rsync", --之前要装好rsync
archive = true, --归档
compress = false, --压缩
owner = true, --属主
perms = true, --权限
whole_file = false
},
ssh = {
port = 22
}
}
end
--执行脚本 lsyncd -log Exec /usr/local/lsyncd/lsyncd.sunhao.conf
Da'sBlog

php在现有环境下编译安装zlib等扩展

发表于 2017-05-31 | 分类于 php

安装的时候是在扩展包里面进行编译安装,所以对现有php环境没有影响

首先进源码的的扩展包

1
2
[root@BBS no-debug-zts-20131226]# cd //usr/src/temp/lamp/php-5.6.15/ext
[root@BBS ext]# cd zlib/
阅读全文 »
Da'sBlog

linux用nfs共享目录文档

发表于 2017-05-26 | 分类于 linux

这里我们分成两台主机,一台web-html nfs客户端ip为192.168.1.100。一台web-php nfs服务端ip为192.168.1.101。

首先我们要判断是否安装rpc,它主要用于给nfs提供传输。客户端服务端都要装

一般系统都安装好装好了,没有就安装下

1
2
3
4
5
service portmap status
service rpcbind status
yum install nfs-utils //nfs软件

登陆客户端查看 nginx的id号

1
2
3
[root@Web-html nfs]# id nginx
uid=501(nginx) gid=501(nginx) groups=501(nginx)

登陆服务端,编辑/etc/exports,格式如下

<共享目录> 客户端1(选项) [客户端2(选项) …]
共享目录:NFS共享给客户机的目录。
客户端:网络中可以访问此目录的主机。多个客户端以空格分隔。
选项:设置目录的访问权限、用户映射等,多个选项以逗号分隔。

阅读全文 »
Da'sBlog

前端面试题-谈谈你对模块化的理解

发表于 2017-05-23 | 分类于 面试题

点评

很多面试公司会问一下,你对模块化的理解。表面上很简单,,但却可以评测出一个人对于前端工程化的认识,实际能力,和学习能力。所以需要充分的准备。切记不可随口回答。一场战斗的胜利去决定于站前的准备。

为什么需要模块,什么是组件化。它们之间有什么区别?

首先我们需要从语义上明白什么是模块

模块,英文名module。又称构件,是能够单独命名并独立地完成一定功能的程序语句的集合(即程序代码和数据结构的集合体)。它具有两个基本的特征:外部特征和内部特征。外部特征是指模块跟外部环境联系的接口(即其他模块或程序调用该模块的方式,包括有输入输出参数、引用的全局变量)和模块的功能;内部特征是指模块的内部环境具有的特点(即该模块的局部数据和程序代码)。

两个重点,一,它有一个接口,二,它内部程序不对外访问。

简单理解,模块就是多个函数的集合…………

再简单点,模块就是手机,里面跑着各种各样的程序,我们通过触摸控制。触摸屏就是我们的接口,里面程序就是内部特征。

还是有点抽象。我们写个小程序。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function phone() {
function weChat() {
console.log('我是不插它');
}
function touch() {
weChat();
}
return {
ctltouch: touch
}
}
var iphone8 = phone();
iphone8.ctltouch(); //VM230:3 我是不插它

待续

阅读全文 »
Da'sBlog

linux如何查杀指定用户进程

发表于 2017-05-23 | 分类于 linux

首先w查看登录用户

mark

通过ps -ef | grep pts/0 查看pts/0上的用户

mark

我们可以看到pid是17866 其余的ppid都是最终指向的都是这个。

-e 显示所有进程。
-f 全格式。
ps e 列出程序时,显示每个程序所使用的环境变量。
ps f 用ASCII字符显示树状结构,表达程序间的相互关系

阅读全文 »
Da'sBlog

nginx重启,重载,测试,配置

发表于 2017-05-09 | 分类于 nginx

nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx

其他的停止nginx 方式:

ps -ef | grep nginx

kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx

启动nginx:
nginx -c /path/to/nginx.conf

平滑重启nginx:
kill -HUP 主进程号

阅读全文 »
Da'sBlog

mysql2013错误

发表于 2017-05-09 | 分类于 mysql

mysql错误Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
mark
mark
默认绑定的是本地,所以把bind-address = 127.0.0.1注释掉就好了。
然后重启下服务器
/etc/init.d/mysql restart

MySQL Error (2013): Lost connection to MySQL server at waiting for initial communication packet

打开my.ini,找到[mysqld]项,在其后加入一句:skip-name-resolve,保存,重启mysql服务即可~

阅读全文 »
1234…7
Sun Hao

Sun Hao

Whoever wants to be first must be slave of all.

68 日志
26 分类
100 标签
RSS
Creative Commons
© 2018 Sun Hao
Powered by Hexo
Theme - NexT.Mist
本站访客数人次 本站总访问量次