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 MongoClient(); | |
| $db = $mongo->dbName; | |
| $collection = $db->collectionName; | |
| $cursor = $collection->find($criteria, array('_id' => 1))->limit(1); | |
| if($coursor->count() == 0){ | |
| exit('not exist'); | |
| } |
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
| wget http://leptonica.googlecode.com/files/leptonica-1.69.tar.bz2 | |
| tat xvf leptonica-1.69.tar.bz2 | |
| cd leptonica-1.69 | |
| ./configure | |
| make && make install | |
| ldconfig | |
| wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz | |
| tar zxvf tesseract-ocr-3.02.02.tar.gz |
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 | |
| $client = new MongoClient('mongodb://127.0.0.1'); | |
| $collection = $client->test->test; | |
| //insert data | |
| $data[] = array('name' => 'zhangsan', 'age' => rand(1, 100)); | |
| $data[] = array('name' => 'zhangsan1', 'age' => rand(1, 100)); | |
| $data[] = array('name' => 'zhangsan2', 'age' => rand(1, 100)); |
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 | |
| //http://flask.pocoo.org/snippets/71/ that is good idea | |
| include 'predis/predis.phar'; | |
| class OnlineUsers { | |
| /* time to consider user online */ | |
| private $minutes = 5 ; | |
| function online() { |
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
| { | |
| "query" : { "query_string" : {"query" : "*:*"} }, | |
| "sort" : { | |
| "_script" : { | |
| "script" : "(doc['_id'].value + salt).hashCode()", | |
| "type" : "number", | |
| "params" : { | |
| "salt" : 10000 | |
| }, | |
| "order" : "asc" |
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
| { | |
| "movie2": { | |
| "properties": { | |
| "title": { | |
| "type": "string", | |
| "store": true | |
| }, | |
| "created": { | |
| "type": "date", | |
| "format": "yyyy-MM-dd HH:mm:ss" |
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 | |
| class Tuple extends SplFixedArray | |
| { | |
| protected $prototype; | |
| public function __construct(array $prototype, array $data = []) | |
| { | |
| echo __METHOD__ . "\r\n"; | |
| parent::__construct(count($prototype)); |
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 dump() | |
| { | |
| $args = func_get_args(); | |
| echo "\n<pre style=\"border:1px solid #ccc;padding:10px;margin:10px;font:14px courier;background:whitesmoke;display:block;border-radius:4px;\">\n"; | |
| $trace = debug_backtrace(false); | |
| $offset = (@$trace[2]['function'] === 'dump_d') ? 2 : 0; | |
| echo "<span style=\"color:red\">" . @$trace[1+$offset]['class'] . "</span>:" . |
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 | |
| function make_semiangle($str){ | |
| $arr = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', | |
| '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', | |
| 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E', | |
| 'F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J', |
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 | |
| $a = [ | |
| '1,2', | |
| '3', | |
| '4', | |
| '5,6' | |
| ]; | |
| $hash = [ | |
| 1 => 'xxx1', |