Skip to content

Instantly share code, notes, and snippets.

@wgm89
wgm89 / gist:1b3a95b8a3a68afee255
Last active November 24, 2016 02:16
中英翻译脚本
#!/usr/bin/php
<?php
//author:saeed
$api = 'http://dict.youdao.com/fsearch?q=';
if(count($argv) > 1 && $argv[count($argv)-1] != '-h'){
$arg = array_shift($argv);
if($arg != 'php'){
$argv = array_slice($argv, 0);
server {
listen 8090;
root /var/www/ti;
index index.php index.html index.htm;
# Enable rewrite error log
# error_log /var/log/nginx/localhost.error_log debug;
# rewrite_log on;
@wgm89
wgm89 / gist:60bdb716b1d2816b88fb
Created December 19, 2014 12:24
PHPExcel usage
<?php
$packages = array();
$contents = file_get_contents('package.txt');
$packages = explode('|', $contents);
foreach ($packages as $key=>$package) {
if (empty($package)) continue;
$packages[$key] = trim($package);
}
@wgm89
wgm89 / UUID.php
Last active August 29, 2015 14:13 — forked from dahnielson/UUID.php
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@wgm89
wgm89 / gist:f85e945cc09f6615cb68
Last active August 29, 2015 14:17
syntaxCheck
#!/bin/bash
search_dir=$1
i=0
error_files=()
if [ ! $search_dir ]; then
search_dir='.'
fi
if [ -f "$search_dir" ];then
ck_result=`php -l $search_dir`
sending HTTP requests[https://github.com/jakubroztocil/httpie]
php syntaxCheck [my gist]
@wgm89
wgm89 / gist:1276d577c4bea531c970
Created March 20, 2015 03:42
Extension Reflection
<?php
$e = new ReflectionExtension('gearman');
print "<?php\n\n// Gearman Version: " . $e->getVersion() . "\n\n";
foreach ($e->getClasses() as $c) {
print 'class ' . $c->name . " {\n";
foreach ($c->getMethods() as $m) {
print ' ';
if ($m->isPublic()) {
print 'public';
} elseif ($m->isProtected()) {
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
pcntl_waitpid($pid, $status, WUNTRACED); //Protect against Zombie children
if (pcntl_wifexited($status)) {
echo "Child exited normally";
} else if (pcntl_wifstopped($status)) {
echo "Signal: ", pcntl_wstopsig($status), " caused this child to stop.";
<?php
$msg_key = 0x3000111; //系统消息队列的key
$worker_num = 2; //启动的Worker进程数量
$worker_pid = array();
$queue = msg_get_queue($msg_key, 0666);
if($queue === false)
{
die("create queue fail\n");
}
@wgm89
wgm89 / gist:2e8a3e882c2f986e797a
Last active August 29, 2015 14:17
vim plugin
1.Vundle.vim
2.ctrl+p(git)
3.ctags(set tags+=./../tags,./../../tags,./../../../tags
4.tlist