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 | |
| // ワンソース | |
| function event() { | |
| $args = func_get_args(); | |
| $name = array_shift($args); | |
| $callable = array_pop($args); | |
| $is_call = $callable(); |
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 | |
| $t = microtime(ture); | |
| for($i = 0; $i < 1000000; $i++) {(string)$i;} | |
| echo microtime(ture) - $t; |
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 | |
| class C | |
| { | |
| protected $middleware; | |
| public function __construct() { | |
| $this->middleware = array($this); //Cオブジェクト自身を参照させる | |
| } |
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 | |
| namespace A; | |
| class C | |
| { | |
| static function foo() {echo "A_foo\n";} | |
| } | |
| namespace B; | |
| class C | |
| { |
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
| $ psql dbname -U username -F ',' -A -c 'select * from users limit 10' |
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
| $ ls | ruby -nle '$_.scan(/\d{8}/) {|m| File.rename(m, m.sub(/(\d{4})(\d{2})(\d{2})/) {"#{$1}_#{$2}_#{$3}"})}' |
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
| var c = {name: 'hoge'}; | |
| (function() {this.echo = function() {console.log(this);};}).call(c); | |
| c.echo(); |
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
| # マッチした最初の文字を置換 | |
| cat hoge.txt | ruby -pe '$_.sub!("hoge", "fuge")' > fuge.txt | |
| # マッチした全ての文字を置換 | |
| cat hoge.txt | ruby -pe '$_.gsub!("hoge", "fuge")' > fuge.txt |
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
| # bash | |
| # <と(の間はスペースが入らない | |
| diff <(command1) <(command2) | |
| # bash以外 | |
| command1 | ( command2 | diff /dev/fd/3 -) 3<&0 |
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
| # カレントディレクトリのディレクトリのみ表示 | |
| ls -aF | grep -E '[^\.]+/$' |