PawEng

Software and websites for getting things done

Skip to: Content | Sidebar | Footer


Subscribe via Email or RSS Feed

Ubiquity: Supercharge Your Firefox with a Command Line

27 August, 2008 (7:43 pm) | Firefox, Linux, Mac, Windows

I found a story on CyberNet News about an add-on for Firefox that really got my attention. The add-on is Ubiquity, and it gives you an instant command line interface to the web. I have earlier shared my love for command lines so I was very excited about Ubiquity. After installing it, I was not disappointed. Even though Ubiquity is only in version 0.1, it still rocks.

Once you install Ubiquity, you activate the new command line by pressing CTRL + Space (Option + Space on Mac). The command line pops up over your current web page. You can use the built-in commands to search the web, translate text, look up the weather, perform a calculation, send an email, find an address on a map, etc. The results are shown in the pop-up without you having to leave your current page.

A really cool feature is that you can select text, and Ubiquity will transform the text on your web page by performing the calculation or translating the text — it all happens in-place. When you look up a location on the map, you can ask Ubiquity to insert a link to the map. This is very handy when composing emails using a web-based service.

According to the Ubiquity website, the overall goals of Ubiquity are to explore how best to:

  • Empower users to control the web browser with language-based instructions. (With search, users type what they want to find. With Ubiquity, they type what they want to do.)
  • Enable on-demand, user-generated mashups with existing open Web APIs. (In other words, allowing everyone–not just Web developers–to remix the Web so it fits their needs, no matter what page they are on, or what they are doing.)
  • Use Trust networks and social constructs to balance security with ease of extensibility.
  • Extend the browser functionality easily.

Those are pretty loft goals, but after trying out Ubiquity, I think they are on to something.

Read more about Ubiquity at Mozilla Labs.

EASEUS Disk Cloning

19 August, 2008 (9:56 pm) | Linux, Mac, Windows

EASEUS Disk Copy 2.0 is a freeware program for cloning a hard disk. It makes a sector-by-sector copy of your hard disk ensuring the copy is 100% identical to the original. It is useful for upgrading your hard disk to a new larger drive.

Disk Copy 2.0 comes as a zipped ISO disk image. Burn the ISO file to a CD, boot from the CD, and you are ready to clone a disk. Because it runs off a bootable CD, it works with any operating system. Disk Copy 2.0 supports IDE, SATAI, SATAII, SCSI, Firewire (IEEE1394) and USB drives.

See EASEUS Disk Copy (via Lifehacker).

Executor Application Launcher

18 August, 2008 (5:20 pm) | Windows

Lifehacker has a story about Executor. It is a full-featured application launcher for Windows. And it is freeware.

Read more about Executor at Lifehacker. They have some nice screen shots and descriptions of what Executor can do for you. It looks like Executor is able to give the other application launchers a run for the money.

While you are visiting Lifehacker, you should check out their list of Best Application Launchers.

Unix Command Line Calculator

15 August, 2008 (6:29 pm) | Linux, Shell

I spend a lot of time on a Linux / Unix command line. Often I need to do a quick calculation. I don’t want to hunt around for a fancy calculator program. I want something that works right from the command line.

The bc program is a command line calculator for Linux / Unix. It is an arbitrary precision calculator, and it can even be programmed in a simple language. Read the man page for a complete list of what it can do.

Now, most of the time I just need a simple calculation done. For this purpose I have written a small program called ‘c’ (for calculate):

#!/usr/local/bin/tcsh -f
echo “$*” | bc -l

Yes, it is just two lines. You could also define it as an alias in tcsh:

alias c ‘echo \!* | bc -l’

Or as a function in bash:

function c() { echo “$*” | bc -l; }

Now, to do a simple calculation on the command line, you just write:

c “1+2*3″

And you get the result 7.

It will also allow you to do more advanced math. For example, “s” for sine, “c” for cosine, and “e” for the exponential function, and “l” for the natual logarithm:

c “e(5)”
c “s(0)”
c “c(3.1415)”
c “l(e(5))”

I believe the bc program is part of Cygwin (the Linux / Unix environment for Microsoft Windows), so you should be able to get it to run on your Windows computer as well.

Crucial Memory Upgrade

14 August, 2008 (8:53 pm) | Web

If you have ever tried to upgrade your computer’s memory, you know how many different types of memory chips there are and how difficult it can be to find the right one. The company Crucial can help you out. On their website they have the Crucial System Scanner tool which will automatically detect your computer and memory configuration, and tell you which type of memory to buy. It is as simple as that. I have used Crucial twice to buy memory, and both times they were right on in their analysis. Oh, and did I mention that they guarantee the correctness of their recommendations?

Crucial via gHacks.

Taking Notes with Google Notebook

13 August, 2008 (9:25 pm) | Web

I often take notes. Sometimes I take notes on paper, but that is mostly in meetings or when I am not at a computer. I find that pen and paper works great for jotting down a few action items during a meeting or for a few things I need to remember. But when I am at a computer, I need something more. I need something that is always ready, and something that I can use on any computer. Google Notebook is the tool I have been looking for.

Google Notebook is a website that allows you to clip text and images from any web page. Google Notebook gives you multiple notebooks. Each notebook contains notes or web clippings. You can add comments to your clips. You can edit notes, add or remove notes, reorder notes, share notes, label notes, etc.

I have used Google Notebook to track ideas for this blog, for noting things I encounter on web pages (like interesting quotations), and sometimes even as a clipboard for copying text between computers.

Google has developed some Google Notebook browser extensions for Firefox and Internet Explorer. I have used the Firefox extension. It adds an “Open Notebook” link in the bottom right corner of your browser. Click that link (or press ALT-N) to bring up a mini window with your notes. You can also highlight the text you want to note, right-click and select “Note this (Google Notebook)”. The text now becomes a note.

Google Notebook is one of those applications I never knew I missed until I tried it. And now I have been a Google Notebook user for two years, and I haven’t looked back.

Visit Google Notebook for more information.

X Mouse for Windows

12 August, 2008 (10:13 pm) | Windows

My fingers hurt from pressing those mouse buttons over and over again — but only when I use Windows on my PC. I noticed that when I use a Linux or a Unix computer, I press the mouse buttons much less. The reason? I have configured my Linux / Unix work environment to automatically bring windows in focus as the mouse moves over them.

Microsoft makes a program for doing the same thing in Windows. It is called Tweak UI, and it is part of Microsoft Powertoys. Tweak UI does a lot of different things, but the option we want here is called “X mouse”. Enable that to cut down on the number of mouse clicks.

There are a couple of other reasons I like to use X mouse:

  • I can now focus a window without raising it. This is actually very useful for taking notes in one application while referring to information in another one.
  • I often use VNC to display a Linux desktop in a window on my PC. Having the same focus method in Windows and Linux avoids a lot of confusion.

Visit Microsoft Powertoys for more information.

Jungle Disk Online Backup

9 August, 2008 (4:07 pm) | Linux, Mac, Windows

For a long time I have been looking at using online storage to backup my data. My main concerns were the reliability of the company providing the storage, and the privacy of the data. Enter Jungle Disk. It is a small company with the right philosophy: Encrypt the data locally using state-of-the-art encryption techniques, and update the encrypted data to Amazon’s Simple Storage Service (S3). Only encrypted data ever leave my computer, and nobody but I can decrypt them. I trust that Amazon will be around for a while — unlike the many start-up companies that offer online backup.

Jungle Disk is available for Windows, Mac, and Linux. For $20 you get a lifetime of upgrades. There are no monthly subscription fees or anything like that. You pay Amazon directly for storage at a rate of $0.15 per GB per month. There are also fees for transfer of data in and out of your Amazon S3 account.

Your $20 Jungle Disk license allows you to install Jungle Disk on multiple computers using the same Amazon S3 account. This is really convenient. You can even mount your Jungle Disk as a drive and use it to share files between your computers. Or if you want, you can use your favorite backup tool to copy files directly to your mounted Jungle Disk drive. Of course, Jungle Disk’s backup tool is fully functional so I see no need to use anything else.

I use Jungle Disk simply for backup. It sits as an icon in the system tray and automatically backs up my data on a set schedule. And every month I get a bill from Amazon — around $6 to keep my 30+ GB of data safe. Not a bad deal, I think.

Visit Jungle Disk for more information.

Update on August 12, 2008: The online storage company TheLinkUp went belly-up, and up to 45% of customer data was lost. Read more about it at Network World. I still trust Amazon with my data, and I am happy I didn’t choose a small company to safe-guard my data.

Backup using Karen’s Replicator

6 August, 2008 (8:05 pm) | Windows

Karen Kenworthy has a wonderful little tool called Karen’s Replicator. It is an automated backup program that will backup files, directories, even entire drives. Karen’s Replicator copies selected files from one drive/folder to another. Source and Destination folders can reside anywhere on your network.

Options include repeated copies at intervals as short as a few minutes, or as long as several months, copy only files that have changed, and the replication of folder and file deletions.

Karen’s Replicator is for Windows only. It is free for personal/home use. If you need to buy a license it will set you back $29.95 and it includes more than 25 programs by Karen.

I left my shell in the sun and now it is all GUI

5 August, 2008 (10:25 pm) | Shell

It seems that everything is GUI these days. Everything has to have a graphical user interface. Sure, it looks great, but is it really user-friendly? Do you really get more done with a GUI than with a command-line interface? The saying goes that when you sell software you show the managers the graphical version, but you give the engineers the command-line version.

A GUI is great if you don’t know a program. It shows you right there what you can do. Unfortunately, it normally requires a lot of mouse clicks; even the simplest things now require use of the mouse. And it is difficult to make different GUI programs talk to each other.

A good shell and some command-line tools, on the other hand, may have a steeper learning curve, but once you master them, you can do very powerful things very quickly.

Consider this situation: You have a number of .jpg files in multiple directories. You want to copy them all into a single directory. How would you do it in Windows? You would probably have to look in each directory and copy them separately. If you have hundreds of directories, this becomes tedious. Below I will show you how to do this with a single command in a shell.

I work a lot on Linux and Unix systems, and here I use the tcsh shell. If you have a Windows PC, you can download Cygwin. It is a Linux-like environment for Windows, and it gives you a bash shell and a set of Unix command-line tools.

Completion

So, what can you do with the command-line? One of the best things is completion: When you are typing in a command or a file or directory name, you can press the TAB key and the shell automatically completes as much as it can. This makes typing much faster and much less error prone. For example, try typing the following command:

more some-very-long-directory-name/some-very-long-file-name.txt

I bet it was slow and that you made at least one mistake. With completion you only have to type:

more s[TAB]s[TAB]

The first TAB key expands “s” to “some-very-long-directory-name/”, and the second time I hit TAB I get “some-very-long-file-name.txt”. In both cases I assume there is only one directory or file with a name starting with “s”. If “s” is not unique, TAB will simply expand as much as it can. And if I press TAB an extra time, the shell will show me which options are available.

Gluing Commands Together

On the command-line you can directly use the output of one command as the input to another command by simply placing a ‘|’ (pipe) character between the commands. For example:

cat foo.txt | grep "something interesting" | head

Here, “cat foo.txt” will show the content of the file foo.txt, but because of the pipe, the output will not go to the screen but rather directly to the next command — in this case grep. The grep command will look for lines containing “something interesting”. Those lines are the input to the “head” command, which will display the first 10 lines of its input.

Another way of gluing together commands is using the back-tick operator. The shell executes what is in back-ticks, and replaces it with its output.

grep "something interesting" `cat filelist.txt`

Here the shell first executes “cat filelist.txt”. Assuming filelist.txt contains a list of files A.txt, B.txt, and C.txt, the shell replaces `cat filelist.txt` with the files:

grep "something interesting" A.txt B.txt C.txt

The grep command now looks for “something interesting” in those three files.

Command-line Tools

The “find” command is very powerful. It allows you to find files and optionally process them. For example, you can easily find all .jpg files in the current directory and its sub-directories, and copy them the directory /tmp:

find . -name '*.jpg' -exec cp \{\} /tmp \;

The find command will find all files matching ‘*.jpg’, and execute (-exec) the copy (cp) command on each of them. The \{\} expands to each file name in turn, and the \; indicates that -exec option is done.

The above find command calls cp for each file. If you have thousands of files, then there is a more efficient way of doing it: Use the xargs command.

find . -name '*.jpg' -print0 | xargs -0 -I cp \{\} /tmp

First the find command finds all files matching ‘*.jpg’. Then it passes the list of files to the xargs command. Xargs breaks the list up into pieces that will fit on the command line, and calls cp. Again, \{\} is replaced with file names, but this time each cp command will copy multiple files at once. The -print0 option to find, and the -0 option to xargs are needed to prevent problems with file names containing white spaces. The -I option to xargs tells it to insert the file names at the location of \{\} rather than at the end of the line.

Final Words

If this is the first time you see Unix command lines, then it probably looks like gobbledygook. It is not easy to read until you learn how to decipher the code. But once you learn it, you have a powerful set of tools at your disposal.

University of Cambridge has a leaflet describing Thirty Useful Unix Commands. There are many more commands out there, but these ones are good to know.