Skip to content

Instantly share code, notes, and snippets.

@adison
adison / m01_changePageByArrow.js
Created November 30, 2012 20:36
mobile 01 方向鍵換頁
/*
請搭配以下環境參數和 Personalized Web 參數使用
環境: chrome,搭配 extension "Personalized Web" ( https://chrome.google.com/webstore/detail/personalized-web/plcnnpdmhobdfbponjpedobekiogmbco )
Personalized Web 設定
Match URLs: ^http://www.mobile01.com/topicdetail.php.*
Add JavaScript: 加入以下內容
*/
@adison
adison / googleSearchChangePageWithArrow.js
Created December 1, 2012 00:57
google search change page with arrow kets(left/right)
/*
在 Google 頁面使用方向鍵切換上一頁、下一頁
Change result page with Arrow keys(left/right) on google search pages.
請搭配以下環境參數和 Personalized Web 參數使用
env: chrome with extension "Personalized Web" ( https://chrome.google.com/webstore/detail/personalized-web/plcnnpdmhobdfbponjpedobekiogmbco )
setting of Personalized Web:
Match URLs: ^https://www.google.com/search.*
Add JavaScript: add the following JS
*/
@adison
adison / gist:6119198
Created July 31, 2013 04:08
檢查瀏覽器版本
//檢查版本
function checkBrowserVersion(){
var isShowBrowserNotice = false;
var N= navigator.appName, ua= navigator.userAgent, tem;
var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M= M? [M[1], M[2]]: [N, navigator.appVersion, '-?'];
var version = M[1].substring(0, M[1].indexOf("."));
//chrome < 15, firefox <2, ie <8 出现提示
if((M[0]== "Chrome" && 15 > parseInt(version)) || (M[0]== "Firefox" && 2 > parseInt(version)) || (M[0]== "MSIE" && 8 > parseInt(version)))
@adison
adison / gist:6190247
Created August 9, 2013 00:43
generate json, json like data by Java
/*
this code tis purposed to make data for AngularJS from data kind of
province district
data-A1 data-B1
data-A1 data-B2
data-A1 data-B3
to
[province: "data-A1", districts: [
{distict: "data-B1"},
{distict: "data-B2"},
@adison
adison / gist:7543152
Last active December 28, 2015 18:29
XML for keyremap4macbook, use for japanese keypad layout 1. chane kana key to option_R (把右邊的kana按鈕當做 option) 2. Use the right option and right shift to select the next input source(用左邊的英數按鈕切換輸入法)
<?xml version="1.0"?>
<root>
<item>
<name>用左邊的英數按鈕切換輸入法 - Switch Input Source by left en</name>
<appendix>Use the right option and right shift to select the next input source(用左邊的英數按鈕切換輸入法)</appendix>
<identifier>private.switch_next_input_source_by_jiseiuu</identifier>
<autogen>--KeyToKey-- KeyCode::JIS_EISUU, KeyCode::SPACE, ModifierFlag::COMMAND_L</autogen>
</item>
<item>
<name>把右邊的kana按鈕當做 option - change kana to option_r</name>
@adison
adison / gist:9540842
Created March 14, 2014 01:58
全螢幕網頁,圖片置中
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, maximum=1.0, minimum-scale=1.0">
<!-- width:可設定數值,或者指定為 device-width
height:可設定數值,或者指定為 device-height
initial-scale:第一次進入頁面的初始比例
minimum-scale:允許縮小最小比例
maximum-scale:允許放大最大比例
@adison
adison / disable-lock.html
Created April 13, 2014 15:40
disable webpage lock
<!--
disable web page locks,
for chrome, get extesion: https://chrome.google.com/webstore/detail/personalized-web/plcnnpdmhobdfbponjpedobekiogmbco
and add code below
-->
<style type="text/css">
* {
-moz-user-select: text !important;
-webkit-user-select:auto !important;
@adison
adison / SynthesizeSingleton.h
Last active August 29, 2015 14:05
Singleton Macro, with
/*
no need to copy this section.
ussge:
in CustomClass.h
+(instancetype)sharedManager;
in CustomClss.m
@implementation CustomClass
...
SYNTHESIZE_SINGLETON_FOR_CLASS(CustomClass)
-- northwind for postgreSQl.. tell me if it works :p
--
-- PostgreSQL Northwind Database v1.0 from Ramiro Estigarribia Canese
-- you may contact him at email [email protected]
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
@adison
adison / commonMacro.h
Last active August 29, 2015 14:05
iOS dev useful macro
// 固定用的一些 macro 方法,不牵涉 app 变数定义
// 取角度, convert radius to angle
#define degreesToRadian(x) (M_PI * (x) / 180.0)
//取螢幕尺寸, screen resolution
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
//判斷是否 iPhone 5, this may need change after iphone6..