Skip to content

Instantly share code, notes, and snippets.

View picasso250's full-sized avatar
💭
I may be slow to respond.

pica picasso250

💭
I may be slow to respond.
View GitHub Profile
@picasso250
picasso250 / code_line.sh
Last active October 13, 2015 16:17
count how many lines you write in your project dir
#!/bin/sh
if [ x"$1" = x ]
then
code_dir="."
else
code_dir="$1"
fi
if [ x"$2" = x ]
@picasso250
picasso250 / .vimrc
Last active December 14, 2015 05:40
a lot of settings, .rc .etc. Sublime Text, Vim
set number
syntax on
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
<?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;
<?php
// from file
function make_image2($imagefile, $opt = array())
{
// deault option
$opt = array_merge(array(
'crop' => 0,
'resize' => 0,
'width' => 50,
@picasso250
picasso250 / tree.php
Last active December 17, 2015 00:59
简单的树结构,可以插入,删除,检测某节点是否存在
<?php
/**
* 简单的树结构,可以插入,删除,检测某节点是否存在
*/
class XcTree
{
// tree structure
// $tree = array(
// array(
@picasso250
picasso250 / MoneyDec.php
Last active December 17, 2015 01:39
计算时指定精度,适用于计算财务
<?php
/**
*
*/
class MoneyDec
{
public $val;
public $pr;
public $int;
@picasso250
picasso250 / sugar.php
Last active December 17, 2015 03:49
sugar functions in php
<?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)
{
<?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';
<?php
/**
* PHP lint
* 用法:放在www目录下,用浏览器访问即可
* 作者:王霄池
* 有 bug,请去打击王霄池
*/
ini_set('display_errors', 1);
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
/**
* 这个 JSON 解析器还有以下问题:
* 不能处理utf编码
* 用的是递归,可能会产生 stack overflow
* 整体需要扫描两遍以上,效率低