Skip to content

Instantly share code, notes, and snippets.

@wgm89
wgm89 / gist:11030047
Created April 18, 2014 07:47
repair ubuntu resolution
Screen Resolution stuck at 640x480 after installing
In /etc/X11/xorg.conf, look for these two lines :
HorizSync 28.0 - 33.0
VertRefresh 43.0 - 72.0
and replace them with
HorizSync 30.0 - 83.0
@wgm89
wgm89 / gist:a35003b585a84966a4b7
Created May 9, 2014 04:00
点击 排除 某区域
$(document).click(function(e){
// Check if click was triggered on or within #menu_content
if( $(e.target).closest("#menu_content").length > 0 ) {
return false;
}
// Otherwise
// trigger your click function
});
@wgm89
wgm89 / gist:af5811f2d4a2797ff6ec
Last active August 29, 2015 14:01
php message queue
消息队列(message queue)也是Linux系统进程间通信的一种方式。
除了现有的一些消息队列解决方案以外,PHP对共享内存段的操作有两组函数:System V IPC和Shared Memory。 其中System V IPC由AT&T的贝尔实验室对早期的UNIX系统贡献而来,现在的linux系统都完美的继承了下来,该系列函数能够更方便的操作数据,无需像Shared Memory那样必须自己掌握读写时的偏移量、长度等,也不用序列化/反序列化来回转换(因为Shared Memory函数只支持字符串格式的数据参数)。但是System V IPC系列不支持Windows,所以如果要在win环境下使用,只能选Shared Memory。
PHP的System V msg模块是对Linux系统支持的System V IPC中的System V消息队列函数族的封装。我们需要利用sysvmsg模块提供的函数来进进程间通信。
<?php
$message_queue_key = ftok(__FILE__, 'a');
$message_queue = msg_get_queue($message_queue_key, 0666);
var_dump($message_queue);
$message_queue_status = msg_stat_queue($message_queue);
@wgm89
wgm89 / gist:ec9a7cb5dafbea9947a7
Last active August 29, 2015 14:01
filter data
<?php
protected function _strip_text($data, $type=false){
if(is_array($data)){
foreach($data as $key=>$val){
$data[$key] = $this->_strip_text($val, $type);
}
}elseif(is_object($data)){
foreach(get_object_vars($data) as $property => $val) {
$data->$property = $this->_strip_text($val, $type);
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设定主题
set t_Co=256
syntax enable
set background=dark
colorscheme molokai
" 设定默认解码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#define POSTURL "http://127.0.0.1"
#define LOGFILE "post.log"
#define RESOURCE_KEY ""
#define CUSTOM_VALUE ""
#define UPLOAD_TOKEN ""
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`