Skip to content

Instantly share code, notes, and snippets.

@jackysee
jackysee / gist:18906
Created October 23, 2008 03:04
Ubiquity Command to set document.body to a input width, auto align to center
CmdUtils.CreateCommand({
name: "page-width",
author: { name: "Jacky See"},
license: "GPL",
description: "Limit the page width by a given parameter, align it to center",
help: "e.g. page-width 400",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
var template = "Setting page to width ${w} (default is 500)";
var width = 500; //default width
CmdUtils.CreateCommand({
name: "jquerify",
author: { name: "Jacky", email: "jackysee at gmail dot com"},
license: "GPL",
description: "Load jquery library to page (using google's hosting)",
help: "jquery version (default version is 1.2.6)",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
pblock.innerHTML = "Load jquery " + (input.text || "1.2.6");
},
@jackysee
jackysee / x
Created January 22, 2009 03:00
CmdUtils.CreateCommand({
name: "css-insert",
author: { name: "Jacky", email: "jackysee at gmail"},
license: "GPL",
description: "Insert CSS",
help: "css body{line-height:1.5em;}",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
pblock.innerHTML = "Insert CSS rule: " + input.text ;
},
CmdUtils.CreateCommand({
name: "ydict",
author: { name: "Jacky", email: "jackysee at gmail dot com"},
description: "Search HK Yahoo dict",
help: "Select the text or just type as the parameter",
takes: { "word": noun_arb_text },
execute: function(word){
var url = "http://hk.dictionary.yahoo.com/search.html";
var params = Utils.paramsToString({q:"1", s:word.text});
Utils.openUrlInBrowser(url + params);
var mtrStationsValue = { "sheung wan":26,"central":1,"admiralty":2,"wan chai":27,
"causeway bay":28,"tin hau":29,"fortress hill":30,"north point":31,"quarry bay":32,"tai koo":33,
"sai wan ho":34,"shau kei wan":35,"heng fa chuen":36,"chai wan":37,"shek kip mei":7,"kowloon tong":8,
"lok fu":9,"wong tai sin":10,"diamond hill":11,"choi hung":12,"kowloon bay":13,"ngau tau kok":14,
"kwun tong":15,"lam tin":38,"tsim sha tsui":3,"jordan":4,"yau ma tei":5,"mong kok":6,"prince edward":16,
"sham shui po":17,"cheung sha wan":18,"lai chi kok":19,"mei foo":20,"lai king":21,"kwai fong":22,"kwai hing":23,
"tai wo hau":24,"tsuen wan":25,"yau tong":48,"tiu keng leng":49,"tseung kwan o":50,"hang hau":51,"po lam":52,
"hong kong":39,"kowloon":40,"olympic":41,"nam cheong":53,"tsing yi":42,"tung chung":43,"sunny bay":54,
"disneyland resort":55,"east tsim sha tsui":80,"hung hom":64,"mong kok east":65,"kowloon tong":66,"tai wai":67,
"sha tin":68,"fo tan":69,"racecourse":70,"university":71,"tai po market":72,"tai wo":73,"fanling":74,
/**
Convert from Google Reader API's ATOM to RSS2.0
It seems that the Google Reader API's ATOM cannot be read by Wordpress import properly. So Write a script to convert it to a simple RSS2.0 format.
Still many trade off: 1) may not be full feed. 2) may not be full archive 3) Images still on remote server. 4) No comments retrieved.
You need to install groovy http://groovy.codehaus.org/ to run the script
1. Get a copy of your RSS archive from Google Reader e.g. http://www.google.com/reader/atom/feed/http://feeds.feedburner.com/Room2046?r=n&n=1500
/**
This script will crawl the MySinaBlog content to your hardisk as HTML files
It can resolves more than one page of comment.
Setup
1. You need to install groovy (http://groovy.codehaus.org/).
See the setup here (http://groovy.codehaus.org/Tutorial+1+-+Getting+started)
2. You need to install nekoParser to your groovy lib
2.1 download from http://sourceforge.net/projects/nekohtml/
2.2 copy in the zip file lib\xercesImpl.jar, nekohtml.jar to e.g. c:\Documents And Settings\User\.groovy\lib
/*
Add live('change') ability on IE with jQuery 1.3.2
Should use with conditional comment. e.g.
<!--[if IE]>
<script type="text/javascript" src="jquery.live.change.js"></script>
<![endif]-->
*/
(function(){
jQuery.event.special.change = {
filters: {
/*
Simple memoize function for function caching
- use args array as cache key
- Usage:
function fib(n){
return n < 2? n: fib(n-2) + fib(n-1);
}
fib = namespace.memoize(fib);
*/
var namespace = {};
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Calendar</title>
<style>
.calendar{ color: green; border: 1px solid green; width: 300px; padding: 4px 10px;}
.year,.month,.month_c{float: left; width:100px; font-size: 120%}
.month{text-align:center;font-size: 120%}
.month_c{text-align:right;font-size: 120%}