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
expr $1 + 1 >/dev/null 2>&1 | |
if [ $? -ne 1 -a $? -ne 0 ]; then | |
echo "must be numeric" | |
exit | |
elif [ $1 -lt 0 ]; then | |
echo "must be more than 0" | |
exit | |
elif [ $1 -eq 1 -o $1 -eq 0 ]; then | |
echo 1; |
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
<?php | |
$color = array( | |
'black' => 30, | |
'red' => 31, | |
'green' => 32, | |
'brown' => 33, | |
'blue' => 34, | |
'purple' => 35, | |
'cyan' => 36, | |
'grey' => 37, |
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 | |
COMMAND=`basename $0` | |
usage(){ | |
echo "Usage: $COMMAND FILE" | |
echo "With no FILE, read standard input." | |
} | |
error(){ | |
local ERROR_MESSAGE=$@ |
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
sinon = require("sinon") | |
should = require("should") | |
a = {} | |
a.test = () -> | |
[1, 2] | |
describe "calc", -> | |
describe ".add", -> | |
it "should return sum of 2 arguments", -> | |
result = 1 + 2 |
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
run=$(ps aux | grep '[h]oge') | |
if [ -z "$run" ]; then | |
do something | |
fi |
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
% mocha *.js [~/work/test] | |
.. | |
✖ 1 of 2 tests failed: | |
1) hoge fuga: | |
AssertionError: expected 1 to equal 2 | |
以下エラーメッセージ |
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
usage() | |
{ | |
echo $0 hoge | |
} | |
if [ -z $1 ]; then | |
usage | |
exit | |
else | |
expr $1 + 1 >/dev/null 2>&1 |
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
function yes_no { | |
msg=$1 | |
while : | |
do | |
echo -n "${msg} y/N: " | |
read ans | |
case $ans in | |
[yY]) return 0 ;; | |
[nN]) return 1 ;; | |
esac |
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
case $1 in | |
hogehoge) | |
hogehoge | |
;; | |
fugafuga) | |
fugafuga | |
;; | |
*) | |
echo hogehoge fugafuga | |
exit 1 |
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/zsh | |
func(){ | |
echo 2 | |
local pre_func_definition | |
local pre_count | |
local new_count | |
local new_func_definition | |
pre_func_definition=$(which func) | |
pre_count=$(echo $pre_func_definition | awk 'NR==2, NR==2 {print $2}') |