2009年4月22日星期三

Bookmarklet of URL shortener

I created a bookmarklet for the url shortener and a testing page for it.

Drag the link below to the bookmark bar.



The main motivation behind this small tool is to help me writing tweets. Twitter is smart that it can convert long URLs to short ones using tinyurl, but that only happens when the whole text is shorter than 140 characters, otherwise the "update" button is disabled and you can not go further. So I want this tool which can be accessed quickly in the twitter's page.

Create a small gadget "URL Shortener"

I have to say that there exists several gadgets that do the same thing. Frankly speaking, I don't try them, I just keep telling myself that what I made is the best.

In my gadget, you can choose the URL shortening service to use. Currently, you can choose tinyurl or bit.ly. I used GAE to implement the background service, i.e. the scraping thing.

You can try in on my blog, it's on the right side. Or add it to iGoogle via the link below.


A screenshot:

And the real thing:



2009年4月7日星期二

Paste in Cygwin window

I want to paste some text from Windows to Cygwin's bash window, but I don't want to enable the quick edit mode of the command window, because it may lock the command window.

So I used the context menu to paste the text. Just click the cygwin icon in the top left of the window, you can see the menu. See the screen-shot below.


Get viewport size using JavaScript

The main idea of the JavaScript is stolen from here. I just rewrote the code a little to make common path faster.

function getViewportSize() {
var w = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || document.getElementsByTagName('body')[0].clientWidth;
var h = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || document.getElementsByTagName('body')[0].clientHeight;
return {width : w, height : h};
}





Add JavaScript code to posts on Blogger


I tried to add some JavaScript code in my post, but it seemed to be harder than I thought. I googled a lot of pages about it and found pages like [1], [2] and [3]. For JavaScript code that not run immediately after the page is loaded, using plan <script> tag is ok. But my JavaScript code needs to be executed after the page is loaded, I tried the approach using <code>, it didn't work. Then I decided to use window.setTimeout to hack that. It works.


See the script below, the content of "viewport" is modified by script after the page is loaded. Note, the script should be only one line to avoid <br> tags inserted by Blogger.

<script type="text/javascript">function fn() {var ele = document.getElementById("test");if (ele) {ele.innerHTML = "Content set by script ";window.clearTimeout(arguments.callee._timeout);}else {arguments.callee._timeout = window.setTimeout(arguments.callee, 500);}}fn();</script>
<span id="test"></span>



The script in action:


2009年4月3日星期五

Yahoo! Search BOSS

Yahoo! is continuing to open up its search platform. It has SearchMonkey, and now the BOSS. BOSS means "Build your Own Search Service". It's free now but will have a fee structure in the near feature. What interests me is the mashup framework, a Python library to manipulate data.

2009年4月2日星期四

Apache's Ftp Server

Maybe I'm out of date now, but I just found Apache's ftp server yesterday. I've tried many ftp servers, such as Serv-U, Cerberus, and several other home-made software. All these software I used are quite good. But I have to say Apache's ftp server is what I need as a programmer. The GUI is fancy and great, but my favorite is still XML configuration.

Just download the package, unzip it and run the bat script. It's simple but enough. Remember, YAGNI.

Technology changes life