Skip to content

Instantly share code, notes, and snippets.

@gogomako
gogomako / gist:8857012
Last active August 29, 2015 13:56
This function can print calling time.這個函式可以印出呼叫時的時間
void print_time(int file_print,FILE* fp,int print_hour){
time_t timeNow = time(NULL)%(24*60*60);
if(file_print == 1){
if(print_hour == 1)
fprintf(fp,"%d:",timeNow/3600+8);//hour
fprintf(fp,"%d:",(timeNow%3600)/60);//minute
fprintf(fp,"%d\n",timeNow%60);//second
}else{
if(print_hour == 1)
/**
* @brief This function is the main function of this script set. For those who cannot read script, I think this name is better than main.
**/
function choose_Me_to_Backup(){
readTable();
}
/**
* @brief This function can read a sheet table in the file
*
@gogomako
gogomako / gist:2065f1dd701573e39f12
Last active December 24, 2015 08:13
利用make假跑印出編譯時該MODEL的所有的flag
$make MODEL=[$model] --just-print | grep -m 1 "\-D"
@gogomako
gogomako / addSVNRevisionPostfix
Last active December 24, 2015 07:59
對檔名加上SVN的HEAD revision作為postfix
#get svn revision
revision=`svn info -rHEAD | grep "Last Changed Rev" | awk '{print $4}'`
echo newest SVN revision is $revision
#rename
input=$1
filename=${input%.*}
extension=${input##*.}
#echo $filename
#echo $extension
@gogomako
gogomako / calendar.c
Created December 24, 2015 08:06
萬年曆。從2000年起算,0代表星期一,6代表星期日。
#include<stdio.h>
#include<stdlib.h>
int is_leap_year(int year){
if((year - 2000)%400==0)
return 1;
else if((year - 2000)%100 == 0)
return 0;
else if((year - 2000)%4 == 0)
return 1;
@gogomako
gogomako / gitdiff-svnpatch.sh
Last active June 1, 2016 06:17 — forked from neosergio/gitdiff-svnpatch.sh
Converts git diff to svn patch format and acceptable for reviewboard 2.0.23
TAB=$'\t'
#get svn revision from manually input
SVN_DIFF_REV=$1
git diff --no-prefix --ignore-space-at-eol | sed -e "s/^diff --git [^[:space:]]*/Index:/" -e "s/^index.*/===================================================================/" -e "/^---/s/$/${TAB}(revision ${SVN_DIFF_REV})/" | awk '{if($1!="+++") print ; else print $1" "$2"\t(working copy)"}' | sed -e "/\/dev\/null/s/[0-9]*)$/0)/" > changes.patch