Skip to content

Instantly share code, notes, and snippets.

View JingwenTian's full-sized avatar
🎯
Focusing

JingwenTian JingwenTian

🎯
Focusing
View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{margin:0;padding:0;}
body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;height:1000px;}
a{color:#08c;text-decoration:none;}
a:hover,a:focus{color:#005580;text-decoration:underline;cursor:pointer;}
@JingwenTian
JingwenTian / gist:f1eecf7ed01610e697a1
Created May 20, 2014 03:15
原生JS(导航的显示与隐藏)
/*NEW NAVIGATOR START*/
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
@JingwenTian
JingwenTian / array.php
Created May 24, 2014 17:07
PHP二维数组转一位数组
<?php
//一个很大的二维数组
$arr = array(
0 => array(
'id'=>11,
'name'=>'name1'
),
1 => array(
'id'=>22,
'name'=>'name2'
<!DOCTYPE html> <!-- HTML5 doctype 不区分大小写 -->
<html lang="zh-cmn-Hans-CN"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用IE最新版本和 Chrome -->
<meta name="renderer" content="webkit|ie-comp|ie-stand"> <!-- 360 浏览器内核控制 -->
<!--
content的取值为webkit,ie-comp,ie-stand之一,区分大小写,分别代表用webkit内核,IE兼容内核,IE标准内核。
@JingwenTian
JingwenTian / memcache.php
Created July 8, 2014 16:28
memcache class
<?php
class ChatMemcache {
public $memcache;
public function __construct() {
$this->memcache = new Memcache;
$this->memcache->connect( CHAT_MEMCACHE_HOST, CHAT_MEMCACHE_PORT );
}
<?php
$cache = new Memcached();
$cache->addServer('servername', 11211);
$myCacheKey = 'my_cache_key';
$row = $cache->get($myCacheKey);
@JingwenTian
JingwenTian / gist:3d79c472822a355a4763
Created August 21, 2014 01:10
SQL常见的可优化点
# ###########################################
# 索引相关
# ###########################################
– 查询(或更新,删除,可以转换为查询)没有用到索引
这是最基础的步骤,需要对sql执行explain查看执行计划中是否用到了索引,需要重点关注type=ALL, key=NULL的字段。
– 在索引字段上施加函数
to_char(gmt_created, ‘mmdd’) = ’0101′
正确的写法
gmt_created between to_date(“20090101″, “yyyymmdd”) and to_date(“20090102″, “yyyymmdd”)
– 在索引字段上使用全模糊
@JingwenTian
JingwenTian / README.md
Last active August 29, 2015 14:06 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@JingwenTian
JingwenTian / painty.php
Created September 14, 2014 05:24
HTML转图片的PHP库 Painty
<?
$html=@$_GET['html'];
if(get_magic_quotes_gpc())
$html = stripslashes($html);
if(!$html)
$html='<h1>No Text</h1><hr/><p>You did not give a html parameter to show:<br /><b>...painty.php?html=...</b></p><p><img src="http://static.php.net/www.php.net/images/php.gif" /></p>';
$config = array
(
'input' => $html,
'output' => "png",