This file contains hidden or 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 | |
// add exception_handle | |
function exception_handler($exception) { | |
echo "Uncaught exception: file:{$exception->getFile()} line:{$exception->getLine()} {$exception->getMessage()}", "\n"; | |
} | |
set_exception_handler('exception_handler'); |
This file contains hidden or 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/sh | |
PS3="Which host? > " | |
select host in `cat ~/.ssh/config | egrep '^Host' | cut -d ' ' -f 2`; do | |
[[ $host ]] && { | |
echo "ssh connect to $host" | |
ssh $host | |
break; | |
} | |
done |
This file contains hidden or 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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/<\1$(parse_git_dirty)>/" |
This file contains hidden or 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
these queries are same run time. |
This file contains hidden or 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
$.ajax({ | |
url: "ajax.html", | |
success: function(data) { | |
alert('success!!'); | |
}, | |
error: function(data) { | |
alert('error!!!'); | |
} | |
}); |
This file contains hidden or 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 | |
$time_start = microtime(true); | |
// 何か重い処理 | |
$time = microtime(true) - $time_start; | |
echo "{$time} 秒"; |
This file contains hidden or 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 | |
$test = function ($expect, $actual) { | |
if ($expect === $actual) { | |
echo 'OK, '; | |
} else { | |
echo "NG expect:{$expect} actual:{$actual} <br>"; | |
} | |
}; |
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Func<int, int, int> abc = (n, i) => { return (n * i); }; | |
Console.WriteLine(abc(3, 4)); | |
/** | |
* output: | |
* 12 |
This file contains hidden or 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 | |
#refs. http://blog.64p.org/entry/2012/08/24/165701 | |
function kill_children { | |
pkill -P $$; | |
wait; | |
} | |
trap "kill_children" EXIT |
This file contains hidden or 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 | |
/** | |
* convert 20120102 to 2012-1-2 | |
* | |
* @return string | |
*/ | |
function convertDate($date) { | |
$dateInfo = date_parse_from_format('Ymd', $date); | |
return $dateInfo['year'] . '-' . $dateInfo['month'] . '-' . $dateInfo['day']; | |
} |