Skip to content

Instantly share code, notes, and snippets.

View guweigang's full-sized avatar

南無假行僧 guweigang

View GitHub Profile
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@guweigang
guweigang / socket_upload.php
Last active December 18, 2015 14:09
upload file using fsocketopen
<?php
/**
* php fsockopen上传,如果使用https,必须先开启ssl才能使用
* @param str $url 要上传的url
* @param array $files 上传的文件参数 数组格式
* array(
* 0=> array(
* "name" => "图片0.jpg", //显示的文件名
* "type" => "image/jpeg", //文件mime
* "savepath" => "D:/www/uploadfile/201305", //文件所在的目录
(define-macro (doc func-name)
(let ((func-name (string func-name)))
(set 'f (read-file {/e:/newlisp/newlisp_manual.html}))
(set 'r (regex (string "<a name=\"" func-name "\"></a>") f))
(set 'n0 (r 1))
(set 'n1 ((regex "<a name=" f 0 (+ n0 (r 2))) 1))
(set 'html-text (slice f n0 (- n1 n0)))
(replace "<.*?>" html-text "" 0)
(replace "&lt;" html-text "<")
(replace "&gt;" html-text ">")
<?php
function seq($width, $lastNum, $inc)
{
$num = $lastNum;
if($inc==true) {
if($lastNum+$width>10) {return false;}
} else {
if($lastNum-$width<0) {return false;}
}
$num = 0;
<?php
$evtManager = new \Phalcon\Events\Manager();
$logger = new \Phalcon\Logger\Adapter\File($configs->database->$nodeName->logger . date("Ymd"));
$evtManager->attach('db', function($event, $connection) use ($logger) {
if ($event->getType() == 'beforeQuery') {
$variables = $connection->getSqlVariables();
if (count($variables)) {
$logger->log($connection->getSQLStatement() . "; Bind parameters: ". join(", ", $variables), \Phalcon\Logger::INFO);
} else {
$logger->log($connection->getSQLStatement(), \Phalcon\Logger::INFO);
@guweigang
guweigang / make_php
Last active December 23, 2015 08:48
install php under ubuntu
sudo apt-get install libxml2-dev
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libpng12-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libicu-dev
sudo apt-get install libmcrypt-dev
sudo apt-get install libltdl-dev
<?php
/* binlog_task.php ---
*
* Filename: binlog_task.php
* Description:
* Author: Gu Weigang * Maintainer:
* Created: Mon Nov 25 14:22:33 2013 (+0800)
* Version:
* Last-Updated: Mon Nov 25 14:42:36 2013 (+0800)
* By: Gu Weigang
<?php
/* BinlogEvent.php ---
*
* Filename: BinlogEvent.php
* Description:
* Author: Gu Weigang * Maintainer:
* Created: Fri Nov 8 20:16:59 2013 (+0800)
* Version: 117777
* Last-Updated: Tue Nov 19 15:05:08 2013 (+0800)
* By: Gu Weigang
<?php
/* Message.php ---
*
* Filename: Message.php
* Description:
* Author: Gu Weigang * Maintainer:
* Created: Sun Nov 10 15:22:06 2013 (+0800)
* Version: 117442
* Last-Updated: Wed Nov 13 20:47:38 2013 (+0800)
* By: Gu Weigang
<?php
/* DefaultEvent.php ---
*
* Filename: DefaultEvent.php
* Description:
* Author: Gu Weigang * Maintainer:
* Created: Fri Nov 8 16:34:55 2013 (+0800)
* Version: 116900
* Last-Updated: Wed Nov 13 16:46:24 2013 (+0800)
* By: Gu Weigang