Create an HTML version of man pages

There is a program designed for the purpose of creating an HTML version of a manual page (man page). This program is called man2html. However, man2html does not create a table of contents in the resulting HTML, which would be very useful for long man pages. But we can actually accomplish that with the man utility itself, believe it or not!

The man utility gives us the ability to view a man page in a browser, with the man page formatted into HTML (with table of contents). This is done using the following command:

man -Hbrowser page

where “browser” is the browser you wish to use, for example “firefox” or “google-chrome” (these need to be in your PATH), and where “page” is the man page you wish to read, for example “bash” or “emacs”.

Unfortunately, the HTML file created for this purpose is a temporary file which is deleted! So if you close the tab or window of the browser, or even refresh the page, you will get an error telling you the HTML file cannot be found anymore! To get around this, we trick the man utility into using the cat utility as the browser. We then let cat redirect its output of the HTML file to a permanent file, like so:

man -Hcat bash > bash.html

After that, we can view the file in a browser:

google-chrome bash.html



Find the UUID of a disk to use in fstab

To find the UUIDs of devices, just run blkid. This will print UUID, which type of file system the partition is using, as well as its label if it has one.

To use the UUID in /etc/fstab, just copy the UUID and paste it into fstab, and it will mount that specific disk regardless of where it is located in /dev/ (which tends to change from time to time with removable storage devices).

# blkid
/dev/sda1: UUID="d8aa67a2-2b1c-41d9-b31f-9452c17a1fe5" TYPE="swap"
/dev/sda2: LABEL="System Reserved" UUID="140025B70025A12A" TYPE="ntfs"
/dev/sda3: LABEL="Windows" UUID="307468D67468A078" TYPE="ntfs"
/dev/sda5: UUID="9ed324ed-ce0a-4cd3-b2b5-439a08c622c5" TYPE="ext4"
/dev/sda6: UUID="8ae1edc4-2198-4207-b826-7817a4621394" TYPE="ext4"

Automatically announce hostname on local network using Avahi (Multicast DNS)

I recently setup a server computer in my apartment. I put Ubuntu 11.04 Server Edition on it as the operating system. Since it’s a server, I wanted to be able to connect to it via SSH and not have to actually have to be physically present in front of it to be able to log in to it. That would definitely ease performing administrative maintenance tasks, such as installing software.

The problem was that when I tried to connect to the computer, ssh was unable to make a connection. The command I issued was:

ssh server

where “server” is the hostname of that machine. What puzzled me was that ssh was able to connect to that machine if I issued its IP on the local network instead of its hostname.

After some digging around I found that installing avahi-daemon would solve this problem. I’m not exactly sure what it does, but I understand that it sort of announces the machine’s hostname to the network. So all I did was:

sudo aptitude install avahi-daemon

and after that I could connect to the machine using:

ssh server.local # “.local” must be appended to the hostname for some reason, maybe because of how mDNS works.


Inserting output from external command into a buffer in Emacs

I recently found a keyboard shortcut for Emacs that I think can prove to be very helpful at times. The keyboard shortcut enables you to run an external command and insert its output into the buffer you are currently editing. An example of when this can be useful is putting a date marker in a file, to document when it was written/saved/modified/etc.

The keyboard shortcut is this: C-u M-!

For example, I might run the command date to insert the current date into the buffer. Or I might prefer my dates formatted in a way more familiar to my locale: date +'%F %R %Z'. (This makes the date format as YYYY-MM-DD HH:MM TZ, where TZ is the current “alphabetic time zone abbreviation”, e.g. 2087-02-26 06:00 CET.)

Another example is to include the directory listing of a certain folder into the current buffer. The command to run would then be ls.

Very handy indeed!


Installing LaTeX packages in your home directory

I was recently in a position where I wanted to use a LaTeX package, but it was not installed on the computer system I was working on. The computer system was at my workplace, at Umeå University. I had a conversation with the systems administrator and he told me that updating the entire TeX distribution would require a lot of work, but that I could place the package in the current directory, with my document, and it would hopefully compile.

I hoped so too. But of course, this being the real world, such luck is rare with computers. So I decided to dive into how I might install a LaTeX package locally, in my home folder. I finally managed to find a solution, and I will detail this below.

This “how-to” will not cover how to create a package, or even how to download ready-made packages or whatever. I had the package that I required installed on my computer at home, so I just copied and pasted that over to the work computer. This tutorial will only cover how to make LaTeX look for packages elsewhere than the default package path.

LaTeX automatically looks to see if there are any package installations in $HOME/texmf/. That search path is the default value of the environment variable TEXMFHOME. This is very nice and handy; what this means is we can use “$HOME/texmf” as a folder to chuck packages into. However, I prefer to have files that I never really intend to open in hidden folders (folders whose name starts with “.” (dot)). So the next step I took was to create a folder where I can put packages, in my home directory (“$HOME”).

> mkdir $HOME/.texmf

After that, I went and added a command to my .bashrc file that will change the value of the TEXMFHOME variable to be that of the newly created folder. This way, LaTeX will search for packages in that folder instead. The following lines were added to the .bashrc file.

# LaTeX stuff
export TEXMFHOME=$HOME/.texmf

I usually use pdflatex to compile my LaTeX documents, so if you use some other program, the environment variable you need to change might be different. I compile my LaTeX documents on the command line, so if you use another system, you might have to find another way to export your environment variable, or even use the specific application settings in your editor, if your editor supports compiling LaTeX documents.


Chrome – Using a website as an application

I really enjoy using GMail for my e-mail tasks. It’s a great service and a great interface with quick and easy keyboard shortcuts. I usually keep a browser tab or window open all the time with http://mail.google.com loaded. The problem is, I use GMail more like an application than a web page. If I turn to another tab within the same browser window, I don’t readily see my GMail “app” anymore, because it has then become an inactive tab in that window.

One solution to this could be to have one browser window open at all time, which has no other tab in it than the GMail tab. A whole window dedicated to GMail solves the problem once and for all. It’s always the active tab, and it has the added benefit of getting its own item in the task bar (or the Window List as we GNOME folk like to call it). That way I can even see whether I have any new e-mails or not just by looking down slightly to the window list. I don’t even have to open the browser window at all!

But, believe it or not, we can actually do even better than this! With Google Chrome (or the other version of Google Chrome which is unbranded by Google – Chromium – which is the one I use).

There is something rather unnecessary with the solution described above. It’s not the fact that a whole window is dedicated to just GMail. We’ve covered the benefits of that. It’s the fact that the window still has a tab bar, address bar and various other interface elements. This is unnecessary because we don’t intend to use them! Remember, this was meant to be a window dedicated to just GMail.

What you can do about this is to create a Launcher on our desktop or quick launch area or wherever you prefer, where you launch Google Chrome/Chromium with the following flag added:


This will launch the URL given in the quotes and strip the interface elements from the browser window. It will also use the favicon of the page as the icon for the window list/task bar item which will make it easier to spot among the other items.

Below is an image to show you just how minimal the window is after running Chrome with that added flag.

Creating the launcher will not be covered here. Please see the documentation of your operating system on how to create launchers or shortcuts or whatever they might be called.

Tags: , , ,

So, yeah.

I read a lot of blogs using a little service I’d like to call Google Reader. I’m sure others call it that, too. One thing I’ve noticed is how annoying it is when people start their blog posts with something along the lines of:

  • So, I was…
  • So, I’ve been…
  • So, I’m…

The main problem here is obviously the “So,” part. Now, it’s very possible that I too have used this way of starting a blog post. If so, however, it would have been before I realized how arrogant it makes the author seem. Not only did I take the time to read your blog post on your blog — one of millions on the Internet — but you also have the audacity to say “Anyway, let’s get BACK TO ME for a change.” You might not agree with me; maybe it’s just me. That might be so—I am very peculiar when it comes to a lot of things, so I wouldn’t be surprised!

Another thing I can’t stand is when authors answer questions that their reader (namely me) never asked in the first place. It’s like they’re saying: “Of course you would ask this question. That’s how important I am.” Take this for example:

Yes, I’m still alive and kicking. Been really busy at work and haven’t had the time or energy to write anything here.

Okay? I didn’t really ask, or even wonder what you’ve been doing. The only reason I read (or skim past) your blog posts is because your blog is part of an aggregated blog package with more interesting posts. And by the way, if I may, even if I did care about your blog, I don’t need to know what you’ve been doing instead of writing your blog. Just write and stick to the juicy parts! No need to explain yourself.

As you can probably tell, I quite know how to pick my battles in life. 😀 Told you I was peculiar!


Browser Size Comparison

I’ve been using Google Chrome (or rather Chromium) from the development channel since a relatively short time after it was announced to the public, and ever since I started using it I have been amazed at the rendering speed, development speed, page (pre)loading speed and startup speed(!) of this wonderful open-sourced browser all while it manages to be visually discrete yet enticing.

Something that bothered me about Mozilla Firefox — which is the browser I was using prior to switching to Chromium — was that a lot of the screen area was taken up by all the tool bars. Just look at this comparison (follow image link for larger version):

Just look at that ridiculous height that Firefox is taking up (browser to the far left). It has the window title bar, menu bar, “Navigation Toolbar”, “Bookmarks Toolbar”, and finally the tab bar. That’s FIVE bars! Outrageous. Now, it is true that the tab bar hosts only one tab in the screen shot, and you can actually set it to hide the tab bar if in fact only one tab is showing. But open one or more other tabs and the tab bar is there!

I should also mention that it is possible to customize Firefox to show nothing but the window title bar and the menu bar (with the addition of the tab bar if this is the current case). So that condenses it quite a bit. You can also choose to use small buttons for the “Navigation Toolbar”, but it doesn’t really make them considerably smaller in my opinion.

Next is Microsoft’s Internet Explorer 8. Counting the bars of IE8, we see 4 bars: the window title bar, navigation toolbar with back and forward buttons, location text field, and search text field. Quite good utilization of a bar, in my opinion. Then a poorly utilized favorites bar, followed by the tab bar. What I think is interesting to notice here is that IE has in recent versions done away with the ancient menu bar, since it actually isn’t used very often.

Notice how unnecessarily large each tab seems to be, and that there are a bunch of buttons to the right of the existing tab that would seem to be in the way of newly opened tabs. There is actually a perfectly wasted space in the “favorites bar” directly above those buttons where the buttons would fit very snugly. Why not put them there instead?

Moving on now to Chromium. The compact, blue (in the default theme) browser. The image next to the one at the far right is Chromium in its non-maximized state, i.e. just a regular window. And the one at the far right is Chromium in its maximized state.

In its non-maximized window state, Chromium has a little space between the tabs and the top edge of the window, so that users will be able to drag the window relatively easy. This vertical space is about 15 pixels. The tab height is 25 pixels. This gives a total of 40 pixels. That’s not a lot on a 1920×1080 screen, or even a 1024×768 screen, yet they managed to make tab text very legible and it looks very stylish all while maintaining this thin size. In its maximized state, the extra space above the tabs is almost completely removed (what’s left is maybe about 2 pixels).

Another important factor is that Chromium not only done away with the menu bar, like Internet Explorer, but also has no window title bar. At the end we are left with just two bars! Extremely compact. All menus are stowed away in the Page/Document/File (icon) button menu, and Wrench/Settings button menu in the navigation toolbar of Chromium.

Chromium also has only one text field in the navigation toolbar, which works as both location field and search field. By putting a question mark at the beginning of what you type into this text field, you can search your default search engine (set in the preferences), and by pressing CTRL+E or CTRL+K Chromium adds the question mark automatically for the user. But actually, I believe anything that isn’t parsed as a URL (such as a web address, or a local file name) is fed through the search engine.

I haven’t mentioned that Chromium also does have a bookmarks toolbar. I usually hide it because the “Omnibar” (Chromium’s name comparable to Mozilla Firefox’s “Awesome bar”) is just so great at finding my bookmarks and search history (and even pages I haven’t visited before) that I don’t really need the bookmarks toolbar. And if I do, I just click the Add tab button (the \+\ looking button to the right of all the tabs). This opens the
New Tab page, which features both the bookmarks toolbar and if I choose, thumbnails (or a list) of a few select pages of my choice.

Browsing with the bookmarks toolbar however, is quite similar to what’s seen below:

Behold Apple’s browser, Safari 4. If Safari is be able to remove its bookmarks toolbar, it is quite similar in size as Chromium. Safari does feature a menu bar, but it is tucked away at the top of the screen, as almost all programs do under OS X.

But still, the window itself is free of the menu bar, for you see, Apple, Google and even Microsoft (SOMETIMES) belong to people who just “get it”. Simple is better. Less is more. Remove all the bulk and cruft and what you get is a lean machine of a program that is highly useful. Featuritis is a disease, and that includes too many interactive parts visible at the same time in a given window, within a given area of the screen. Content is king. The application comes second, and therefore needs to enable the content to flow forward as best it can.

By now this post (or more like article) is quite long, but I’d just like to mention a little something about the little favicons to the left of the tabs in the Chromium window. In case you’re not interested in them, you may stop reading now. 🙂 It’s a lovable little feature that has come back in a form even stronger than before — Pin Tab. This feature  was present in older builds and was removed for a while. It lets you make a tab’s width even smaller (just over the width of the favicon), and stow it off to the far left for safekeeping — “pinning” it. This is great for any tabs you keep open for a long time during your browsing session (which lasts days or weeks for some who don’t shut off their computer).

I was messing around with the Pin Tab feature now that we got it back on the Chromium dev channel, and it turns out the new feature (or at least one I hadn’t noticed before) is that if you close a Pinned Tab, its icon will remain on the far left, and you can click on it to open the Pinned Tab back up again still in its Pinned form. Just like a bookmark, or an application that loads super-quick, right in your tab bar. Amazing feature. They are window-specific however, and are not present in newly opened windows. Just like regular tabs. All that’s missing now is a key combination to pin a tab.

Wow, 1216 words. That’s pretty bad, even for me, so I’ll end it now. Thanks for reading!


New Google Interface

Apparently if you’re running a late enough version of Chromium or Google Chrome I really don’t know how you enable this, but you might experience that Google’s home and search results page have been revamped to a new style. I’m running Chromium 5.0.335.0 5.0.356.2 (on the dev channel).

This is what these pages look like for me now:

Notice how the buttons and search text box is bigger, and the Google logotype now lacks shadows and the trademark symbol has been taken off of it. This page no longer features the fade-in effect, but shows everything on the page immediately. Though I have to say, in Chromium, the page reloads much, much faster anyway, than in Firefox 3.5.8 (current version in Ubuntu 9.10 as time of writing).

Update (2010-03-12): Fade-in effect is now activated in the new design as well.

Moving on to the results page now:

As you can see there is an entirely new menu on the left hand side. This menu is collapsed by default but I expanded it to show what it looks like. The options that were available before–such as sorting by date, and other attributes–can now be found under “More options…” also on the left hand side. The first menu on the left is very smooth-looking with its little favicon/thumbnail style of icons, and probably AJAX-powered, with its smooth expanding and collapsing. The menu below it however, unfortunately is not very smooth and seemingly even reloads the page when one expands/collapses it. It also resets the state of the menu above it.

Update (2010-03-23): The lower menu is now much more smooth and does not reload the page. It also features a few options (two at first: “All results” and “Page images” and more as you use other options), and the menu has now been titled “Recommended Tools”.

Update (2010-03-12): The little icons in the left-hand side menu are now colored as opposed to monochromatic/gray-ish.

Another thing to notice is the integration of the search button into the search text box, giving them both a more coherent look.

One thing I’m really missing from this new interface is the handy dictionary on the right side. If you search for a word that Google’s dictionary recognizes, there would otherwise be a link to its definition (see image below). I can’t see that anymore, but hope it resurfaces some day.


Windows Restarting Automatically

Really? Still? Are you serious?

O.K., I’ve been using Windows since just before Windows XP came out, and Windows XP had this thing called “Automatic Updates”. This concept is brilliant, and is used these days in many, many popular, more or less advanced pieces of software. One example is of course, as mentioned, Windows XP. Other examples include Mozilla Firefox, with its incremental updates that can download automatically; Mac OS X has security updates and major version updates to the operating system itself and accompanying software, such as iTunes, Safari, etc; and Ubuntu has free updates to all of its software packages, and the operating system itself upgrades to major new releases, just as most other free (GNU/)Linux distributions.

One huge gripe I always had with Windows XP, which was never resolved—not that I know if it was even considered a problem by anyone else but me since it was never fixed—was that once updates had been installed, it pretty much ALWAYS required me to restart the machine. The keyword here is “me”. Or rather, isn’t, but we’ll get to that. (Yeah, you bet we are!) And not only this constant restarting of the machine whenever there was an update, there would always be a notification stating this fact, asking me whether I wanted to restart Now or Later. I always chose Later, because for goodness’ sake, it’s not like I sit down in front of the computer just to restart it again while I’m in the middle of my work. But this damned notification keeps popping up at regular intervals, incessantly driveling about the same stupid question! NO I DO NOT WANT TO RESTART AT THIS POINT IN TIME, IS THAT NOT AN ACCEPTABLE ANSWER? If it’s not an acceptable answer, why ask the question in the first place?

We-e-ell, isn’t that an interesting question. In fact, if you didn’t keep answering the same question over and over, and just let the dialog sit there for a while, Windows XP would start asking itself the very same question, and it would actually RESTART ITSELF, without permission! RIDICULOUS behavior! This brings us back to present day, not only because this is still a problem with Windows XP, but because I’ve now moved on to Windows 7 and the problem is still as blatant as ever! Thank GOD that isn’t my only operating system and I only boot into it every once in a blue moon.

So today I was just minding my business, playing Counter-Strike: Source, when suddenly the game just shuts down and even Windows says “shutting down”. It wasn’t a crash and it certainly wasn’t an error on my part where I accidentally hit a key combination that would minimize the game and shut down the operating system. No, what had happened was that Windows received information about an update it could install, downloaded the update, installed the update, and just threw me out. Past the curb and straight under the bus! Stupid Windows design flaws, get it right for once in ten years! EVERYBODY ELSE KNOWS HOW TO DO IT.

There was absolutely no way that I could have spotted any potential warnings Windows would have given me about the reboot just because I was running a full-screen game—although considering the circumstances I doubt there even was so much as a little icon in the task bar letting me know what was going to happen. Yet other times, ironically, the game just minimizes for no reason and I’m met with an empty desktop.

I don’t know what Windows’ problem is. I’m guessing those geniuses at Microsoft are thinking “if the user isn’t around anyway, it’s probably safest to just install this update and restart the computer so that the computer will be updated and ready to go when the user comes back. Or something? NO THAT IS A STUPID DESIGN. I KNOW WHAT I’M DOING, I JUST. DON’T. WANT. TO INSTALL THE UPDATE. ATTHISPOINTINTIME. IS THAT A CRIME? There’s just no excuse. I mean what if you’re a speaker at a huge conference or something, or you’re running a program that displays something on a public screen in the middle of the street or your store window? All of a sudden it just decides to restart automatically, just because you’re not monitoring the screen every second, un-maximizing all of your full-screen applications to see if there is an update, and when there is spend all day clicking Restart Later until closing time of your store.

THE CONSEQUENCES COULD BE MAJOR LOSS OF IMPORTANT DATA. Which in turn could mean loss of revenue, and lack of food on the table. STUPID. I could’ve been a professional computer-game player, playing an extremely important match of Counter-Strike: Source against my arch rival team or something, and I was the last surviving player on my team! IN THE FINALS OF A CHAMPIONSHIP. And all of a sudden, Windows 7 just bombs out on me. WOW. YOU SUCK, MICROSOFT. AND YOU SUCK, WINDOWS. What a piece of crap product and operating system just for this problem alone. Take a lesson from Ubuntu and Mozilla Firefox and just about every other piece of software that has automatic updates. Ask the question once. And when we answer “No”, all you say is “Don’t want to install it now? Alright, I won’t bother you again, sir/madame. Have a good session and I will install updates upon your next reboot.” AND BE DONE WITH IT.

I loathe Windows.