8bq

光辉岁月

Git多个项目使用不同的公钥和私钥

在github上有多个项目,在公司内部也有两个用Git管理的项目,这几个都要用,而且它们的公钥和私钥还都不一样,肿么办????
首先把公钥和私钥都按以下方式命名好,并且放到.ssh目录下,方便管理(注意公钥和私钥两个文件一个都不能少)

1
2
3
4
5
6
~/.ssh/project1_rsa
~/.ssh/project1_rsa.pub
~/.ssh/project2_rsa
~/.ssh/project2_rsa.pub
~/.ssh/project3_rsa
~/.ssh/project3_rsa.pub

MySQL语句集合

查询同一字段中的相同记录

1
select tt1.i_value,count(*) from cx_invite as tt1 ,cx_invite as tt2 where tt1.i_id!=tt2.i_id and tt1.i_value=tt2.i_value group by tt1.i_value;

MySQL替换语句

1
update `yourtable` set `yourcol`=replace(`yourcol`, '张三', '李四');

JS cookie 操作函数

获取cookie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">
function getCookie(name){
var start = document.cookie.indexOf(name + "=");
var len = start + name.length + 1;
if((!start) &&(name != document.cookie.substring(0, name.length))){
return null;
}
if(start == -1)
return null;
var end = document.cookie.indexOf(';', len);
if(end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(len, end));
}
</script>

过滤xml特殊字符

1
2
3
4
5
6
7
8
9
10
11
12
<?php
/**
XML标准规定的无效字节为:
0x00 - 0x08
0x0b - 0x0c
0x0e - 0x1f
所以很简单,输出的时候过滤这些字符就万无一失了,下面是PHP的实现。
*/
function XmlSafeStr($s){
return preg_replace("/[\x00-\x08\x0b-\x0c\x0e-\x1f]/",'',$s);
}
?>

Linux实用命令集合

删除.svn文件

1
find . -type d -name ".svn"|xargs rm -rf

查找$1同时过滤svn

1
grep $1 * -R -i | grep -v svn

linux系统下查询文件个数

1
ll -R | wc -l

查找

1
find ./ -exec grep -nH "/var/run/dovecot/auth-master" {}

brew使用

brew常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
brew update             #升级brew
brew outdated #列出可升级软件
brew search nginx #搜索nginx
brew install nginx #安装nginx
brew upgrade nginx #升级nginx
brew uninstall nginx #卸载nginx
brew list #查看已安装列表
brew info nginx #查看已安装nginx的版本信息
brew cleanup -n #查看哪些软件包要被清除
brew cleanup #清除所有软件包的所有老版本
brew pin #禁止指定软件升级
brew unpin #解锁禁止升级
brew upgrade --all #升级所有的软件包,包括未清理干净的旧版本的包

git下添加新项目及用户

新创建一个git项目并允许开发者使用.

1.生成密钥与公钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[dev1@bogon ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dev1/.ssh/id_rsa):
Created directory '/home/dev1/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/dev1/.ssh/id_rsa.
Your public key has been saved in /home/dev1/.ssh/id_rsa.pub.
The key fingerprint is:
99:4c:e4:00:56:a9:a2:e2:68:20:8c:60:90:2e:b9:b8 dev1@bogon
The key's randomart image is:
+--[ RSA 2048]----+
| . ooo.. |
|o . .+ |
|o. . o |
|+o. . o o |
|Bo . S |
|O. |
|*. |
|Eo |
|. |
+-----------------+
1
2
[dev1@bogon ~]$ ls .ssh
id_rsa id_rsa.pub