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
<phpunit bootstrap="./TestHelper.php" colors="true"> | |
<!-- Version: $Id$ --> | |
<testsuite name="Zend Framework Unit Test Demo"> | |
<directory>./</directory> | |
</testsuite> | |
<filter> | |
<whitelist> | |
<directory suffix=".php">../library/</directory> | |
<directory suffix=".php">../application/</directory> |
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 | |
$mongo = new Mongo(); | |
$db = $mongo->selectDb('firv_exam'); | |
// 要查询的collection | |
$collection = 'question'; | |
// 构造 map 和 reduce 函数 | |
$map = <<<MAP | |
function() { emit(this.username,1); } // this.username 相当于 sql 里的 group by username |
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
SELECT * , IF( `Word` = 'sim', 1, IF( `Word` LIKE 'sim%', 2, IF( `Word` LIKE '%sim', 4, 3 ) ) ) AS `sort` FROM `dblist` WHERE `Word` LIKE '%sim%' ORDER BY `sort` , `Word` | |
# 得到结果: | |
1. sim | |
2. sim* | |
3. *sim* | |
4. sim* |
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 | |
/** | |
* Pdo MySql driver wrap | |
* | |
* @category Class | |
* @package Fasthold Own PHP Snippet | |
* @copyright Copyright (c) 2007 | |
* @license New BSD License | |
* @author Fasthold Lau ([email protected]) | |
*/ |
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 | |
/** | |
* PDF2PNG | |
* @param $pdf 待处理的PDF文件 | |
* @param $path 待保存的图片路径 | |
* @param $page 待导出的页面 -1为全部 0为第一页 1为第二页 | |
* @return 保存好的图片路径和文件名 | |
*/ | |
function pdf2png($pdf,$path,$page=-1) | |
{ |
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
function check_username($username) { | |
$guestexp = ‘\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8′; | |
$len = $this->dstrlen($username); | |
if($len > 15 || $len < 3 || preg_match(“/\s+|^c:\\con\\con|[%,\*\"\s\<\>\&]|$guestexp/is”, $username)) { | |
return FALSE; | |
} else { | |
return TRUE; | |
} | |
} |
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
sudo apt-get update | |
sudo apt-get install build-essential vim gvim git gitk | |
mkdir ~/temp | |
mkdir ~/app | |
# 安装 chrome | |
sudo apt-get install chromium-browser | |
# 安装 sublime text | |
cd ~/temp |
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 | |
/** | |
* 加密 hash,生成发送给用户的 hash 字符串 | |
* | |
* @param array $hash_data | |
* @param string $hash_key | |
* @return string | |
*/ | |
function encode_hash($hash_data, $hash_key = false) |
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
// From http://stackoverflow.com/questions/476679/preloading-images-with-jquery | |
function preload(arrayOfImages) { | |
$(arrayOfImages).each(function(){ | |
$('<img/>')[0].src = this; | |
// Alternatively you could use: | |
// (new Image()).src = this; | |
}); | |
} |
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": { | |
"silex/silex": "1.1.*@dev", | |
"respect/validation": "dev-develop", | |
"symfony/browser-kit": "2.4", | |
"monolog/monolog": "1.6.*@dev", | |
"cartalyst/sentry": "2.0.*", | |
"illuminate/database": "4.1.*", | |
"ircmaxell/password-compat": "*", | |
"gabordemooij/redbean": "dev-master" |
OlderNewer