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
<?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 | |
$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 | |
// ワンソース | |
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 | |
function foo() { | |
$args = func_get_args(); //可変長引数を配列で取得 | |
$v = array_shift($args); | |
$callable = array_pop($args); | |
$callable($v); //コールバック関数を呼び出し | |
} |
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
require 'optparse' | |
OptionParser.new do |o| | |
o.on("-r") {puts 'read mode'} | |
o.on("-w") {puts 'write mode'} | |
o.on("-e") {puts 'edit mode'} | |
o.on("-d") {puts 'delete mode'} | |
end.parse! ARGV |
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 | grep -e "[0-9]\{4\}" | xargs mv ../sandbox_daily/ |
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 -U <username> -d <dbname> -c 'SELECT * FROM users where id > 10;' -A > log.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
# 起動 | |
$ ruby -r webrick -e 'WEBrick::HTTPServer.new(:DocumentRoot => "./", :Port => 8080).start' | |
# 停止 | |
$ ps aux | grep ruby | |
$ kill -9 <pid> |
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
[1,2].tap {|arr| arr << 3}.display |