Skip to content

Instantly share code, notes, and snippets.

Avatar

wangshijun wangshijun

View GitHub Profile
@wangshijun
wangshijun / hideaddrbar.js
Created Aug 27, 2012 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
View hideaddrbar.js
/*
* 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 Aug 27, 2012
Border-Radius
View CSS
-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 Aug 27, 2012
php: environment dependent config autoloading Yii startup
View index.php
<?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 Aug 30, 2012
Sublime Text 2 - Useful Shortcuts
View gist:3521924

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 Aug 30, 2012
javacript: web page night mode
View night_mode.js
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 Aug 30, 2012
javascript: detect next page
View detect_next.js
/**
* 检测下一页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 Aug 31, 2012
vim: vim config file
View vimrc.local
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设定默认解码
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 Aug 31, 2012
java: Continuous Recognition and Visualization of Pen Strokes and Touch-Screen Gestures
View Gesture.java
/*
* 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 Aug 31, 2012
php: quick sort algorithm implemented in php
View quicksort.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 Sep 11, 2012
php: get client location city based on ip address
View iplocation.php
<?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数据库路径