关于一个配置项的设计
有个需求需要配置每张表的备份SQL语句,我开始想实现如下的效果:
struct TableBackupSQL
{
uint64_t table_id_;
const char* sql_;
const char * table_name_;
TableBackupSQL()
{
sql_ = NULL;
table_name_ = NULL;
table_id_ = OB_INVALID_ID;
}
TableBackupSQL(uint64_t table_id, const char* table_name, const char* sql)
{
sql_ = sql;
table_name_ = table...
同步github上的项目到gitcafe
github固然好,只是国内访问有点慢。为了提高博客访问速度我决定把github上托管的博客同步到gitcafe上。最好能在DNS那里做CDN,但是貌似没有免费的服务。那直接指向gitcafe好了,反正没有什么国外访问的需求。简单记一下过程。
gitcafe自己有导入的功能,但是貌似不是很好用。而且不够智能。所以我们先建立一个跟用户名一样的目录。gitcafe只允许这种方式的Html页面生成。并且只渲染gitcafe-pages分支。
我们修改source分支.git/config加入
[remote "cafe"]
url = git@gitcafe.com:xxx/xxx.git
fetch = +refs/heads/*:refs/remotes/cafe/*
...
git远程分支和refs文件详解
最近同时同步博客到github和gitcafe上,遇到一些问题,我们分如下几个方面来分析一下:
推送远程分支到同一个服务器
比如首先建立git服务器,顺便clone出两个副本
mkdir server
cd server
git init --bare
cd ..
git clone server git1
git clone server git2
目前git branch是空的。我们提交一点东西建立master分支。
cd git1
touch a.txt
git add .
git commit -m "init"
git push origin master
现在git branch -a 显示:
* master
remotes/origin/maste...
一个关于宏的问题
写了一段代码,我想实现宏里面拼接一个变量然后取得这个变量的值的效果,但是没有成功:
#define OB_FIRST_ROOT_TABLE_TID 21
#define OB_INVALID_ID INT_MAX
const char* OB_FIRST_ROOT_TABLE_TABLE_NAME = "__first_root_table";
struct TableBackupSQL
{
uint64_t table_id_;
const char* sql_;
const char * table_name_;
TableBackupSQL()
{
sql_ = NULL;
table_name_ = NULL;
table_i...
octopress代码着色
markdown有自己支持的代码模块,但是想支持着色,就需要单独对代码进行parse和加上css。octopress支持自己的代码语法,但是比较麻烦,并且是本地渲染,对不同语言需要指定。
所以还是js渲染比较方便一点,我们可以用google code prettify进行着色,在markdown里面只要对代码加入缩进(tab或者四个空格)。服务端引入如下js:
<link href="/javascripts/google-code-prettify/prettify.css" media="screen, projection" rel="stylesheet" type="text/css">
<script type="text/javascript" sr...
直接从markdown生成各种电子书
有时候我们需要把编辑的markdown转成各种格式,这不失为一种写书的方式。借助pandoc这把瑞士军刀,我们可以实现一个脚本编译各种格式的功能,代码如下:
#!/usr/bin/python
#coding=utf-8
#Filename:build.py
import glob,os,sys,shutil
cmd_template={'html':"pandoc %s -o output/html/%s.html --template=default.html",
'pdf':'pandoc -N --toc --template=default.latex --latex-engine=xelatex %s -o output/pdf/%s.pdf...
post-review插件
###post-review.vim
A plugin to generate post-review script
Usage
####install:
git clone https://github.com/chenxiaohui/post-review.vim
put post-review.vim to your $VIM/plugin
add this to your vimrc
nmap <leader>pr :call PostReview()<cr>
####process:
svndiff use vimdiff: see link
gitdiff use vimdiff: see link
495 post articles, 62 pages.