Skip to content

Instantly share code, notes, and snippets.

View lizheming's full-sized avatar
:octocat:

Austin Lee lizheming

:octocat:
View GitHub Profile
@lizheming
lizheming / stringToPyin.php
Last active August 29, 2015 14:00
汉字转拼音,不考虑多音字的情况。
<?php
class dict {
private $_dict;
function __construct() {
/** 设置字典库 */
$this->_dict = array(
'A' => array(59371,41648,50400,33157,41392,18661,47599),
'Ai' => array(19697,32178,35504,36856,20712,25068,28663,26608,29399,19381,17099,47497,30339,43240,54250,56459,45201,25005,57749,17131,36057,28596,49375,29162,55685,31713,27114,64665,19190,56536,37508,22145,59104,42373,18930,17311,30185,29599,54922,60552,35971,19670,27069,47505,56476,52365,63875,43184,17031,45460,45466,43440,32176,44464,57310,36230,41904,42672,42928,42416,42160,18330,22758,52719,58012,27797,45716,44208,44720,23788,45302,25559,49645,30387,51430,56208,24969,51680,44976,16588,46209,43696,43952,18334,57994,29916,51424,34439),
'An' => array(63223,39405,58764,17125,31621,34691,56712,18059,46512,33240,42376,22239,20462,39914,36586,64753,21940,18566,20963,29912,29649,37368,23685,26617,22193,47024,25589,19441,40169,36845,45488,29099,29640,37881,24205,61928,55010,17352,50928,36553,22468,30127,3
function user_agent($ua){
//开始解析操作系统
$os = null;
if(preg_match('/Windows 95/i',$ua) || preg_match('/Win95/',$ua)) {
$os = "Windows 95";
} elseif (preg_match('/Windows NT 5.0/i',$ua) || preg_match('/Windows 2000/i', $ua)) {
$os = "Windows 2000";
} elseif (preg_match('/Win 9x 4.90/i',$ua) || preg_match('/Windows ME/i', $ua)) {
$os = "Windows ME";
} elseif (preg_match('/Windows.98/i',$ua) || preg_match('/Win98/i', $ua)) {
d=document;
var m = {
e: d.querySelectorAll('input'),
r: parseInt( d.body.clientWidth / 20 ),
c: parseInt( d.getElementById('container').clientHeight / 19),
o: function() {return {x: 0,y: Math.floor(m.c / 2)};},
g: function(x, y) {return m.e[(m.o().y - y) * m.r + x];}
};
var e = function(x, y) {
if( y>=0 )
@lizheming
lizheming / plugin.php
Created December 27, 2013 11:22
XiaMiPlayer插件部分代码
<?php
/**
* 虾米音乐播放器:虾米音乐搜索+引用
*
* @package XiaMiPlayer
* @author 公子
* @version 3.0.6
* @link http://zh.eming.li/#typecho
*/
class XiaMiPlayer_Plugin implements Typecho_Plugin_Interface
<?php
class WXRDecoder
{
protected $_parser;
protected $_ns;
public $posts=array();
public $tags=array();
public $post_table = 'tbl_posts';
@lizheming
lizheming / srun.login.curl.sh
Created March 8, 2013 00:58
srun login by curl
curl -d 'username={username}&password={password}&mac={macaddress}&n=99&type=3' http://202.204.105.195/cgi-bi
n/do_login
@lizheming
lizheming / blogmi.navi.html
Last active December 11, 2015 22:38
blogmi无限翻页
<div id="page_bar">
<div id="more" page="2">载入更多</div>
<style type="text/css">
#more {font-size:14px;}
#more:hover {cursor:pointer;}
</style>
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$('#more').click(function() {$.get('?page='+$('#more').attr('page'), function(data) {$('#content_box').append($('#content_box', data).html());$('#more').attr('page',parseInt($('#more').attr('page'))+1);});});
</script>
@lizheming
lizheming / gist:4554221
Created January 17, 2013 06:52
wechat.php
<?php
include "config.php";
function sql_query($sqlcon){
$con=mysql_connect(DATABASE_HOST, DATABASE_USER,DATABASE_PSSWORD);
mysql_select_db(DATABASE_DB_NAME);
mysql_query("SET NAMES 'utf8'");
$result = mysql_query($sqlcon);
mysql_close($con);
return $result;
}
@lizheming
lizheming / xiami.php
Last active February 6, 2017 18:15
虾米自动签到
<?php
set_time_limit(0);
/*输入账号密码*/
$name = '';
$password = '';
//获取登陆cookie
$curl_post = 'email='.$name.'&password='.$password.'&done=/&submit=登 录';
$cookie_file = dirname(__FILE__).'/cookie.txt';
$curl = curl_init();

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?