Skip to content

Instantly share code, notes, and snippets.

View wangshijun's full-sized avatar

wangshijun wangshijun

View GitHub Profile
@wangshijun
wangshijun / hideaddrbar.js
Created August 27, 2012 07:33 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@wangshijun
wangshijun / CSS
Created August 27, 2012 07:34
Border-Radius
-webkit-border-radius: 3px 3px 0 0;
-khtml-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
-ms-border-radius: 3px 3px 0 0;
-o-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
@wangshijun
wangshijun / index.php
Created August 27, 2012 08:36
php: environment dependent config autoloading Yii startup
<?php
define("APP_DIR", dirname(dirname(__FILE__)));
define("WWW_DIR", dirname(APP_DIR));
define("CONF_DIR", APP_DIR . "/protected/config/");
$clusters = require_once(CONF_DIR . "clusters.php");
$mainConfig = require_once(CONF_DIR . "main.php");
// 根据应用程序所在环境加载配置, 默认为develop
if (isset($clusters["product"]) && in_array(strtolower(php_uname("n")), $clusters["product"])) {
@wangshijun
wangshijun / gist:3521924
Created August 30, 2012 03:02
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@wangshijun
wangshijun / night_mode.js
Created August 30, 2012 09:57
javacript: web page night mode
var nightCss = 'html,body,div,span,applet,object,'
+ 'h1,h2,h3,h4,h5,h6,p,blockquote,'
+ 'pre,abbr,acronym,address,big,cite,'
+ 'code,del,dfn,em,font,img,ins,kbd,'
+ 'q,s,samp,small,strike,strong,sub,'
+ 'sup,tt,var,b,u,i,center,dl,dt,dd,'
+ 'ol,ul,li,fieldset,form,label,'
+ 'legend,table,caption,tbody,tfoot,thead,th,td'
+ '{background:#333333 !important;'
+ 'color:#A0A0A0 !important;'
@wangshijun
wangshijun / detect_next.js
Created August 30, 2012 09:59
javascript: detect next page
/**
* 检测下一页javascript层面的实现, 支持html5形式,时间复杂度n
*
* @author wangshijun <wangshijun2010@gmail.com>
* @package default
* @subpackage default
* @copyright (c) wangshijun2010@gmail.com
* @todo Implement this in a OOP style
*/
@wangshijun
wangshijun / vimrc.local
Created August 31, 2012 02:19
vim: vim config file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设定默认解码
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
@wangshijun
wangshijun / Gesture.java
Created August 31, 2012 05:20
java: Continuous Recognition and Visualization of Pen Strokes and Touch-Screen Gestures
/*
* Continuous Recognition and Visualization of Pen Strokes and Touch-Screen Gestures
* Version: 2.0
*
* If you use this code for your research then please remember to cite our paper:
*
* Kristensson, P.O. and Denby, L.C. 2011. Continuous recognition and visualization
* of pen strokes and touch-screen gestures. In Procceedings of the 8th Eurographics
* Symposium on Sketch-Based Interfaces and Modeling (SBIM 2011). ACM Press: 95-102.
*
@wangshijun
wangshijun / quicksort.php
Created August 31, 2012 13:49
php: quick sort algorithm implemented in php
<?php
$data = array(55,41,59,26,53,58,97,93);
quicksort(0, sizeof($data)-1);
function quicksort($lower, $upper) {
global $data;
if ($lower >= $upper) {
return;
@wangshijun
wangshijun / iplocation.php
Created September 11, 2012 06:04
php: get client location city based on ip address
<?php
/**
* 根据用户IP获取用户所在城市
* @param string $userip IP
* @return string Location
* @todo Implement this service in an OOP way, and Silington Pattern
*/
function get_client_location($userip) {
//IP数据库路径