This file contains 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 WeiChatAuth | |
{ | |
/** | |
* 获取access_token | |
* | |
* 一定通过网络获取 | |
*/ | |
public static function getAccessToken($appid, $appsecret) |
This file contains 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 | |
// convert with float | |
function my_base_convert($n, $from_base, $to_base) | |
{ | |
// when int | |
if (intval($n) == floatval($n)) { | |
$n = intval($n); | |
return base_convert($n, $from_base, $to_base); | |
} |
This file contains 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 | |
set_time_limit(0); // 无限制的跑下去,跑到天荒地老 | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
// 绑定地址和端口 | |
if (!socket_bind($socket, $config['tcp.host'], $config['tcp.port'])) { | |
die('socket bind fail'); | |
} |
This file contains 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 | |
set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) { | |
$msg = "$errno $errstr in $errfile:$errline "; | |
$trace = debug_backtrace(); | |
array_shift($trace); | |
$trace = array_map(function ($e) { | |
$function = $e['function']; | |
if (isset($e['class'])) { | |
$function = $e['class'].$e['type'].$function; | |
} |
This file contains 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
alias tl="tmux ls" | |
alias ta="tmux attach" |
This file contains 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 | |
static $traces; | |
if (!isset($traces)) { | |
$traces = array(); | |
} | |
if (stripos($sql, "SELECT `t_acct_user`.* FROM `t_acct_user` WHERE `user_id` = '") !== false) { | |
var_dump($sql); | |
$trace = implode(' <== ', array_map(function($e){ | |
$func = isset($e['class']) ? "$e[class]::$e[function]" : $e['function']; |
This file contains 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
var c=document.getElementById("XcCanvas"); | |
var ctx=c.getContext("2d"); | |
ctx.drawPoint = function (point) { | |
var x, y, size; | |
if (arguments.length === 2) { | |
x = arguments[0]; | |
y = arguments[1]; | |
} else { | |
x = point.x; | |
y = point.y; |
This file contains 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 | |
// 1 | |
TcpClient::api_name(array('key' => $value, 'key2' => $value)); | |
// 2 | |
TcpClient::api_name($value1, $value2); |
This file contains 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
<style type="text/css"> | |
.cell{ | |
width: 40px; | |
height: 40px; | |
display: inline-block; | |
border: 1px solid; | |
} | |
.c1 { | |
background-color: red; | |
} |
This file contains 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
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var Iconv = require('iconv').Iconv; | |
var iconv = require('iconv-lite'); | |
var i = 10; | |
var url = 'http://www.esgweb.net/Html/Yxzcpstj/'+i+'.htm'; | |
console.log(url); | |
request(url, function(err, resp, body) { | |
if (err) |