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
<style type="text/css"> | |
canvas { border: 1px solid #000; position:absolute; top:0;left:0; | |
visibility: hidden; } | |
</style> | |
<canvas id="MainCanvas" width="480" height="640"></canvas> | |
<canvas id="SecondCanvas" width="480" height="640"></canvas> | |
<script type="text/javascript" src="bird.js"></script> |
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 | |
// php build in server vhost | |
// php -S 0.0.0.0:80 router.php | |
// on Windows, router.php must be absolute path, bug of php v5.4.26 | |
$map = array( | |
'host.name' => '/file/path', | |
); |
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 | |
$g_start_time = microtime(true); | |
register_shutdown_function(function () { | |
global $g_start_time; | |
$g_start_time = microtime(true) - $g_start_time; | |
UB_LOG_TRACE('%s (time %s ms)', $_SERVER['REQUEST_URI'], intval($g_start_time*1000)); | |
}); |
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 | |
$country = array ( | |
0 => | |
array ( | |
0 => 'Country', | |
1 => 'Capital', | |
2 => 'Latitude', | |
3 => 'Longitude', | |
), | |
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 | |
foreach (file('http://cygwin.com/mirrors.lst') as $line) { | |
echo $line; | |
if (preg_match('%^\w+://([\w.-]+)/%', $line, $matches)) { | |
$host = $matches[1]; | |
if (!isset($table[$host])) { | |
$output = shell_exec("ping $matches[1]"); | |
echo $output; | |
if (preg_match('/(\d+)ms/', $output, $matches)) { |
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
// from c++ version: https://gist.github.com/timshen91/f6a3f040e5b5b0685b2a | |
// author: wangxiaochi | |
function ConcatExpr (Left,Right) {this.Left = Left;this.Right=Right} // ab | |
function AltExpr(Left,Right) {this.Left = Left;this.Right=Right} // a|b | |
function RepeatExpr(SubExpr) {this.SubExpr= SubExpr;} // a* | |
function OptionalExpr(SubExpr) {this.SubExpr= SubExpr;} // a? | |
function MatchExpr(ch) { | |
this.ch= ch | |
} |
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
#!bash | |
# Usage: test X | |
# It will include `X.h` and `test_X.cpp` | |
# and execute all `test_.+()` functions. | |
if [[ x$1 == "x" ]]; then | |
echo "Usage: $0 <file>" | |
exit | |
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
#!env php | |
<?php | |
// PHP test tool by xiaochi | |
// Usage: test.php foo.php | |
// If you have a test_foo.php, it will automatically include | |
// foo.php and run test_foo.php. | |
// It also includes `vendor/autoload.php` | |
$vendor_autoload = "vendor/autoload.php"; |
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/sh | |
curl -sL 'https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz' | tar zx | |
cd libevent-2.0.20-stable/ | |
./configure --prefix=/usr/local/libevent/2.0.20-stable | |
make | |
sudo make install | |
sudo alternatives --install /usr/local/lib64/libevent libevent /usr/local/libevent/2.0.20-stable/lib 20018 \ | |
--slave /usr/local/include/libevent libevent-include /usr/local/libevent/2.0.20-stable/include \ | |
--slave /usr/local/bin/event_rpcgen.py event_rpcgen /usr/local/libevent/2.0.20-stable/bin/event_rpcgen.py |