Setup dropbox without X Assume you are accessing your server remotely through SSH. 1. Download the package, say you are using Ubuntu $wget https://www.dropbox.com/download?dl=packages/ubuntu/dropbox_1.4.0_amd64.deb 2. Install the package $sudo dpkg -i *dropbox_1.4.0_amd64.deb 3. Start Dropbox $dropbox start 4. You will get an url to link your computer here, copy-and-paste into your web-browser. Restart your dropbox, all set :] $dropbox […]
gitignore 如果用git管理的工程文件结构比较复杂,可以新建一个.gitignore文件 $cat .gitignore *.o tmp* 用来忽略一些文件,比如上面的内容可以用来忽略以.o结尾的文件和tmp开头的路径。 今天发现还可以用惊叹号!来做白名单。 $cat .gitignore *.o tmp* !*.c 这样确保.c文件不被git忽略。 值得注意的是,.gitignore里条件是靠后优先的,写在后面会覆盖前面的效果。 比如当前目录下有 $ls . a.c a.o tmp.c 上面的.gitignore不会忽略掉tmp.c
fstream issue under 64-bits cygwin This is a question I posted on StackOverflow: fstream issue under 64-bits cygwin, glad to get help from Nemo on Stackflow, all credits goes to him. The problem is when I use 64-bits g++ to compile the same piece of code, I get unexpected different result. The source code looks like this: #include #include using […]
Use a different delimiter in sed Think about this, you want to replace “XXX” with a path like “/path/to/YYY” in a file. Your file looks like this: XXX AAA XXX Your bash script looks like this: NEW_PATH=”/path/to/YYY” VAR=”XXX” sed -e ‘{s/$VAR/$NEW_PATH/g}’ your_file Well, it won’t work, since single quotes ‘ will force bash to keep variables as-is. Ok, we try to […]
STL map operator[] not const STL里Map的Operator[]和其它的Container不太一样。 因为Map的Operator[]可以提供这种操作: map testMap; testMap[“a”] = “b”; 所以Map的Operator[]返回的是T&,而不是const T& 如果需要得到const reference,可以这样: map testMap; const string& constMember = testMap.find(“a”)->second;
UnitTest框架GoogleTest 回到C++下,随着代码量增加,遇到维护问题了。 找到一个Google的UnitTest框架,GoogleTest 有很详细的Sample,推荐一下 :] 编译的时候需要先编译出libgtest.a和gtest_main.o,自己的testXX.cpp文件需要和ligtest.a, gtest_main.o链接。 $g++ testXX.cpp path/to/gtest_main.o -Lpath/to/libgtest.a -lgtest -o testXX
Project-Specific Vim Configuration Usually, we have our own vim configuration in the file ~/.vimrc What if we want one for our project? For example, we are working on certain project which needs to read in a tags file. Well, here is a possible solution. You put a line at then end of your ~/.vimrc file source ./.project.vim Then […]
tail -n Quite useful trick, when you want to get rid of the first certain lines of the output/file. $tail -n +2 tail prints out the result starts from the 2nd line. When you use the “find” command to generate a file list under certain folder, this is quite easy to eliminate the folder path at the […]