kk Blog —— 通用基础

date [-d @int|str] [+%s|"+%F %T"]

树状数组

大体上可以分为两种:

每次修改的是一个点,所求的是关于某段区间;
这种情况最好办;比如说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)

octopress侧边栏添加内容

1.添加about页面

rake new_page[about]
会生成 source/about/index.markdown 文件。
编辑该文件的内容。
然后在头部导航菜单中添加页面的超链接。具体做法是编辑 /source/_includes/custom/navigation.html 文件。

2.增加链接

在source/_includes/custom/asides创建blog_link.html,代码如下:

1
2
3
4
5
6
7
8
<section>
<h1>link</h1>
<ul>
  <li>
      <a href=http://hi.baidu.com/abcdxyzk target=_blank>My</a>
  </li>
</ul>
</section>

然后修改_config.yml文件在default_asides中加入custom/asides/blog_link.html。

octopress+github建立个人博客

静态建立blog

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
ubuntu 18.04:
	openssl 编译错误,需要先卸载 libssl-dev,再编译安装
	vim /usr/local/lib/ruby/2.3.0/net/https.rb 删除 require 'openssl'

ubuntu 16.04:

sudo apt-get install zlib1g-dev libssl-dev

git clone https://github.com/abcdxyzk/abcdxyzk.github.io_base.git

tar xf ruby-2.3.8.tar.gz
cd ruby-2.3.8
make
make install

zlib:
	cd ext/zlib
	ruby extconf.rb  
	make
	make install


openssl:
	cd ext/openssl
	ruby extconf.rb  
	make
	make install

	这时出错,make: *** No rule to make target `/include/ruby.h', needed by `ossl.o'

	其实是ext/openssl/Makefile中忘了给路径变量top_srcdir赋值,调用的时候当然就报错了,修改 Makefile 增加 top_srcdir = ../..


sudo cp -r usr/local/lib/ruby/gems/2.3.0/* /usr/local/lib/ruby/gems/2.3.0/

sudo cp bundler bundle compass jekyll /usr/local/bin/

sudo cp bayes.rb  kramdown  listen  rackup  safe_yaml  summarize.rb  tilt  /usr/local/bin/

rake renerate

对于ruby低于1.9.3,下载 http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.bz2

高于1.9.3 ???

有时https连不了,http却可以,所以修改Gemfile

1
2
3
4
5
6
7
8
9
10
diff --git a/Gemfile b/Gemfile
index b02ee4b..7f7aac3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source "https://rubygems.org"
+source "http://rubygems.org"
 
 group :development do
   gem 'rake', '~> 10.0'

Step 1 安装git ruby nodejs

1
2
sudo apt-get install git zlib1g-dev libyaml-dev openssl libssl-dev tcl-dev tk-dev node/nodejs
sudo apt-get install ruby ruby-dev 安装的版本偏低不行,要1.9.3以上https://www.ruby-lang.org/en/downloads/

Step 2 准备octopress

1
2
3
4
5
6
7
8
9
git clone git://github.com/imathis/octopress.git octopress
cd octopress    # 如果你使用RVM, 你会被询问你是否信任 .rvmrc 文件 (选择 yes).
ruby --version  # 这条命令应该输出 Ruby 1.9.3
然后安装依赖
sudo gem install bundler
rbenv rehash    # 如果你使用 rbenv, 执行 rehash 以运行 bundle 命令 (好像不需要这条)
bundle install    # 在octopress目录运行
最后安装默认主题
rake install

css 二级菜单

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
44
45
46
47
48
49
50
51
52
53
54
55
56
<style type="text/css">

.divclass
{
	display:none;
	font-size:12px;
	position:relative;
	left:0px;
	top:0px;
	padding:5px 10px 0px 10px;
	width:320px;
}
</style>
<script language="javascript" type="text/javascript">

function showDiv(divName)
{
	if (document.getElementById(divName).style.display == "block")
		document.getElementById(divName).style.display = "none"; //隐藏层
	else
		document.getElementById(divName).style.display = "block"; //显示层
}
</script>
</head>
<body>
<div id="menu">
<ul>
<li><a href="#" onmousedown="showDiv('div1')">菜单一</a></li>
	<div id="div1" class=divclass>
	<a href="#" onmousedown="showDiv('div2')">子菜单一</a>
		<div id="div2" class=divclass>
		<ul>
		<li><a href="#">子菜单一</a></li>
		<li><a href="#">子菜单二</a></li>
		<ul>
		</div>
	</div>
<li><a href="#" onmousedown="showDiv('div3')">菜单三</a></li>
<div id="div3" class=divclass>
<ul>
<ul>
</div>
<li><a href="#" onmousedown="showDiv('div4')">菜单四</a></li>
<div id="div4" class=divclass>
<ul>
	<li><a href="#">子菜单一</a></li>
	<li><a href="#">子菜单二</a></li>
<ul>
</div>
</ul>
</div>
</body>
</html>
<script language="javascript" type="text/javascript">
showDiv('div1');
</script>