Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
cat > test0.cc <<EOF
#include <iostream>
#include <string>
void foo(){
std::cout << "this is the target function." << std::endl;
}
EOF
@xgwang
xgwang / gist:4690456
Created February 1, 2013 10:03
date计算相对日期的代码
%{
/* Parse a string into an internal time stamp.
Copyright (C) 1999-2000, 2002-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@xgwang
xgwang / git-file-branch.sh
Created July 15, 2012 12:51 — forked from drmingdrmer/git-file-branch.sh
shell script to find out in which git-branch the last time a file was modified
# usage:
# ./git-file-branch.sh fn.cpp
prev=$(git rev-parse $(git rev-list -n1 --all -- $1)^)
for br in $(git branch | cut -c 3-); do
[ "x$(git rev-list -n1 --no-merges --first-parent $prev..$br -- $1)" != "x" ] && echo $br
done