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 | |
if [ x"$1" = x ] | |
then | |
code_dir="." | |
else | |
code_dir="$1" | |
fi | |
if [ x"$2" = x ] |
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
set number | |
syntax on | |
set autoindent | |
set smartindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab |
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 | |
// get all sub strings for a given string | |
// return an array whose count is O(n^2) | |
function all_substr($str) | |
{ | |
$length = strlen($str); | |
$ret = array(); | |
for ($i=0; $i < $length; $i++) { | |
$max_length = $length - $i; |
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 | |
// from file | |
function make_image2($imagefile, $opt = array()) | |
{ | |
// deault option | |
$opt = array_merge(array( | |
'crop' => 0, | |
'resize' => 0, | |
'width' => 50, |
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 | |
/** | |
* 简单的树结构,可以插入,删除,检测某节点是否存在 | |
*/ | |
class XcTree | |
{ | |
// tree structure | |
// $tree = array( | |
// array( |
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 | |
/** | |
* | |
*/ | |
class MoneyDec | |
{ | |
public $val; | |
public $pr; | |
public $int; |
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($key = null, $or = null) | |
{ | |
if ($key === null) | |
return $_GET; | |
return isset($_GET[$key]) ? trim($_GET[$key]) : $or; | |
} | |
function _post($key = null, $or = null) | |
{ |
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 | |
ini_set('display_errors', 1); | |
error_reporting(E_ALL | E_STRICT); | |
set_time_limit(1000); | |
$root_url = 'http://mitpress.mit.edu/sicp/full-text/book/'; | |
$start_url = 'http://mitpress.mit.edu/sicp/full-text/book/book.html'; | |
$save_root = 'sicp'; |
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 lint | |
* 用法:放在www目录下,用浏览器访问即可 | |
* 作者:王霄池 | |
* 有 bug,请去打击王霄池 | |
*/ | |
ini_set('display_errors', 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 | |
ini_set('display_errors', 1); | |
error_reporting(E_ALL | E_STRICT); | |
/** | |
* 这个 JSON 解析器还有以下问题: | |
* 不能处理utf编码 | |
* 用的是递归,可能会产生 stack overflow | |
* 整体需要扫描两遍以上,效率低 |
OlderNewer