使用Start SSL免费申请SSL证书,并为nginx server添加SSL支持

start ssl证书申请

  • 首先在start ssl网站注册一个账号
  • 登录后进入登录页面,点击Validations Wizard,并选择Domain Validation,添加一个新的域名

add_domain.png

  • 点击Certificates Wizard,选择申请Web Server SSL,一直按照向导,进入到填写信息的页面。

Continue Reading...

js对象的那点事儿

原型

原型的概念以及访问

JS中原型就是一个对象,它用于某个对象从其他对象中继承属性。 怎么理解这句话呢:例如,对象b想有一个.x属性。如果对象a有.x属性,那么让b的原型等于a,则b就也有了.x属性。注意b的.x属性本质上就是a的.x属性。

每个对象都有一个原型。原型本身也是对象。这意味着原型本身也含有一个原型。当然这样下去似乎无穷无尽,自然有一个原型链的顶层对象,这个对象叫Object。这个对象是一个例外,它没有原型。

原型有几种方式可以访问

// ECMA5 标准 IE<=8失败
Object.getPrototypeOf(a);
// IE下失败,其他都可以
a.__proto__;
// 所有浏览器都可以,但是这有可能会出问题,下面讲对象的构造的时候会说明
a.constructor.prototype

bash snippets

Little Useful Functions

The Real Dir of Script itsef

sometimes we need to change dir to the real path of a script and do something. But this little thing is very hard to make it works in lots of Linux Distribution and Mac OS X. The snippets below is work on CentOS, Ubuntu and Mac OS X 10.10.

#!/bin/sh
# read link 
_script="$(readlink -n ${0})"
if [[ $_script = '' ]]; then
    # when call script without symbolic, readlink will return empty string
    pushd `dirname $0` > /dev/null
    _script=`pwd`
    popd > /dev/null
else
    _script="$(dirname $_script)"
fi
echo 'the real path is ' $_script

command usage

echo color

16color syntax:

# \033 is the Escape symbol in ASCII, it can also written in \x1b
echo -e "\033[${attr};${clbg};${clfg}m${renderText}\033[0m"
# -e explain as use string escape
# if you let \033[ in a variable, -e is not necessary. such as
start="\x1b["
end="\x1b[0m"
echo "${start}${attr};${clbg};${clfg}m${renderText}${end}"

which attr is control number, clbg is background color, clfg is foreground color.
The detail is in tip_colors_and_formatting

Dell R730服务器在Ubuntu 14.04 LTS中安装网卡驱动

前言

今天被分配到一个任务,就是去给一台新的服务器安装系统。用U盘做了个启动盘,居然半天没能启动。 只能自己做一个DVD盘。 结果安装好了之后,准备配置IP的时候,发现没有网卡驱动。只能手动安装了。。。
查询清单得知网卡型号是broadcom的5700系列的。因此去官网下载了驱动。 下载下来之后发现,是源码。。。。
考虑到服务器中没有make等一系列构建工具。找了一台普通的X86的64位Ubuntu14.04的桌面版进行编译,得到了ko格式的内核模块。

Continue Reading...

Ubuntu ssh登录时,出现 warning: Setting locale failed 的正确解决方法

本文转载自 perl: warning: Setting locale failed.引发的问题

缘由

我用的是linode的vps,系统为ubuntu14.04LTS
当apt-get安装软件时,都会报一个相同的错误,如下

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "zh_CN.UTF-8",
    LC_MONETARY = "zh_CN.UTF-8",
    LC_ADDRESS = "zh_CN.UTF-8",
    LC_TELEPHONE = "zh_CN.UTF-8",
    LC_NAME = "zh_CN.UTF-8",
    LC_MEASUREMENT = "zh_CN.UTF-8",
    LC_IDENTIFICATION = "zh_CN.UTF-8",
    LC_NUMERIC = "zh_CN.UTF-8",
    LC_PAPER = "zh_CN.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Continue Reading...