kk Blog —— 通用基础

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

octopress+github建立个人博客

对于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>

ar ranlib nm 命令--制作.a文件

1.ar基本用法

功能说明:建立或修改备存文件,或是从备存文件中抽取文件。

ar命令可以用来创建、修改库,也可以从库中提出单个模块。库是一单独的文件,里面包含了按照特定的结构组织起来的其它的一些文件(称做此库文件的member)。原始文件的内容、模式、时间戳、属主、组等属性都保留在库文件中。

gcc同时使用动态和静态链接

gcc –static a.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc

其中用到的两个选项:-Wl,-Bstatic和-Wl,-Bdynamic。这两个选项是gcc的特殊选项,它会将选项的参数传递给链接器,作为 链接器的选项。比如-Wl,-Bstatic告诉链接器使用-Bstatic选项,该选项是告诉链接器,对接下来的-l选项使用静态链 接;-Wl,-Bdynamic就是告诉链接器对接下来的-l选项使用动态链接。下面是man gcc对-Wl,option的描述,

1
2
3
4
5
6
-Wl,option  
   Pass option as an option to the linker.  If option contains commas, it is   
   split into multiple options at the commas.  You can use this syntax to pass  
   an argument to the option.  For example, -Wl,-Map,output.map passes -Map output.map  
   to the linker.  When using the GNU linker, you can also get the same effect with   
   -Wl,-Map=output.map.  

下面是man ld分别对-Bstatic和-Bdynamic的描述,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-Bdynamic  
-dy  
-call_shared  
   Link against dynamic libraries. You may use this option multiple times on the  
   command line: it affects library searching for -l options which follow it.  

-Bstatic  
-dn  
-non_shared  
-static  
   Do not link against shared libraries. You may use this option multiple times on   
   the command line: it affects library searching for -l options which follow it.   
   This option also implies --unresolved-symbols=report-all.  This option can be   
   used with -shared.  Doing so means that a shared library is being created but   
   that all of the library's external references must be resolved by pulling in   
   entries from static libraries.  

值得注意的是对-static的描述:-static和-shared可以同时存在,这样会创建共享库,但该共享库引用的其他库会静态地链接到该共享库中。