The world is not beautiful

July 20, 2009

Custom FireGesture script to use both wheel gesture(up/down) to switch tab

Filed under: I'm here, Toy box, Software

The default behavior of FireGestrure’s wheel gesture is like this: hold right mouse key down, scroll down mouse wheel one time, then a list of tabs is shown and current tab is selected, one should scroll down one more time to select next tab. the fist scroll down is interpreted as “show the switch tab drop list”, as they do not use both wheel up/down for tab switching.

but when i want to use both wheel up/down to switch between tabs, the default behavior is annoying, what i want is that the cursor should scroll to last/next tab in the list as soon as i scroll the wheel up/down for the first time. the default command can’t meet my requirement, after some researching, my solution is a short piece of custom script:

FireGestures._buildPopup(”FireGestures:AllTabsPopup”, event.type == “DOMMouseScroll”, null);
FireGestures.handleEvent(event);

January 26, 2006

Regular Expression Syntax

From MSDN:

Character Description
\ Marks the next character as a special character, a literal, a backreference, or an octal escape. For example, ‘n’ matches the character “n”. ‘\n’ matches a newline character. The sequence ‘\\’ matches “\” and “\(” matches “(”.
^ Matches the position at the beginning of the input string. If the RegExp object’s Multiline property is set, ^ also matches the position following ‘\n’ or ‘\r’.
$ Matches the position at the end of the input string. If the RegExp object’s Multiline property is set, $ also matches the position preceding ‘\n’ or ‘\r’.
* Matches the preceding character or subexpression zero or more times. For example, zo* matches “z” and “zoo”. * is equivalent to {0,}.
+ Matches the preceding character or subexpression one or more times. For example, ‘zo+’ matches “zo” and “zoo”, but not “z”. + is equivalent to {1,}.
? Matches the preceding character or subexpression zero or one time. For example, “do(es)?” matches the “do” in “do” or “does”. ? is equivalent to {0,1}
{n} n is a nonnegative integer. Matches exactly n times. For example, ‘o{2}’ does not match the ‘o’ in “Bob,” but matches the two o’s in “food”.
{n,} n is a nonnegative integer. Matches at least n times. For example, ‘o{2,}’ does not match the “o” in “Bob” and matches all the o’s in “foooood”. ‘o{1,}’ is equivalent to ‘o+’. ‘o{0,}’ is equivalent to ‘o*’.
{n,m} m and n are nonnegative integers, where n <= m. Matches at least n and at most m times. For example, “o{1,3}” matches the first three o’s in “fooooood”. ‘o{0,1}’ is equivalent to ‘o?’. Note that you cannot put a space between the comma and the numbers.
? When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible. For example, in the string “oooo”, ‘o+?’ matches a single “o”, while ‘o+’ matches all ‘o’s.
. Matches any single character except “\n”. To match any character including the ‘\n’, use a pattern such as ‘[\s\S].
(pattern) Matches pattern and captures the match. The captured match can be retrieved from the resulting Matches collection, using the SubMatches collection in VBScript or the $0$9 properties in JScript. To match parentheses characters ( ), use ‘\(’ or ‘\)’.
(?:pattern) Matches pattern but does not capture the match, that is, it is a non-capturing match that is not stored for possible later use. This is useful for combining parts of a pattern with the “or” character (|). For example, ‘industr(?:y|ies) is a more economical expression than ‘industry|industries’.
(?=pattern) Positive lookahead matches the search string at any point where a string matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example ‘Windows (?=95|98|NT|2000)’ matches “Windows” in “Windows 2000″ but not “Windows” in “Windows 3.1″. Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.
(?!pattern) Negative lookahead matches the search string at any point where a string not matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example ‘Windows (?!95|98|NT|2000)’ matches “Windows” in “Windows 3.1″ but does not match “Windows” in “Windows 2000″. Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.
x|y Matches either x or y. For example, ‘z|food’ matches “z” or “food”. ‘(z|f)ood’ matches “zood” or “food”.
[xyz] A character set. Matches any one of the enclosed characters. For example, ‘[abc]’ matches the ‘a’ in “plain”.
[^xyz] A negative character set. Matches any character not enclosed. For example, ‘[^abc]’ matches the ‘p’ in “plain”.
[a-z] A range of characters. Matches any character in the specified range. For example, ‘[a-z]’ matches any lowercase alphabetic character in the range ‘a’ through ‘z’.
[^a-z] A negative range characters. Matches any character not in the specified range. For example, ‘[^a-z]’ matches any character not in the range ‘a’ through ‘z’.
\b Matches a word boundary, that is, the position between a word and a space. For example, ‘er\b’ matches the ‘er’ in “never” but not the ‘er’ in “verb”.
\B Matches a nonword boundary. ‘er\B’ matches the ‘er’ in “verb” but not the ‘er’ in “never”.
\cx Matches the control character indicated by x. For example, \cM matches a Control-M or carriage return character. The value of x must be in the range of A-Z or a-z. If not, c is assumed to be a literal ‘c’ character.
\d Matches a digit character. Equivalent to [0-9].
\D Matches a nondigit character. Equivalent to [^0-9].
\f Matches a form-feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any white space character including space, tab, form-feed, and so on. Equivalent to [ \f\n\r\t\v].
\S Matches any non-white space character. Equivalent to [^ \f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.
\w Matches any word character including underscore. Equivalent to ‘[A-Za-z0-9_]’.
\W Matches any nonword character. Equivalent to ‘[^A-Za-z0-9_]’.
\xn Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, ‘\x41′ matches “A”. ‘\x041′ is equivalent to ‘\x04′ & “1″. Allows ASCII codes to be used in regular expressions.
\num Matches num, where num is a positive integer. A reference back to captured matches. For example, ‘(.)\1′ matches two consecutive identical characters.
\n Identifies either an octal escape value or a backreference. If \n is preceded by at least n captured subexpressions, n is a backreference. Otherwise, n is an octal escape value if n is an octal digit (0-7).
\nm Identifies either an octal escape value or a backreference. If \nm is preceded by at least nm captured subexpressions, nm is a backreference. If \nm is preceded by at least n captures, n is a backreference followed by literal m. If neither of the preceding conditions exist, \nm matches octal escape value nm when n and m are octal digits (0-7).
\nml Matches octal escape value nml when n is an octal digit (0-3) and m and l are octal digits (0-7).
\un Matches n, where n is a Unicode character expressed as four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©).

September 22, 2005

再试试pyjj…

Filed under: I'm here, Toy box

找了个便携版,感觉还好,用段时间看看~

主要是可以shift切换中英文了就比较方便了,而且gbk、繁体应有尽有,还能笔划输入,最bt的是以前一直头疼的符号输入也很方便…比如说省略号(……),只要输入slh就可以了…词频调整也很好,不像紫光那样神经过敏,也不像M$PY那样健忘的要死…

不过ms便携版的词库小的可怜,还要多用用才好。

June 14, 2005

正则表达式语法

在别处看到的,就贴上来,以后要用也好找~

正则表达式是一种文本模式,包括普通字符(例如,a 到 z 之间的字母)和特殊字符(称为“元字符”)。模式描述在搜索文本时要匹配的一个或多个字符串。

下面是正则表达式的一些示例:

表达式 匹配
/^\s*$/ 匹配空行。
/\d{2}-\d{5}/ 验证由两位数字、一个连字符再加 5 位数字组成的 ID 号。
/<\s*(\S+)(\s[^>]*)?>[\s\S]*<\s*\/\1\s*>/ 匹配 HTML 标记。

下表包含了元字符的完整列表以及它们在正则表达式上下文中的行为:

字符 说明
\ 将下一字符标记为特殊字符、文本、反向引用或八进制转义符。例如,“n”匹配字符“n”。“\n”匹配换行符。序列“\\”匹配“\”,“\(”匹配“(”。
^ 匹配输入字符串开始的位置。如果设置了 RegExp 对象的 Multiline 属性,^ 还会与“\n”或“\r”之后的位置匹配。
$ 匹配输入字符串结尾的位置。如果设置了 RegExp 对象的 Multiline 属性,$ 还会与“\n”或“\r”之前的位置匹配。
* 零次或多次匹配前面的字符或子表达式。例如,zo* 匹配“z”和“zoo”。* 等效于 {0,}。
+ 一次或多次匹配前面的字符或子表达式。例如,“zo+”与“zo”和“zoo”匹配,但与“z”不匹配。+ 等效于 {1,}。
? 零次或一次匹配前面的字符或子表达式。例如,“do(es)?”匹配“do”或“does”中的“do”。? 等效于 {0,1}。
{n} n 是非负整数。正好匹配 n 次。例如,“o{2}”与“Bob”中的“o”不匹配,但与“food”中的两个“o”匹配。
{n,} n 是非负整数。至少匹配 n 次。例如,“o{2,}”不匹配“Bob”中的“o”,而匹配“foooood”中的所有 o。’o{1,}’ 等效于 ‘o+’。’o{0,}’ 等效于 ‘o*’。
{n,m} mn 是非负整数,其中 n <= m。至少匹配 n 次,至多匹配 m 次。例如,“o{1,3}”匹配“fooooood”中的头三个 o。’o{0,1}’ 等效于 ‘o?’。注意:您不能将空格插入逗号和数字之间。
? 当此字符紧随任何其他限定符(*、+、?、{n}、{n,}、{n,m})之后时,匹配模式是“非贪心的”。“非贪心的”模式匹配搜索到的、尽可能短的字符串,而默认的“贪心的”模式匹配搜索到的、尽可能长的字符串。例如,在字符串“oooo”中,“o+?”只匹配单个“o”,而“o+”匹配所有“o”。
. 匹配除“\n”之外的任何单个字符。若要匹配包括“\n”在内的任意字符,请使用诸如“[\s\S]”之类的模式。
(pattern) 匹配 pattern 并捕获该匹配的子表达式。可以使用 $0$9 属性从结果“匹配”集合中检索捕获的匹配。若要匹配括号字符 ( ),请使用“\(”或者“\)”。
(?:pattern) 匹配 pattern 但不捕获该匹配的子表达式,即它是一个非捕获匹配,不存储供以后使用的匹配。这对于用“或”字符 (|) 组合模式部件的情况很有用。例如,与“industry|industries”相比,“industr(?:y| ies)”是一个更加经济的表达式。
(?=pattern) 执行正向预测先行搜索的子表达式,该表达式匹配处于匹配 pattern 的字符串的起始点的字符串。它是一个非捕获匹配,即不能捕获供以后使用的匹配。例如,“Windows (?=95| 98| NT| 2000)”与“Windows 2000”中的“Windows”匹配,但不与“Windows 3.1”中的“Windows”匹配。预测先行不占用字符,即发生匹配后,下一匹配的搜索紧随上一匹配之后,而不是在组成预测先行的字符后。
(?!pattern) 执行反向预测先行搜索的子表达式,该表达式匹配不处于匹配 pattern 的字符串的起始点的搜索字符串。它是一个非捕获匹配,即不能捕获供以后使用的匹配。例如,“Windows (?!95| 98| NT| 2000)”与“Windows 3.1”中的“Windows”匹配,但不与“Windows 2000”中的“Windows”匹配。预测先行不占用字符,即发生匹配后,下一匹配的搜索紧随上一匹配之后,而不是在组成预测先行的字符后。
x| y xy 匹配。例如,“z| food”与“z”或“food”匹配。“(z| f)ood”与“zood”或“food”匹配。
[xyz] 字符集。匹配包含的任一字符。例如,“[abc]”匹配“plain”中的“a”。
[^xyz] 反向字符集。匹配未包含的任何字符。例如,“[^abc]”匹配“plain”中的“p”。
[a-z] 字符范围。匹配指定范围内的任何字符。例如,“[a-z]”匹配“a”到“z”范围内的任何小写字母。
[^a-z] 反向范围字符。匹配不在指定的范围内的任何字符。例如,“[^a-z]”匹配任何不在“a”到“z”范围内的任何字符。
\b 匹配一个字边界,即字与空格间的位置。例如,“er\b”匹配“never”中的“er”,但不匹配“verb”中的“er”。
\B 非字边界匹配。“er\B”匹配“verb”中的“er”,但不匹配“never”中的“er”。
\cx 匹配由 x 指示的控制字符。例如,\cM 匹配一个 Control-M 或回车符。x 的值必须在 A-Z 或 a-z 之间。如果不是这样,则假定 c 就是“c”字符本身。
\d 数字字符匹配。等效于 [0-9]。
\D 非数字字符匹配。等效于 [^0-9]。
\f 换页符匹配。等效于 \x0c 和 \cL。
\n 换行符匹配。等效于 \x0a 和 \cJ。
\r 匹配一个回车符。等效于 \x0d 和 \cM。
\s 匹配任何空白字符,包括空格、制表符、换页符等。与 [ \f\n\r\t\v] 等效。
\S 匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。
\t 制表符匹配。与 \x09 和 \cI 等效。
\v 垂直制表符匹配。与 \x0b 和 \cK 等效。
\w 匹配任何字类字符,包括下划线。与“[A-Za-z0-9_]”等效。
\W 任何非字字符匹配。与“[^A-Za-z0-9_]”等效。
\xn 匹配 n,此处的 n 是一个十六进制转义码。十六进制转义码必须正好是两位数长。例如,“\x41”匹配“A”。“\x041”与“\x04”&“1”等效。允许在正则表达式中使用 ASCII 代码。
\num 匹配 num,此处的 num 是一个正整数。到捕获匹配的反向引用。例如,“(.)\1”匹配两个连续的相同字符。
\n 标识一个八进制转义码或反向引用。如果 \n 前面至少有 n 个捕获子表达式,那么 n 是反向引用。否则,如果 n 是八进制数 (0-7),那么 n 是八进制转义码。
\nm 标识一个八进制转义码或反向引用。如果 \nm 前面至少有 nm 个捕获子表达式,那么 nm 是反向引用。如果 \nm 前面至少有 n 个捕获,那么 n 是反向引用,后面跟 m。如果前面的条件均不存在,那么当 n m 是八进制数 (0-7) 时,\nm 匹配八进制转义码 nm
\nml n 是八进制数 (0-3),ml 是八进制数 (0-7) 时,匹配八进制转义码 nml
\un 匹配 n,其中 n 是以四位十六进制数表示的 Unicode 字符。例如,\u00A9 匹配版权符号 (?)。

May 6, 2005

orz…eMule的preferences.dat文件里居然有窗口定位信息…

Filed under: Toy box, Software

今天升级eMule的时候偶然和半年前的一个备份比对了一下preferences.dat的md5,发现居然不一样,开始还以为是文件损坏导致userhash变化过了,尝试把以前的文件覆盖过去,发现userhash是一样的,百思不得其解,Shane提示我说可能里面还有其他信息,我就跑去看代码,结果发现……居然是窗口定位信息 = =!!,我就差吐血了,orz…

估计是从最早版本的eMule遗留下来的东西……

April 25, 2005

推荐个贴图空间~

Filed under: Toy box

http://www.picgoo.com
速度不错的说,支持的格式也很多(jpeg, gif, png, bmp, swf, tif, xls, doc),界面也很简洁,不过没有图片分类,可能图片多了会比较乱的说~

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com