jump to navigation

Installing Vista Fonts in Ubuntu September 16, 2007

Posted by Carthik in guides, looks and feel, microsoft, packages, ubuntu.
475 comments

Microsoft’s new ClearType fonts for Vista are great. The fonts include Constantia, Corbel, Calibri, Cambria, Candara and Consolas.
Microsoft Vista Fonts

Getting them installed in Ubuntu is a breeze, thanks to a script I found.
To install the Vista ClearType fonts in Ubuntu, you need to install cabextract first. Cabextract is a utility found in the universe repository, so before you run the following command, make sure you have universe enabled in your repository list. Once this is done, install cabextract using:
$sudo apt-get install cabextract

Then, once that is done, use this script to install the Vista fonts. Create a file called “vista-fonts-installer.sh” in your home (~) directory.
Then open up a text editor and copy and paste the script into that file.
Do a chmod a+x ~/vista-fonts-installer.sh to make the file/script executable.
Then run the script using:
$ ~/vista-fonts-installer.sh

The script downloads the Powerpoint Viewer installer from microsoft.com, and then extracts the Vista cleartype fonts using cabextract. These fonts are then installed in the ~/.fonts directory.

Please remember that the ClearType Vista fonts are not free as in they are not GPL-ed or made available under a re-distributable license. Since you are downloading the fonts from the MS website, and since you might already have a Windows XP/Vista license, this is not a crime, but consider yourself warned against the perils of supporting closed systems 🙂

Update::

  1. Looks like the use of these fonts are restricted to only Microsoft Windows/Vista operating systems according to the terms of the license. I am sorry, but you’ll be installing them at your own risk.
  2. Also, please make sure you use the bash shell, or change the first line of the code to #!/bin/bash
  3. In retrospect, this was a bad post – I think we’re better off not using stuff folks don’t want us to use – let’s use the better, freer, easier to install fonts.

SSH Menu – Save and Open SSH Connections from the Panel August 17, 2007

Posted by Carthik in applications, gnome, packages, ubuntu.
95 comments

I was looking for a replacement for SecureCRT in Ubuntu. Something that would let me save all my SSH connections and make it possible to open a connection with the least effort.

As is often the case, I found something better than SecureCRT – a panel applet for GNOME that gives me a drop-down list of SSH connections. SSHMenu is cool, way too cool.
SSH Menu
(more…)

300+ Easily Installed Free Fonts for Ubuntu May 21, 2007

Posted by Carthik in applications, gnome, looks and feel, packages, ubuntu.
370 comments

Ubuntu offers a lot of fonts, in addition to the defaults installed, and the MicroSoft msttcorefonts package, in its repositories. All these fonts mentioned here are provided as packages, which can easily installed using command line tools like apt-get or using Synaptic. These fonts will come in handy for designing flyers, or for designing headers and graphics for the web using the Gimp. Also, some of these fonts are pretty commonly used to render pages, like Lucida.

I will save the packages with the biggest collection of fonts for the end here. Since I have included screenshots of most of the fonts, and this article is sorta long, please read on by clicking the “More” link below.

(more…)

^txt2regex$: Regular Expression Tool To Create Regex from Description April 21, 2007

Posted by Carthik in applications, commands, packages, ubuntu.
24 comments

^txt2regex$ is a lifesaver. It helps you create regular expression strings in a step by step process, by describing what your regex pattern should do in English (or your own language). The tool can create RegExes for use with 23 different programs, including sed, vim, mysql, and procmail. When you start the program, it will ask you a series of questions like “1. do you want to start matching at the beginning of lines? or 2. search anywhere?” and “this is followed by…. 1. A specific character…” etc… download it and run it and you will see.

Anyone who has worked with regular expressions for searching and optionally replacing stuff in files knows what a godsend then can be if you get the regex down pat – but they would also know what a time sink they can be if you can’t whip up exactly what you want. In the past, when faced with this kind of a situation, I would read man pages, books, experiment, fail and then, finally, succeed after a good half hour or so. txt2regex is a tool that eliminates the confusion. Totally.

You can install txt2regex on Ubuntu by doing a:
$sudo apt-get install txt2regex

Among its features include the ability to print a list of characteristics of the regular expression syntax for various tools, a history tool which keeps track of you past regexes, and some pre-built regexes that are often used – for dates, times and numbers.

For example,
$txt2regex --all --make number3
will create the regex for all supported tools. The regex will match a number of the form “34,412,069.90”

Here’s the output:

carthik@milan:~$ txt2regex --all --make number3

### number LEVEL 3: level 2 plus optional commas, like: 34,412,069.90

 RegEx awk       : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx ed        : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx egrep     : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx emacs     : [+-]?[0-9]!!\(,[0-9]!!\)*\(\.[0-9]!!\)?
 RegEx expect    : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx find      : [+-]?[0-9]!!\(,[0-9]!!\)*\(\.[0-9]!!\)?
 RegEx gawk      : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx grep      : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx javascript: [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx lex       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx lisp      : [+-]?[0-9]!!\\(,[0-9]!!\\)*\\(\\.[0-9]!!\\)?
 RegEx mawk      : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx mysql     : [+-]?[0-9]{1,3}(,[0-9]{3})*(\\.[0-9]{2})?
 RegEx ooo       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx perl      : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx php       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx postgres  : [+-]?[0-9]{1,3}(,[0-9]{3})*(\\.[0-9]{2})?
 RegEx procmail  : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx python    : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx sed       : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx tcl       : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx vbscript  : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx vi        : [+-]\{0,1\}[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\{0,1\}
 RegEx vim       : [+-]\=[0-9]\{1,3}\(,[0-9]\{3}\)*\(\.[0-9]\{2}\)\=

$txt2regex --help
prints out a short help message

and

man txt2regex
gives some more info.

What would be handy is if txt2regex had an extension that allowed one to deconstruct a regex – give it a regex and it tells you what it does in plain English. Also, I cannot seem to create regexes for the mod_rewrite module in apache. I suspect that since mod_rewrite supports POSIX regexes, I could just run with one or the other of the regexes created by txt2regex. Since I haven’t tried it, I can’t say which one of the 23, just yet.

“True” Word Count In LaTeX February 7, 2007

Posted by Carthik in commands, packages, Readers' Tips.
42 comments

By way of Wei comes this little nugget of useful information of the kind I love.

If you were to count the number of words in a LaTeX document using the “wc” command, you will find that you have counted, in addition to the words you wrote, all the LaTex formatting text, like the “\paragraph”s and the “\textit”s.

Of course if you use Kile like I do, all you have to do is go to “File -> Statistics” to see the word count. But if you don’t use Kile, then you can follow Wei’s advice and install and use the “untex” package by doing a:
$sudo apt-get install untex and then a:
$untex source.tex > target && wc -w target
to count the number of words in the file named “source.tex”.
Alternatively, you can use this online tool to count the words.

A word of caution here — untex does not ignore equations, and so the output of the word count might be off by a bit. If you are a perfectionist, I would recommend using detex instead. There is no seperate package for detex, it ships in the Ubuntu package texlive-extra-utils.

If your document has citations, references, and include other files etc, the only reasonably efficient way to count the words in the final result is to convert the pdf file to text and then to count the words. Here is a command that will help you do that:
$pdftotext file.pdf - | egrep -E '\w\w\w+' | iconv -f ISO-8859-15 -t UTF-8 | wc

pdftotext is a command line utility provided by Xpdf. You may have to tweak the charsets in the previous command.

Create DVDs with All of Ubuntu’s Packages December 11, 2006

Posted by Carthik in guides, packages.
11 comments

For those looking to install Ubuntu without a high speed internet connection, a set of DVDs with the entire contents of the repositories would be a great tool. The idea being that armed with the DVDs, you really don’t need a net connection for retrieving any packages, since between the DVDs you have every package that is present in the software repositories.

Though there is no “official” set of DVDs, one can find such DVD sets for sale at some shops online. The catch is, of course, that the DVD sets are expensive. Why pay for something that is free? Ubuntu is 100% free, and we like it that way.

I just ran across some detailed instructions to create a set of Ubuntu DVDs. In fact, it is one better than a set of detailed instructions – it is script that you can use to create such DVDs. A few months ago I had started on writing a bunch of commands in python that would do the job – but never got done. The “How-To Make Ubuntu DVDs Including Main, the Universe and Everything” article seems to use some Ruby scripts. I know little about Ruby, but as long as the task is completed, the programming language matters little.

The script promises to generate 4 DVD images (.iso files), and might require as much as 30 GB of hard disk space. I usually try out the tips I post here first – but this time, since I don’t have 30 GB of hard disk space to spare, I have not been able to try this technique. I have a tight budget – with a laptop, I really can’t have all the HDD space I want 🙂 So it would be great if some of you could try this one out, and let me know how it goes.

Share Music in a Network using Avahi (DAAP) September 22, 2006

Posted by Carthik in applications, guides, music, packages, ubuntu.
40 comments

Okay, so I have a desktop with around 50 Gigs of music. I also have a laptop on which I work most of the time, from various places in and around the house. I did not want to (and don’t have the space to) copy the songs onto the Laptop. So I went looking for a simple way to share my music over the Network.

I found that rhythmbox supports DAAP, the same technology that Apple uses with iTunes to enable sharing.

To enable sharing, install the avahi daemon on the desktop using:
$sudo apt-get install avahi-daemon

Now, in Rhythmbox, go to Edit->Preferences->Sharing(which is a tab) and select “Share my music”.

Avahi is the name of the project that brings DAAP (aka rendezvous or zeroconf) to Linux.

You’re all set! Now when you use Rhtyhmbox on the laptop, or any other system in your network, the music collection on the desktop should appear when you start it up in the “Source” pane on the left! Og’s post was one of the many pages I hit when I was searching for a solution. He even has a screenshot showing how the shared directory shows up.

If you want to share music using Banshee, install the banshee-daap package which provides a plugin for DAAP music sharing.

The only caveat is, even when you use this, Rhythmbox has to be running on your desktop for the files to show up elsewhere. If that bothers you, then see how Tangerine can help you. From the website, we get the following description:

Tangerine is an application that allows you to publish music over the local network, using DAAP. It runs on both Linux and Windows. There are several clients that you can then use to connect to it, such as Apple’s iTunes, Banshee, and Rhythmbox.

Music files can be specified either by a directory, or can be automatically discovered using Beagle or Google Desktop. Recently you can also specify which music player you use and share the songs in it’s collection. For typical configurations, a graphical tool is included (see below).

As far as I know, the stable version of Amarok, my favorite music manager, does not have any support for DAAP, either as a server(for the desktop) or as a client(for other computers to access shared stuff).

Normalize the Gain (Playback Volume) of your MP3s September 11, 2006

Posted by Carthik in applications, commands, guides, packages, ubuntu.
50 comments

I confess to the grave sin of storing part of my music collection in the mp3 format – mostly music I have had around for ages. There, now that that is out of the way, let’s move on to making that collection friendlier.

I have the habit of going to sleep while listening to a little light music. Some of the songs in my collection would sound louder than the others. So when I have a couple of classical music tracks lined up with Paul McCartney and Guns ‘N Roses, I sometimes get jolted awake by the difference in the playback volume. So off I went looking for solutions.

My main concerns when I started my research were:

  1. My mp3s should not be irretrievably changed into something I end up hating
  2. I did not want all songs sounding as loud as the loudest song
  3. The algorithm or method used should be free of the application used for music playback

Then came the choices. In the end it all came down to two apps: Normalize and mp3gain. Now how do I decide which one’s the one for me without learning DSP? Simple, search some more.

Fortunately, besides the websites for the applications, I ran into this thread at jwz’s livejournal. Thank god for geeks-who-start-nightclubs and their friends! I also followed most of the replaygain technical outline, since mp3gain is an implementation of the replaygain idea.

Normalize is simple, perhaps a little too simple.

mp3gain works by figuring out how loud the music actually sounds to the human ear, and then figuring out how much positive or negative gain to apply to the mp3 file to “fix” it. I was happy to note that it does not use the peak volume in a file as a benchmark for normalization. It applies changes by modifying the mp3 file in some fashion, but I read that the change is reversible since mp3gain writes some tags (not ID3 tags) to the mp3s for possible later undoing. This fact also means that one you use mp3gain on a file, if you try doing it again, it takes a lot less time – almost no time. So in the future if I add files to the collection, and I don’t remember what files I added, I can run mp3gain on the entire collection, and it will complete much faster than the first time.

To cut to the chase, I decided to go with mp3gain. I installed the mp3gain package (using $sudo apt-get install mp3gain), and set out to normalize my entire music collection. (For those of you who also have .oggs, check out vorbisgain).

Edit: for an alternative command, with explanation, and a way to use album-gain for songs from albums, visit porges
The following command, executed from the directory where I store my music normalized all the files in my collection:
$find . -type f -iname '*.mp3' -print0 | xargs -0 mp3gain -r -k

What it does is, it finds all files (type -f) in the present directory (.) with a name that ends in “.mp3” and creates a list of the same. The output of this find command is then piped to the mp3gain program. The options that I ended up using for mp3gain, -r and -k dictate that the calculated track gain will be applied automatically to normalize the volume, and that files should be protected against “clipping” by lowering the applied gain if the required gain seems likely to clip the sound. Concoct your own recipe by referring to the man page for mp3gain.

After around 16 hours of processing on my old PIII desktop, my massive 50 GB music collection now agrees on what is an acceptable volume. Needless to say, I sleep in peace.

Local DNS Cache for Faster Browsing August 2, 2006

Posted by Carthik in administration, guides, packages, ubuntu.
332 comments

A DNS server resolves domain names into IP addresses. So when you request “google.com” for example, the DNS server finds out the address for the domain, and sends your request the right way.

You can run a DNS cache on your computer. This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms for me. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement. Of course, all this would be worth it if it weren’t for the fact that setting this up is way too easy.

The following instructions are for someone with a cable (broadband) internet connection, where the computer gets it’s local IP address using DHCP from the router in your house/office:

The package we will be using for caching nameserver lookups is called dnsmasq. So first, install it using:
$sudo apt-get install dnsmasq
(If you can’t find then, then you probably haven’t added the Universe repository to your list of repositories.)

No uncomment the following line (that is edit the line to NOT have a “#” in the beginning) in the file /etc/dnsmasq.conf:
listen-address=127.0.0.1

Now edit /etc/dhcp3/dhclient.conf and make sure the section below exactly like this, especially the line that says “prepend domain-name-servers 127.0.0.1;”

#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

Explanation for the above change: In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the /etc/resolv.conf file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider). Adding the “prepend” option as we did above ensures that “127.0.0.1” will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 – your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the “127.0.0.1”. I hope that explains things.

Now open the file /etc/resolv.conf in your text editor. It probably looks like:

search yourisp.com
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

The 127.0.0.1 is missing right now since you haven’t renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:

search yourisp.com
nameserver 127.0.0.1
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

Don’t worry if the numbers are different – if they are not, then hey – we must be neighbours 😉

Okay. We are almost done here. All we have to do now is to restart dnsmasq so that the changes we made to the configuration file take effect. You can do that using the command:
$sudo /etc/init.d/dnsmasq restart.

Now you are running a local DNS cache. If you want to measure your speed improvement, type the command:
$dig google.com
You will see something like “;; Query time: 38 msec” there.
Now type the command again, and you should see something like:”;; Query time: 2 msec”

See, the first time, since google.com’s details were not in your cache (you are using it for the first time), the query took 38 ms. The second time, the cache speeds up the lookup. I have been using this for over a month now, and haven’t had a problem.

The following is ONLY for dsl customers
Note: If you have a dsl connection, the following may work:
Basically, the differences are in how the “conf” files are edited and used.
Copy the /etc/resolv.conf file to /etc/resolv.dnsmasq.conf
Then, edit the /etc/dnsmasq.conf file as follows:

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/resolv.dnsmasq.conf

You also have to uncomment the line that says listen-address=127.0.0.1
Now, edit /etc/resolv.conf to have ONLY the following line in it:
nameserver 127.0.0.1
Next, edit /etc/ppp/peers/dsl-provider and change the line:
usepeerdns to
#usepeerdns
(that is, comment out that line)
The ppp client does not allow you to prepend the 127.0.0.1 entry to your /etc/resolv.conf file. So what we did in the above was to create a copy of your previous resolv.conf for dnsmasq to use for lookups, update the file to use a local cache, and then prevent the ppp client from overwriting the resolv.conf file the next time. Now you can restart the dnsmasq service as I explained above, and start enjoying faster name resolution.
I don’t have a dsl connection, and so all the above is to the best of my knowledge.

To those of you still on dial-up – THANK YOU for visiting my blog! (I’m too ignorant to know how to change things to get dnsmasq to work on dial-up 🙂 )

Participate in the Popularity Contest July 16, 2006

Posted by Carthik in administration, applications, packages, ubuntu.
22 comments

The popularity-contest (popcon) package in Ubuntu lets you vote on your favorite, most-used apps and packages every week. This is an automated process, so once you set it up, you will never have to worry about it again. Below is a description of the package:

Vote for your favourite packages automatically. When you install this package, it sets up a cron job that will anonymously inform the developers about your most used packages.
This information helps us make decisions such as which packages should be promoted and so be in standard installs.

The results are available to everyone at popcon.ubuntu.com. Seeing as there are less than 2000 i386 (pentium) users that currently submit popcon information, I thought we could do better. So setup popcon and start submitting info about your usage of applications now – this is vital feedback for those who architect the distro – not to mention a lot of fun for everyone.

Here’s how you set it up. It is already installed, but inactive:
Execute the following command to reconfigure it:
$sudo dpkg-reconfigure popularity-contest

You can choose to submit stats via http, or via email. Both are automated processes, and I’d choose http for the convenience. If, however, you do choose email, note that you might have to take a small additional step to enable postfix to send the email properly. You can follow the instructions to setup a “smarthost” in postfix to ensure that your email gets sent and received without problems. I have my popcon set up to use the http protocol to send information. Since it is anonymous, it is not a threat to your privacy. So go ahead, and give ’em some feedback.