Monday, January 25, 2010

Add Google Translate Tool To Your Webpage Or Blog


1. Google Translate Element
Go to http://www.google.com/webelements/translate/. With a little configuration, you can get a snippet of javascript code to put on your web page or blog. By choosing "Display" as "Always", you get a menu of "Select Language"; by choosing "Display" as "Automatic", you can invoke the Google Translate automatically.

If you just want to specify a subset of destination languages, you can go to http://translate.google.com/translate_tools to setup the code. After you select some specific languages, a parameter "includedLanguages" is added to the Google TranslateElement.

2. Play with Google Translate URL
If you just want to translate your web page or blog into one specific language, there is no point in adding a menu. You can just add a button. For example, if you want to add a button to let the readers translate your web page from English to French, you can add this snippet of code:
<form action="http://www.google.com/translate" onsubmit="this.u.value=window.location.href" method="GET">
<input value="en" name="sl" type="hidden"/>
<input value="fr" name="tl" type="hidden"/>
<input value="" name="u" type="hidden"/>
<input value="FRANÇAIS" type="submit"/>
</form>

If you are using Blogger.com, you can add a Page Element of "HTML/JavaScript" with the code above and you get the Google Translate tool on your blog. It is very convenient.

Wednesday, January 13, 2010

Firefox/Thunderbird Extension: Autohide Tabbar



Overview
This extension auto-hides your Firefox/Thunderbird's tab bar. It can also relocate the tab bar to the bottom of the browser window.

It supports Thunderbird since version 2.0.

New Feature
In version 2.6, a hot key is added to switch the tab bar on/off quickly. By default, it is disabled. To enable it, open the Options dialog and check option "Double-press Ctrl key to show/hide Tabbar". After that, you can press the Ctrl key twice to hide/show the tab bar.

In version 2.6.1, another hot key Alt is added. Those who do not want to use Ctrl as the hot key can use Alt instead. Enable it in the Options dialog.

Features
After you install the extension and restart Firefox/Thunderbird, the tab bar is hidden automatically. After the tab bar is hidden, a tiny plain bar would be placed at the tab bar's old position, e.g. the edge of the content panel. By moving the mouse to the plain bar, you can make the tab bar shown again.

Right click on the tab bar, you can see a menu item of Autohide Tabbar. Use it to toggle the feature on or off. It will only make the change on the current browser window and any new browser window you will open. To turn the feature on or off for all currently opened windows, use the next method.


You can also toggle this feature by the extension's Options dialog, which is accessed from the menu Tools|Add-ons|Extensions. Select our extension Autohide Tabbar and click the button Options/Preferences. In the Options dialog, toggle the checkbox of Enable Autohide Tabbar.


When you are toggling the tab bar on and off with the mouse, the web page in the content panel would looks jumping up and down because the content panel is being resized against the top edge. Some people may find that annoying. An option was added in version 1.1 to allow you relocate the tab bar to the bottom of the content panel so that the web page would not look jumping. To do that, open the Options dialog via the menu Tools|Add-ons|Extensions|Autohide Tabbar|Options(or Preferences), and toggle the checkbox of Put Tabbar At Bottom. The new setting will take effect after the next time you restart Firefox/Thunderbird.


Installation
Download/install the extension from:
Firefox: https://addons.mozilla.org/en-US/firefox/addon/59267
Thunderbird: https://addons.mozilla.org/en-US/thunderbird/addon/59267

As always, after the installation, you need to restart Firefox/Thunderbird.

Options
The Options dialog can be opened from the menu Tools|Add-ons|Extensions|Autohide Tabbar|Options(or Preferences). Here are the options you can change:


- Enable Autohide Tabbar: if it is checked, the extension is enabled. By default, it is checked.

- Put Tabbar At Bottom: if it is checked, the tab bar is placed at the bottom of the browser window -- above the status bar. After you change this setting, you need to restart Firefox/Thunderbird. By default, it is not checked.

- Delay hiding tabbar: how long in milliseconds to delay hiding the tabbar when the mouse moves away.

- Delay showing tabbar: how long in milliseconds to delay showing the tabbar when the mouse moves into the tabbar area.

- Double-press Ctrl key to show/hide tabbar: use the Ctrl key as the hot key to show/hide tabbar.

- Double-press Alt key to show/hide tabbar: use the Alt key as the hot key to show/hide tabbar.


Notes & Tips
This extension respects Firefox's own Tabs Auto-hide option -- which auto-hide the tab bar when there is only one tab. So if you have only one open tab, no matter where you point your mouse, the tab bar will not be shown. To disable Firefox's own Tabs Auto-hide, open Firefox's Options dialog via menu Tools|Options (or Edit|Preferences in Linux), and click icon Tabs, then check Always show the tab bar. It is recommended that you should do that.

If you place the tab bar at the bottom, you may find it takes more effort when you use the '+' button on the tab bar to open a new tab and then type in the address bar. You may consider add a New Tab button to the menu bar so that you do not have to move the mouse all the way across the browser. To do that, right click on the menu bar and select Customize..., and drag the New Tab icon to the menu bar. You can, of course, always use the shortcut Ctrl-T to open a new tab.

This extension works with mouse. If you use only the keyboard, do not install it.

Sometimes when the mouse quickly cross the hidden tar bar, the tar bar will be shown but not be hidden again. That is because our extension can only receive the mouseover event of the tiny plain bar but the mouseout event of the just-shown tar bar may be lost. If that happens, just move your mouse a little bit on the web page to trigger the hiding of the tar bar.

When you open a new tab, the tabbar is not shown. That gives you better privacy. If the new tab is not shown (e.g. when you open it by middle-click a link), you can switch to the new tab by using shotcut Ctrl-PgDn. You can also use other shortcuts to quickly switch tabs, e.g. Ctrl-1 to the first tab.

Install another extension Packed Menu together and you would get a neater interface.

---
If you like this extension, please recommend it to your friends.

Sunday, January 10, 2010

Google Chrome Extension: Take A Break


Addicted to the Web? Don't compromise your health! Continuously staring at the computer can cause headaches, blurred vision, neck pain, fatigue, dry eyes. Take A Break extension tries to help you avoid or reduce these problems. It reminds you when to take a break while you are surfing the Web.

Features
- A little icon on the tool bar will be flashing every 15 minutes to remind you a short break. You should sit back and close your eyes, or look outside the window for a while.

- A pop-up dialog will remind you a big break every hour. You should stand up, get a cup of coffee, do some stretching, or go freshen up.

- You can adjust the timers according to your own needs.

Installation
Download it here: https://chrome.google.com/extensions/detail/kfcgkgmiedhpoalhpmalhjjcnhpkapgl

You will need to restart the Chrome browser after the installation.

After the installation, you will see an icon of a green clock on your tool bar.




How does it work
- The clock icon on the tool bar will be flashing in red and yellow every 15 minutes to remind you a short break.
-- Take A Break extension is on.
-- Icon is flashing and reminding you to take a short break.

- A pop-up dialog will remind you a big break every hour. The pop-up window will be automatically closed after 5 minutes. You can click on the "Take A Break" text to close it, too. Clicking on the URL will bring you to more Chrome extensions I made.




- A click on the clock icon will switch off and on its function. If the function is turned off, the icon is in gray.
-- Take A Break extension is off.

- Right-click the icon and you can select to open the Options dialog. Here you can adjust the timers to meet your own needs. See the next section for the meanings of the options.

- Move the mouse over the icon and you can see when the next break will come.

- Of course, you can also open the Options dialog through the Extensions page.

Options setting
- Enable Flashing: enable/disable the feature of icon flashing. If it is not checked, the following two timers of Flashing Interval and Flashing Duration are ignored.

- Flashing Interval: the time between two flashing. The default value is 15 minutes.

- Flashing Duration: the duration of the flashing. The default value is 30 seconds.


- Enable Pop-up Reminder: enable/disable the feature of pop-up reminding. If it is not checked, the following two timers of Rest Interval and Rest Duration are ignored.

- Rest Interval: the time between two pop-up reminding. The default value is 60 minutes.

- Rest Duration: after this long, the pop-up window will be closed automatically. The default value is 5 minutes.

- No reminding if idle for XXX min: if checked, you can inform the extension that XXX minutes of no mouse movement means you are not browsing. So that the extension would temporary stop when you had left your desk. The default value is 10 minutes.

Limitations
This extension uses content script to capture the movement of your mouse and key strokes. So it has the limitations due to the use of content scripts.

---
If you think this extension is helpful, please share it with your friends.

Tuesday, January 5, 2010

Google Chrome: content script limitations make my extension look bad


After I published my Google Chrome extension Boss Key and Button, some positive feedbacks were received in the beginning. But later on, I kept receiving comments saying that the the extension was not working. That puzzled me for quite some time because I had developed it in a quite early version of Google Chrome (the dev channel) and tested it on both Windows and Linux successfully.

Then I realized that it might be the limitations of the content scripts that confuse the user. Because the background page could not capture the key strokes or the mouse clicks, I had to use a content script to add event listeners to the key and mouse events. What pages a content script could run in was defined in the manifest.json file with a matching pattern. Unfortunately, the matches parameter did not have a pattern of everything. I.e. You could not add a pattern of *://*/*. So a content script could only works on pages of http://, https://, ftp:// and file://. When a user opened a new tab in Chrome, the new tab had a default URI of chrome://newtab/. A content script would not run in it. In another word, my extension could not work when a user pressed the Boss Key and Button on that page.

The second reason could be that a user tried to use the extension when he was browsing the Google Chrome extensions gallery. For some reasons I don't know, content scripts listed in manifest.json would not run in the pages on that site. Users tended to try a extension as soon as it was installed so it was highly possible that they installed my Boss Key and Button extension, pressed the key or button and nothing happened because they were still on the Google Chrome extensions site. Then they got frustrated and removed the extension right away and missed the chance to try it on other pages. This might be the reason why I received positive feedbacks when I published version 1.0 on another site and got negative ones when the new version was published on Google Chrome extensions gallery.

The third reason could be that a content script only ran when the page was being loaded. Supposed a user had opened several pages, when he installed a new extension, the content scripts would not run in those pages. He needed to reload those pages to make the content script work on them, or just restart the Chrome browser. But an innocent user would not know that, he would assume the extension was bad instead and uninstall it immediately.

I have not found a way to solve the problem caused by the first reason. For the second and third reasons, we could use a trick of explicitly executing the content script by calling function chrome.tabs.executeScript(). That was what I did in the new version of Boss Key and Button extension. However, sometimes you may not want the content script being executed multiple times on a page, then you need some kind of flag to mark the executing of the content script.

I hope this blog can help a little if you are using content scripts in your extension.

Monday, January 4, 2010

Linux: secure login without entering password (Part 2)


If you have supplied a passphrase when you generated your pair of private and public keys (see Part 1 for how to generate the keys), you would need to enter the passphrase each time you ssh login to the remote machine. If you think that is painful, you need the program ssh-agent. It can hold the private key and help to authenticate without asking for the passphrase every time.

Case 1
If you are using a GUI desktop, ssh-agent is usually started up for you. You just need to run
        ssh-add
to add your private key to it. ssh-add would ask you to input the passphrase for your private key. You just need to input the passphrase once here. After that, you can ssh to the remote machine without inputting the passphrase.

If you get an error message from running ssh-add:
        Could not open a connection to your authentication agent.
you have to start ssh-agent manually as in Case 2 below.

Case 2
If you are using a console, you need to manually start ssh-agent. If you are using bash/ksh/sh, run
        eval `ssh-agent -s`
or if you are using csh, run
        eval `ssh-agent -c`
Please note that you should use backquote(`) in the command, not a single quotation mark(').


Then you can run ssh-add on the same terminal to add your private key. On this terminal, you can then ssh to the remote machine without entering the passphrase.

When you run ssh on another terminal, you would still be asked for the passphrase. That is because environmental variables SSH_AUTH_SOCK and SSH_AGENT_PID were set on that terminal when we started ssh-agent, and any other terminals do not know these environmental variables. However, any new terminals opened from the same terminal which we started ssh-agent will inherit the environmental variables, so we could ssh from them to the remote machine without entering the passphrase.

Sunday, January 3, 2010

Chrome Extensions: Table Of Contents


Boss Key and Button
You can press the F12 key or both the right button of your mouse to hide all your browser windows.

Secure Or Not
It shows whether the links on a webpage are https links or http.

Take A Break
By reminding you when to take a break while surfing the Web, it tries to help you avoid excessive web browsing and keep healthy.

Support
 
Get This <