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 | |
namespace Lib; | |
use Exception; | |
use Psr\Container\ContainerInterface; | |
use Psr\Container\ContainerExceptionInterface; | |
use Psr\Container\NotFoundExceptionInterface; | |
class Container implements ContainerInterface | |
{ |
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 | |
function get_first_line($content) { | |
$pos = -1; | |
do { | |
$pos = strpos($content, "\n", $pos+1); | |
$found = trim(substr($content, 0, $pos)); | |
// http://blog.sina.com.cn/s/blog_49f914ab0101eyjj.html | |
} while (trim(substr($content, 0, $pos), "\r\n\t \xEF\xBB\xBF") === ""); | |
return substr($content, 0, $pos); | |
} |
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 | |
/* vim: set expandtab tabstop=4 shiftwidth=4: */ | |
// +----------------------------------------------------------------------+ | |
// | PHP version 4.0 | | |
// +----------------------------------------------------------------------+ | |
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | | |
// +----------------------------------------------------------------------+ | |
// | This source file is subject to version 2.0 of the PHP license, | | |
// | that is bundled with this package in the file LICENSE, and is | | |
// | available at through the world-wide-web at | |
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 | |
# deploy project with ssh | |
# has to work with deploy_remote | |
set -eu | |
git_root_dir=~/Documents/work/git/xxx # the dir of git | |
git_src_dir=. # if you don't want copy whole dir, change it to sub dir | |
git_sub_dir="a b" # sub dir list to deploy |
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 | |
$f = isset($_GET['f']) ? $_GET['f'] : ''; | |
if (!$f) { | |
die("plz specify f"); | |
} | |
if (!is_file($f)) | |
die("$f is not a file"); | |
header("Content-Type:text/plain;charset=UTF-8"); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<canvas id="canvas" width="220" height="220"></canvas> | |
<script type="text/javascript"> | |
var canvas = document.getElementById('canvas'); |
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 | |
$zip = new ZipArchive; | |
$res = $zip->open($file); | |
if ($res === TRUE) { | |
for ($i=0;($filename=$zip->getNameIndex ($i))!==false; $i++) { | |
echo "$filename\n"; | |
if ($filename[strlen($filename)-1] == '/') { | |
$filename = iconv('UTF-8', 'GBK', $filename); | |
if (!is_dir($filename)) { |
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 |
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
#!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 |