1: 285 items found.

centos 配置dhcp简记

yum -y install dhcp

配置文件:/etc/dhcp/dhcpd.conf

示例配置文件:/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example

default-lease-time 7200;
max-lease-time 14400;
subnet 10.1.119.0 netmask 255.255.255.0 {
  option routers 10.1.119.128;
  option domain-name-servers 10.1.102.2;
  range 10.1.119.200 10.1.119.220;
}
More ~

git 找回已删除的文件

找出已删除文件的提交记录:

git rev-list -n 1 HEAD -- <file_path>

返回为commit id

使用提交记录ID检出文件, commit id后缀**^**:

git checkout <commit id>^ -- <file_path>

或者一行命令:

$file 是文件路径

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
More ~

go可变参数传数组值

在https://github.com/qiniu/qmgo 中 有个方法是传排序参数,通常是一个或多个。

func (q *Query) Sort(fields ...string) QueryI {
	if len(fields) == 0 {
		// A nil bson.D will not correctly serialize, but this case is no-op
		// so an early return will do.
		return q
	}

	var sorts bson.D
	for _, field := range fields {
		key, n := SplitSortField(field)
		if key == "" {
			panic("Sort: empty field name")
		}
		sorts = append(sorts, bson.E{Key: key, Value: n})
	}
	newQ := q
	newQ.sort = sorts
	return newQ
}

若需传递多个fields, fields是个可变参数, 传值是你可能想支持多个,但对于参数个数也清楚, 那要先定义个字符串数组。

More ~