kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

markdown部分语法

贴自http://wowubuntu.com/markdown/index.html

段落和换行

一个 Markdown 段落是由一个或多个连续的文本行组成,它的前后要有一个以上的空行。普通段落不该用空格或制表符来缩进。
如果你确实想要依赖 Markdown 来插入 <br /> 标签的话,在插入处先按入两个以上的空格然后回车。

标题

Markdown 支持两种标题的语法,类 Setext 和类 atx 形式。
类 Setext 形式是用底线的形式,利用 = (最高阶标题)和 - (第二阶标题),例如:

1
2
3
4
This is an H1
=============
This is an H2
-------------

任何数量的 = 和 - 都可以有效果。
类 Atx 形式则是在行首插入 1 到 6 个 # ,对应到标题 1 到 6 阶,例如:

1
2
3
# 这是 H1
## 这是 H2
###### 这是 H6

你可以选择性地「闭合」类 atx 样式的标题,这纯粹只是美观用的,若是觉得这样看起来比较舒适,你就可以在行尾加上 #,而行尾的 # 数量也不用和开头一样(行首的井字符数量决定标题的阶数):

1
2
3
# 这是 H1 #
## 这是 H2 ##
### 这是 H3 ######

树状数组

大体上可以分为两种:

每次修改的是一个点,所求的是关于某段区间;
这种情况最好办;比如说poj2352 stars;求每个点前面比他小的点的个数;
只用设置数组a[],先全是0,然后有某个点就依次修改,并以此统计;
这一种是最基本的向上修改,向下统计;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int lowbit(int x) {
	return x&(-x);
}
void update(int x,int num) {
	while(x<=N) {
		 d[x]+=num;
		 x+=lowbit(x);
	 }
}
int getSum(int x) {
	int s=0;
	while(x>0) {
		 s+=d[x];
		 x-=lowbit(x);
	 }
	return s;
}

octopress分类中使用二级目录

1.修改plugins/category_list_tag.rb为

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
# encoding: UTF-8
module Jekyll
	class CategoryListTag < Liquid::Tag
		def render(context)
			html = ""
			pre = ""
			divout = 0
			categories = context.registers[:site].categories.keys
			categories.sort.each do |category|
				posts_in_category = context.registers[:site].categories[category].size
				category_dir = context.registers[:site].config['category_dir']
				cats = category.split(/~/)
				if cats.size > 1 and cats[0] == pre
					if divout == 0
						html << "<div id='#{pre}' class='divclass'>"
						divout = 1
					end
					html << "<li><a href='/#{category_dir}/#{category.to_url}/?opendiv=#{pre}'>#{cats[1]} (#{posts_in_category})</a></li>\n"
				else
					pre = cats[0]
					if divout > 0
						html << "</div>"
						divout = 0
					end
					html << "<li class='category'><a href='##' onmousedown=showDiv('#{pre}')>#{category} </a><a href='/#{category_dir}/#{category.to_url}/'>(#{posts_in_category})</a></li>\n"
				end
			end
			if divout > 0
				html << "</div>"
				divout = 0
			end
			html
		end
	end
end

Liquid::Template.register_tag('category_list', Jekyll::CategoryListTag)