Skip to content

Instantly share code, notes, and snippets.

@forthxu
forthxu / data.php
Last active March 29, 2016 06:34
业务需要,抓取页面排名数据保存,月末发邮件
<?php
foreach (glob("./data/*.html") as $filename) {
echo "<a href='$filename'>$filename</a><br/>";
}
?>
@forthxu
forthxu / zmqClient.php
Created March 1, 2016 07:36
zeromq php的使用,需要装php扩展
<?php
/*
* Hello World client
* Connects REQ socket to tcp://localhost:5555
* Sends "Hello" to server, expects "World" back
@forthxu
forthxu / bufferlog.php
Last active December 8, 2015 09:51
log and parase pockermine-pm pocket
<?php
namespace raklib\server;
use raklib\protocol\CLIENT_CONNECT_DataPacket; //0x09
use raklib\protocol\CLIENT_DISCONNECT_DataPacket; //0x15
use raklib\protocol\CLIENT_HANDSHAKE_DataPacket; //0x13
use raklib\protocol\PING_DataPacket; //0x00
use raklib\protocol\PONG_DataPacket; //0x03
use raklib\protocol\SERVER_HANDSHAKE_DataPacket; //0x10
@forthxu
forthxu / minecrafe pe client.php
Created November 25, 2015 09:29
try write a php client to learn the pocketmine-pe
<?php
//error_reporting(0);
header("Content-type:text/html;charset=utf-8");
function __autoload($class_name) {
require_once ('/workspace/minecraft/pocket/src/'.str_replace('\\','/',$class_name) . '.php');
}
function test($f=array()){
$magic = "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78";
$re = null;
@forthxu
forthxu / php thread example.php
Last active October 23, 2015 09:52
php thread example
<?php
//example 使用多线程处理任务
// http://netkiller.github.io/journal/thread.php.html 比较全部的php多线程学习
class vote extends Thread {
public $res = '';
public $url = array();
public $name = '';
public $runing = false;
@forthxu
forthxu / post-receive.sh
Last active September 14, 2015 03:52 — forked from icyleaf/post-receive.sh
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <[email protected]>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@forthxu
forthxu / gitbranch.php
Created August 14, 2015 10:22
git自助切换项目分支
<?php
// http://hostname:82/gitbranch.php
$root_path = '/workspace/www/';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<meta name="description" content="">
@forthxu
forthxu / githook.php
Last active August 29, 2015 14:27
git hook部署
<?php
// nohup /usr/local/php55/bin/php -S 0.0.0.0:82 -t /www/sync/ >> /www/sync/githook.log 2>&1 &
// http://hostname:82/githook.php?token=xfs
$valid_token = 'xfs';
$valid_ip = array('127.0.0.1');
$client_token = $_GET['token'];
$client_ip = $_SERVER['REMOTE_ADDR'];
$fs = fopen('./githook.log', 'a');
fwrite($fs, "\n".'Request on ['.date("Y-m-d H:i:s").'] from ['.$client_ip.']'.PHP_EOL);
if ($client_token !== $valid_token)
@forthxu
forthxu / is_idcard.php
Created June 11, 2015 06:09
函数主要用于国内身份证号码的验证,支持15位与最新的18位身份证号码。
function is_idcard( $id )
{
$id = strtoupper($id);
$regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/";
$arr_split = array();
if(!preg_match($regx, $id))
{
return FALSE;
}
if(15==strlen($id)) //检查15位
@forthxu
forthxu / swoole.php
Created April 8, 2015 10:07
swoole IDE开发工具开发提示
<?php
//src https://github.com/Gsinhi/swoole-ide
/**
* 当前Swoole的版本号
*/
define('SWOOLE_VERSION', SWOOLE_VERSION);
/**
* 使用Base模式,业务代码在Reactor中直接执行
*/