This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#log format:[log_msg time] | |
calc_avg(){ | |
awk 'BEGIN{ OFS="\t"; sum=0; max=0; } | |
NR==1 { min=$2; } | |
{ sum+=$2; if($2>max){max=$2}; if(min>$2){min=$2}; } | |
END{ print($1, sum, NR, max, min, sum/NR) }' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'BEGIN{ OFS="\t"; sum=0; max=0; } | |
NR==1 { min=$2; } | |
{ sum+=$2; if($2>max){max=$2}; if(min>$2){min=$2}; } | |
END{ print($1, sum, NR, max, min, sum/NR) }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
foo=${1:-hoge} | |
echo $foo #$1がなかったらhogeをデフォルト値としてfooに代入する | |
#var自身にデフォルト値としてhogeを代入としたいので以下のように書きたい | |
${var:=hoge} #このままでは、hogeが展開されてしまって、hogeなんてコマンドはないとシェル怒られる | |
echo "1:$var" | |
var= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <time.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#define ERROR(fmt, ...) err_msg(__FILE__, __FUNCTION__, __LINE__, "error", fmt, ##__VA_ARGS__) | |
#define WARNNING(fmt, ...) err_msg(__FILE__, __FUNCTION__, __LINE__, "warnning", fmt, ##__VA_ARGS__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <time.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
void err_msg(const char *, const char *, int, const char *, const char *, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC := gcc | |
RM := rm -f | |
CFLAGS = -Wall | |
programs := run | |
.PHONY: all | |
all: $(programs) | |
$(programs): libhello.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RM := rm -f | |
CXXFLAGS := -Wall | |
programs := run | |
.PHONY: all | |
all: $(programs) | |
$(programs): libhello.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC := gcc | |
RM := rm -f | |
CFLAGS := -Wall | |
CXXFLAGS := -Wall | |
programs := run | |
.PHONY: all | |
all: $(programs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
version=gtest-1.7.0 | |
root=/usr/local | |
sudo apt-get install cmake | |
wget https://googletest.googlecode.com/files/$version.zip -P ~ | |
(cd ~; unzip ${version}.zip;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 非再帰的make(non-recursive make) | |
# ソースファイルツリーが常に整頓されている前提 | |
# 使っていないソースファイルが紛れ込まないようにしなければならない、その辺はGitで管理する | |
# 内容的には "GNU Make 第3版、6章 大きなプロジェクトの管理" に載っているコードとほぼ同じ | |
# | |
### 参考 | |
#論文: "Recursive Make Considered Harmful" | |
#http://miller.emu.id.au/pmiller/books/rmch/ | |
#実際にnon-recursive makeを適用しているOSSプロダクト(OpenRADIUS)のMakefile解説(上記論文のサイトにもリンクが貼られている) | |
#http://evbergen.home.xs4all.nl/nonrecursive-make.html |
OlderNewer