Archive for 'Geek Stuff'

Running Greasemonkey scripts on Ubiquity

Mozilla Ubiquity is not only a wonderful command engine and launcher. It can also be used to do stuff what Greasemonkey is good at, manipulating page DOM dynamically, by utilizing the “pageLoad_” function hook. To demonstrate this case I’ve quickly migrated the recently popular Twitter search on Google monkey script onto Ubiquity. You can get the Ubiq version of Twitter+Google search from here.

I retained the original DOM building code, but replaced the Ajax call with a JQuery one along with a couple hacks explained below to get it working from Ubiquity.

First, while Greasemonkey has built-in mechanism for filtering page URLs for selective script invocation, you have to do that on your own with Ubiquity. Look at the first few lines in the Ubiq command for the regex job to filter out Google search addresses.

    var href = doc.location.href;
    var q = (/^https?:\/\/(?:www\.)?google\..*\/.*[&?]q=([^&]*)(?:&|$)/(href)||0)[1];

Secondly, before publishing the script, you have to put such a line of comment in the script in order for Ubiquity to consider it an installable command and trigger the install bar at the top of the page. (Kudos to satyr for pointing out this hack)

//function cmd_

In similar ways, most of the Greasemonkey scripts can be migrated to Ubiquity.

twtplus - The missing Twitter command for Ubiquity and Firefox

Earlier this year I spent some time to write the “twtplus” command for Ubiquity, the intriguing Quicksilver-like plugin for Firefox. I’ve been tweaking it intermittently and now I’m gonna put together a little handy reference for it. Twtplus has the following features:

  • Post message to your twitter account (of course)
  • Preview your friends timeline. Click avatar to reply.
  • @ and d message to friends with friends username autocompletion. Notice that “@” is a modifier keyword so you need to leave a space after it to get the friend name autocompletion working.
  • Use “#url” tag to substitute the URL of the currently viewing page
  • Automatically shorten all URLs found in a message using http://is.gd
  • “as” modifier for posting as multiple twitter accounts.

Most of the features are pretty straightforward. Take a look at the following screenshot. Notice the grey hints after the “twtplus” command when you type and you’ll be fine.

twtplus

twtplus

In order to get multi-account posting working, there are a couple things I’d like to mention. First, due to the way the browser works, if you have a logged in session for Twitter, the browser will ALWAYS post your tweet as the currently logged in user, regardless of the one you specifies with the “as” modifier keyword. Thus the solution is to avoid being logged in via the Twitter web interface, or when the stock “twitter” command prompts you a login dailog. If you visit twitter.com and find that you’ve already logged in, log out explicitly.

Secondly, twtplus looks for your stored usernames and passwords for Twitter in your Firefox password manager, for the login authentication to Twitter and provide multiple account autocompletion suggestions. So you need to store your Twitter accounts with Firefox if you haven’t already. This is also a more secure and convenient way than the stock “twitter” command since you don’t need to input your twitter login from time to time.

Now get twtplus from here.

Update: Here’s an awesome screencast from @neo4zion

Ubiquity叽歪命令火力加强版

Ubiquity jiwai命令现在变得更强了。首先,现在提供了强大的电影,音乐,书籍标签功能,可以通过指定名称关键字来自动在消息里扩展出媒体信息,通过和叽歪富媒体功能的结合,可以非常方便的在叽歪个人主页上显示丰富的媒体信息。另外,经过调试多帐号发消息功能基本可以正常使用了。

Click to continue reading “Ubiquity叽歪命令火力加强版”

Ubiquity叽歪命令加强版

Ubiquity刚出来时候写过个最简单的叽歪命令玩,现在写了个加强版的放出,比以前的好用多了,可以从这里安装。
加强版叽歪命令fork自2ii,做了大量修改重构,并且增加了一些有用的功能,除了预览好友时间线外,还能自动用is.gd服务缩短消息里的所有URL,用#url标签替换当前页面地址,支持@回复好友和d私信好友的名字自动完成。

Click to continue reading “Ubiquity叽歪命令加强版”

Ubiquity命令:收藏到Evernote和Friendfeed

Ubiquity太好玩了,又写了几个有用的命令(我为什么要说又呢),可以直接敲键盘来收藏当前选中的内容到Evernote,以及分享到Friendfeed。外加一个,在当前页面上调出Jash,一个Javascript命令行调试工具。从下面的地址就可以安装了。

Click to continue reading “Ubiquity命令:收藏到Evernote和Friendfeed”

code_swarm Python

今天又看到了code_swarm的Python视频,不禁贴出来共赏。外加code_swarm Eclipse作为Bonus。

Click to continue reading “code_swarm Python”

Feedlr公开上线咯

Feedlr是我用Grails做的一个pet project(宠物项目?)现在已经公开上线咯~

Feedlr是一个类似twitterfeed的miniblog mashup。但它除了twitter同时还支持国内的叽歪饭否,并且能让用户浏览所有在feedlr上创建的bot,就像个bot超市,找自己感兴趣的就能直接follow/关注了。

如果你经常用miniblog,特别是国内的叽歪或者饭否用户的话,不妨去feedlr找找看有趣的bot吧。

或者,如果你有自己的博客,希望更多的人能随时随地收到你博客的更新的话,就可以用feedlr把自己的blog广播到miniblog上。现在不用再羡慕英文blog圈流行的twitterfeed了,用feedlr把你的博客直接广播到国内的叽歪和饭否吧~

另外,你也可以把任何你感兴趣别人也可能感兴趣的feed用feedlr建立bot,让大家都能随时随地收到新鲜消息,比如我建立的cnBeta botGoogle新闻 bot,就有很多叽歪的朋友关注着咯。

你还可以访问Feedlr的叽歪留言板,关注和讨论最新的Feedlr功能和用法,还可以给我提意见~我直接就能通过叽歪收到你的留言呢:))

Notes 8在Ubuntu Gutsy下启动崩溃问题和解决

Notes 8在Gutsy下已经运行的不错了,除了用scim不能输入中文。但是今天在一次意外退出以后,Notes每次启动都会提示出错,错误号CLFRJ00010E(毫无意义的出错信息并不是m$专利)。Google以后终于找到这篇文章,经过尝试以后我的解决方法是这样的。

sudo rm ~/lotus/notes/data/~notes.lck
ps -ef | grep lotus

如果看到还有notes进程的话,比如
user 22514 1 0 10:19 ? 00:00:01 /opt/ibm/lotus/notes/taskldr /opt/ibm/lotus/notes/taskldr

pkill -9 taskldr

以上两步就可以让notes重新启动成功了,并不需要清空workspace。

P.S. 2008第一贴,祝各位新年快乐!

Tags: ,

用Launchy提高你的生活品质:直接搜索你想要的任何东西

几天前Launchy 2.0发布了。2.0出现了哪些新功能呢?其实并没有什么惊天动地的新功能,Launchy已经很好的达到了简约而强大的目的了,如果越变越复杂的话其实会违背其本意。2.0主要是改善了界面和易用性,可扩展性。

用了几天Launchy 2.0以后,有一个实实在在非常有用的用法分享给大家:直接从Launchy向常用的网站提交搜索。用法是这样的:

  1. 从Launchy右上角的按钮进入Optionsimage2.png
  2. 在Plugins里选择Weby插件image3.png
  3. 在Weby配置里添加你最常用的网站搜索URL和查询格式。比如淘宝,URL是:http://search1.taobao.com/browse/search_auction.htm,Query是:?q=%s
    其中%s是使用Launchy搜索淘宝的时候输入的字串。
    image4.png
  4. 设好了!使用起来只要Alt+Space召唤出Launchy,然后打taobao+TAB+搜索字串,直接就能打开淘宝搜索结果页面了。再也不用为了搜一点东西摸上网站填表提交了。爽吧!
    image5.png

和大家分享一下我在默认搜索之外添加的常用搜索:

taobao http://search1.taobao.com/browse/search_auction.htm ?q=%s
shooter http://shooter.cn/sub/ ?searchword=%s
nti http://www.newtorrents.info/search/ %s
mininova http://www.mininova.org/search/ ?search=%s
gmail http://mail.google.com/mail/#search/ %s
ciba http://dict.iciba.com/search ?s=%s
flickr http://www.flickr.com/search/ ?q=%s

要添加你自己常用的搜索,只要照常在网页上搜索的时候留意一下搜索结果的URL,或者看看form的代码,就知道怎么设置Launchy了。

接下来,把Firefox search bar里面的search engine和google toolbar上的custom search全都搬到Launchy上来吧!

LinkStation改装攻略备忘 补充

今天拿了台新换的linkstation回来,很快又改会原来的状态了。上次写的备忘有些需要补充的地方。

  1. 这次试验了ls2直接连电脑后,在电脑和ls2的c网段不同的情况下刷机。结果是firmware刷新失败!不过不用怕,firmware刷新失败后ls2会进入工程模式(Engineer Mode, EM)。这时候ip会回到默认的192.168.11.150,firmware刷新工具仍旧能搜索到ls2。把电脑设置到和ls2相同c网段,重新刷一次就行了。
  2. 建议在第一次e2fsck检查完Debian分区,重启进系统之后,执行tune2fs -i 0 -c 0 /dev/hda1,禁止系统启动时自动检查硬盘,从而避免出现检测超时无法开机的麻烦情况。
  3. 快速改机档的默认ip直接修改/mnt/hda/etc/network/interfaces,这样就不用重启进入Debian再接上电脑改了