Archive for the 'tips' Category

Enabling Polish Letters (Ogonki) in Vim

Tuesday, August 19th, 2008

This is one of these things that I always need to look up. I know this tip will probably have no relevance for 98.5% of my regular readers, but I wanted to put it here for future reference. Also, since I just spent like 20 minutes googling the solution perhaps this can be of service for people who run into the same issue.

Today was the first time since I last reinstalled Windows when I needed to type something in Polish inside Vim and I realized that my Alt-gr combinations are not working. In other words I could not type letters such as ł, ą, ę, ż, ź, ś, ć, ó and etc.. You’d be surprised how often these come up in an average sentence. Surprisingly enough, I had no such problem on Ubuntu where they worked just fine. Windows version however refused to cooperate.

I did a quick google search for “vim polish characters” and got basically nothing. Then I tried few search queries in Polish and still got little info. Then I realized I was approaching this wrong, and my issue was caused by two factors:

  1. Vim was not in a Unicode compliant mode
  2. The font I was using (Bitstream Vera Sans Mono) was not Unicode friendly

So I set out to fix this. How do we get Unicode characters to work properly in Vim on Windows? Easy, just paste the following snipped into your _vimrc:

if has("multi_byte")
     set encoding=utf-8
     setglobal fileencoding=utf-8
     set bomb
     set termencoding=iso-8859-15
     set fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8
endif

Explanation can be found in Vim Tip #246. The if statement is a safety precaution since your version of the editor may not be compiled with the multi_byte feature which is required for Unicode to work properly.

Next you need a unicode friendly font. Bitstream Vera Sans Mono did not have the right Glyphs. Neither did Lucida Sans Typwriter. However Lucida Console, Curier New and the Consolas font all worked just fine. I really can’t tell you which fonts will work and which wont. You should probably just type some interesting word like “Gżegżółka” into the editor and just try different fonts until you find the one you like. For example Bitstream Vera Sans looks like this:

Bitstream Vera Sans

On the other hand Consolas font looks like this:

Consolas

In my case I simply added the following line to _vimrc to change the font to Consolas:

set gfn=Consolas:h10:cANS

I hope that someone will find this helpful. I’m posting it under a Google friendly title in case someone else needs to figure this out they can easily find it here. For those of you who could care less about Polish characters, vim or unicode I apologize. It had to be done. Now we can return to our usual brand of craziness that you came here to read. P

My Firefox Extensions - Let Me Show You Them

Thursday, March 6th, 2008

Considering my stats, and the comment threads, I can safely say that majority of readers here use Firefox. So let’s share the best/favorite extensions out there. Here are the ones I use. You probably already know some of them, but some might be new to you - perhaps you will look through this list and find something cool that you didn’t eve know existed. I hope you share your cool choices in comments.

Adblock or Adblock Plus

Adblock is a must in this day and age. I use Adblock on my laptop and Adblock Plus on my desktop and I don’t see any real difference between the effectiveness of the two. Both have finely tuned filters built up over years of me manually killing every add banner I could find. So most sites I visit these days are add free. I usually white list some blogs which I want to support and which have unobtrusive adds though.

Adsense Notifier

This one will probably be of interest only to people who both own websites, and use Google Adsense. I simply like to be able to peek in the status-bar and know how little money this website is making each month. Thanks for clicking them add things guys!

CuteMenus Crystal SVG

This one is purely aesthetic. It adds nice Crystal SVG style icons to the rather bland Firefox menus (both pulldown and context). I usually run with the standard theme (just make the icons smaller) but this little extension makes it more lively. And there is a small usability boost here - these icons actually help you navigate by using visual cues instead of reading.

Dummy Lipsum

What do you do when you need to populate some web form with random text? Do you drum on they keyboard and type in “asdadffsdf sdf sf” or do you use some form of the Lorem Ipsum text which is typographically similar to English and has been used by typesetting industry for ages?

This extension allows me to generate a random Lorem Ipsum fragment by simply right clicking inside of a textarea or a textbox and choosing an option from the context menu. I use it constantly at work - very convenient.

Fasterfox

Allegedly it makes FF faster by doing all these about:config tweaks that people used to constantly blog about. I have been using it forever, but I never didn’t benchmarked it. I don’t know if it actually makes a difference anymore, but it doesn’t seem to be giving me any problems so meh..

Faviconize Tab

Let’s you reduce the size of selected tabs so that they only show the favicon. I use it all the time at work keeping my google reader, twitter, gmail and Terminally-Incoherent tabs nicely minimized in the corner.

Firebug

Absolutely necessary. I have no clue how people used to code Javascript stuff without it. It is extremely helpful and if you do any web design that requires you to mess around with client side code, definitely get this plugin. It saves lives.

Gmail Manager

Lets me know when I get a new email. Wordpress emails me whenever someone posts a comment here.Since I almost always have Firefox open when I’m on the computer and I’m not playing games, I get almost a live feed of what is going on here, and what you guys are saying. I don’t always have time to read and respond immediately but I know that something is up as soon as I glance in the right corner of FF. I use my Gmail account strictly for fun and socializing - so a blue email icon always lets’ me know there is some interesting email and/or blog comment to read.

Google Notebook

I use Google Notebook as sort of a permanent clipboard which persists between my desktop and laptop. I mostly use it for copying interesting quotes, URL’s or making quick todo notes. Not terribly useful but has slightly more functionality than some bookmark syncing strategy.

Greasemonkey

I used to use it more in the past, but both Firefox and web applications that I used kinda caught up by now. So at the moment the only script I have in there right now is the one that removes music from MySpace pages. Not that I browse myspace more often that like 3 times a month, but when I do I don’t want to be assailed by a cacophony of sound.

IE Tab

Let’s me open IE in a FF tab. I used to use that a lot when my work required us to enter time in a crappy IE only online app. Fortunately we no longer use that POS system. I don’t get much more use of it these days but it’s not a bad thing to have.

Image Zoom

I actually don’t know why Firefox doesn’t have this functionality by default. It let’s you zoom images either using presets, by typing in pecentage/dimensions or gradually by using right-click+scroll combo.

It’s All Text

This one puts a little button in the corner of each text-area. If you click it, it opens a text editor of your choice (vim in my case) and populates it with the text from the box. Whenever you save in the text editor, it refreshes the textarea in the browser. So not only do you get to type in your favorite editor (vim key bindings) when you blog or comment. If the browser ever crashes for whatever reason , your text will still be in the opened text editor.

Check it out. I really like this one.

Linkification

Linkify is great - it will take any URL and convert it into a clickable link. It is one of those extensions that you tend to rely on without even realizing it. You only notice how much you were using it when it’s gone.

Live HTTP Headers

This is an extension that is nice to have, but you won’t use it very often. It lets you peek at the HTTP headers in real time. Since I installed it, there were maybe 4 times that I actually needed to use it. It’s probably worth having it just for shits and giggles.

PDF Download

Prevents Adobe from opening PDF files as a browser plugin and gives me a choice of whether I want to open it using the default reader, save it to disk or try to view HTML if possible. It’s a small thing but it really makes a difference when you deal with a lot of PDF files online.

Twitterfox

There are no good Twitter clients for Linux. I was searching for something like Snitter to run on Gutsy. I failed. Instead I found Twitterfox which is the next best thing. It’s small, unobtrusive and just works - lettign me follow tweets as I work without obsessively looking at my Twitter hompeage.

That’s all I have for now. How about you guys? Do you have some cool extensions that I should know about, but I didn’t list them here? Let me know!

Using CPAN version of WWW::Mechanize with ActiveState Perl on Windows

Monday, February 25th, 2008

I end up doing this each time I reinstall windows, and every time I forget how I did it, so I figured I’ll archive the process here. Perhaps it will help some of you. And I know, someone will say why don’t you use the PPM repository. Let’s just say i don’t want to. I want to grab the latest WWW::Mechanize package from CPAN and run with it.

Why am I posting it now? Because I needed to reinstall windows once again on my desktop, and now I need to get my blackboard scrips to work again.

This is really a multi step process. I’ll assume you have perl installed already. If not, you can get Activestate Perl which works pretty well on windows. Just grab the MSI package, install it and all the useful tools including perl, cpan and ppm will land in your path. From there follow these 3 easy steps:

Step 1: Get nmake

You will need nmake - the windows version of the make utility to compile most of the CPAN packages. How do you get nmake? There are several ways to do it, but probably easiest one is to grab the Microsoft version of the tool from their knowledge base. Once you download it, dump it somewhere in your path. It doesn’t really matter where it is, but I stuck it in the bin directory of my Perl install.

Step 2: Get YAML from CPAN

You will need YAML to build WWW::Mechanize. What is YAML? Sort answer is: do you care? Long answer: look it up. All you need to know is that you need it. So run cpan from your console and type in:

install YAML

This should cause some streaming text on the screen as the package is fetched and compiled. If it fails, make sure nmake is in your path, and that it is named nmake.exe and not something else.

Step 3: Install WWW::Mechanize

Final step is the easy one - just fetch and install the WWW::Mechanize package using the traditional method:

install WWW::Mechanize

Make sure you do step 1 and 2 before you try this. If you have tried this before you installed YAML the build will fail for some reason. To avoid that, just quit cpan, and run it again. This will clear the local cache and will re-fetch the package for a clean build.

So, there you have it. I know it’s a bit of a dry and uninteresting post for Monday morning. But this is more of a reminder to myself than anything else. I never remember where to grab nmake or what is that other package without which nothing ever builds on windows. Hopefully some of you will find it helpful. )

Gutsy on Dell Latitude D830

Friday, February 1st, 2008

I got my brand new Dell Latitude D830 laptop today, and the first thing I did with it was installing Gutsy. Dell was nice enough to partition the drive for me so I didn’t have to bother with resizing. This is possibly like the single most useful service they offer in their store. Installation went very smoothly, but configuring the laptop was a bit more rocky than my recent test with Inspiron 600m

New Dell Latitude D830 On my Desk

I’m pleased to report that my Intel PRO/Wireless 3945ABG card worked out of the box without any tweaking. It is listed in the Restricted Drivers section but there was nothing I had to do to enable it. It just popped into action and that was that. I’m very happy about this. As far as I could tell everything else except for the sound card worked. Yes Aplhast, my sound card doesn’t work! I’m blaming you! You jinksed it buddy! ;P

Lshw tells me that I have an Intel 82801H (ICH8 Family) HD Audio Controller. In Ubuntu circles ICH8 is an acronym for “fucking pain in the ass”. It just doesn’t work without major tweaking. Patching and recompiling ALSA might be required. And even then it is not guaranteed that it will work at all.

But there is no way in hell I’m willing to accept “doesn’t work” without at least trying. After some googling I found two possible solutions. First one was very simple - simply add the following line to /etc/modprobe.d/alsa-base:

options snd-hda-intel probe_mask=1 model=3stack

I did just that, rebooted and found out that this doesn’t work. Of course! Why would it. Things can’t be this easy, can they? I left the line in it’s place just in case and moved to the next suggestion which was equally easy. Just install one small package and reboot.

sudo aptitude install linux-backports-modules-generic

I rebooted and heard a faint chime of KDE startup sound. It was a little bit quiet so I mashed the Volume Up button above the keyboard. Gutsy actually knew about this button, and displayed a nice overlay volume bar on my screen. I maxed out the sound, fired up Amarok and played the welcome message. It wasn’t as loud as the sounds in Windows, but for my purposes it was perfectly adequate. So yes, sound is working. All is well!

Just about everything else worked including Bluetooth. Ot at least I think it works because the LDE lights up, and KDE has a nice icon in the taskbar which tells me the MAC adress of my card. Unfortunately I do not have any bluetooth toys that I could test it with. Any suggestions for a bluetooth appliance for this laptop?

The Nvidia Quadro NVS 140M card was red in the restricted driver panel signifying that the proprietary drivers were not installed but are available. Since everything looked fine I decided to leave it be for now. I could always go back and install the driver later. So I messed around with it some more, and then decided to plop it in the place of my regular laptop.

As soon as I connected the laptop to my external monitor and hit Fn+F8 (which is the CRT/LCD switch) everything went to hell. I got incredibly colorful, psychedelic, blinking patterns on both screens and that was it. Killing the X server did nothing - this weird display corruption had to be happening at a lower level. Only thing I could do was to pull the monitor plug and REISUB.

So I figured this was the time to install the nvidia driver. So I went to K-menu, System Settings, Advanced, Restricted Drivers and installed it without ever dropping down to CLI. Neat! Naturally I needed to reboot for the new driver to go into action. Unfortunately I immediately realized that Nvidia decided to take away my Fn+F8 function. I was able to flip back and forward between LCD and CRT during the framebuffer loading screen, but as soon as X started the picture would jump back to the laptop LCD and stay there.

It took me few minutes to figure out the magical spell I needed here:

nvidia-settings

It pops up a very nice config dialog you can use to set up he multi-display stuff:

NVidia Dialog

Once I did that, everything started working just fine. Now I’m running on a beautiful 1280×1024 resolution and enjoying how incredibly fast this hardware seems compared to my old 700 Mhz junker. It is a great machine!

If you are planning to buy a machine for Linux though I would probably recommend the Dell Ubuntu line - this way you avoid the fun I had here with the sound card. And that machine comes with an integrated webcam (kinda like Apple does) which is kinda awesome. I got this one because it was supposed to be a dual boot machine and I kinda needed it to have an XP license attached to it. I’d recommend it but only if you are not afraid of getting your hands dirty messing around with the sound card. You know what… I take that back - it’s just one package and one line in alsa-base file (I don’t know which one did it, and I don’t care at thisp point) - I did the research for you so it should be easy. mrgreen

Your First Steps with Linux

Wednesday, January 30th, 2008

Over the years I think I helped to influence few people here and there to actually start experimenting with linux. I count that as a personal success. I’m sure I was not the primary influence in most cases, but I’m glad I could help people to start tinker with the new OS. Note that I didn’t say switch. I do have an issue with this whole switch mentality. People say “I have switched to Linux” or “I have switched to Mac” and I can’t help but roll my eyes.

I just want to put out there this novel idea: you are not marrying you OS. Regardless of what Microsoft may want you to think, there is no rule anywhere that says you can use only one OS. Personally I think a well rounded human being should be able to use several operating systems. Hell, you can have several OS’s installed on the same computer, and simply boot into the one that you need when necessary.

When people ask me how to go about switching to Linux I tell them not to. I tell them, to try using it along side Windows (cause it’s usually Windows folks who ask it) for a while, play and explore. Whenever it gets scary or overwhelming you just go back to comfy windows zone. Whenever you need that crucial windows application that has no Linux equivalent it will be right there for you. Don’t switch - just start playing. Have fun with it and learn. Then if you one day realize that you haven’t touched the Windows box in months, you can say you have switched. However, most of us never reach the point where they can honestly say they use linux exclusively. I don’t see it as a honor badge or anything. Most of us are perfectly content having a windows box (for gaming) sitting in the corner, a MacBook laptop, and a linux workstation all working together.

But the question does have merit. Starting with linux is usually a little bit different than starting with windows, or Apple. Why? Because this is the only OS that most people have to install by themselves. When people start messing around with Linux and BSD they usually tend to install it on a system that originally came preloaded with Windows. And this is where many issues crop up. Here are the few tips I usually pass down to the newbies. I figured that I might as well record them here and just point people to this post from now on.

Consider buying a system that comes Linux installed

Best advice I can give to total newbs is to consider purchasing a system that already comes preloaded with Linux. This is naturally the most expensive option you can pick but it does solve two main problems a lot of people run into:

First, you side-step the whole installation process. Your machine will be equipped with hardware that works well with linux, and will ship with all the right drivers. Your drive will be partitioned for you and the OS will be right there. All you need to do is go through few easy initial steps such as creating a new user and you will be ready to go. The biggest linux adoption hurdle for many people is the issue with hardware that doesn’t play well with linux. If you buy a linux machine you circumvent this whole problem.

Second, you are getting a brand new computer. This means that if you for some weird reason hose the linux installation you still have your old Windows machine to fall back on. People are often scared to try linux because they don’t want to get stuck with a botched installation and a PC that can neither boot windows or linux. You will be working on a dedicated Linux machine so even if you hose it you are still fine. You can still go online and research your issues, and try to get help.

Where do you get a machine with linux on it though? You don’t have to go to some shady online company that promises to ship you linux powered PC. You can get one from Dell. Yup, dell sells machines preloaded with everyone’s favorite distro (Ubuntu). You can say what you want about dell, but at least they are trustworthy, and usually make good on their warranties.

If you feel more adventurous, or you hate dell/large corporate behemoths you can try something like System 76 which sells laptops, desktops and mini boxen all running Ubuntu out of the box.

Consider Using A Spare Computer

If you can’t afford a brand new PC at the moment. If you are like me, you probably don’t like to throw out old computers. I usually stash them in the attic planning to one day turn them into some low powered server or something like that. I also inherit hardware from relatives and sometime even co-workers who bring me their old PC to dispose of (”here, maybe you can do something with it or scrap it for parts… If not just throw it out”). Old machines are perfect candidates for Linux test boxen for all the reasons I listed in the previous section. If you mess around with your primary PC you will be nervous, and you will worry about hosing your windows partition. If you are working with a spare junker that you really don’t care about you will be in the care-free tinkerer mode.

If you mess up, just start over. Wipe the drive and start again. That is the mindset you want to get yourself into. You are messing around and experimenting on some random machine while your data and most importantly your internet connection is safe and secure on your windows box.

Of course when you are using old hardware you may run into problems. Some of it might not be compatible, some might actually be really broken, and naturally it will be really slow. Then again, older hardware may actually be a blessing - having been around for years, the correct drivers may have made their way directly into the currently used kernel.

Use a Live CD First

This is less of a concern now since most of major distros ship with a Live CD installer these days. It wasn’t like that when I was starting. Still, probably a good first step for anyone is to download and burn yourself a Knoppix CD and stick it into the machine you plan to use for Linux. If Knoppix has major problems identifying your hardware and getting to work, then you may need to reconsider your choice. Chances are that any distro will have simillar issues, if not worse. If Knoppix just works, it doesn’t necessarily mean your distro of choice will but it is a sign that your hardware can and will work with Linux.

A lot of distros ship a Live CD installer (I know Ubuntu does) which lets you try out the system before you install it. I highly recommend burning yourself several such Live CD’s of different distributions and messing around with them. See how they interact with your hardware, how they handle driver installation and etc. Pick one that gets everything right out of the box, or has the best, most intuitive system for loading the needed drivers and applications.

Most of them will be very simillar but different people tend to be comfortable with different types of interfaces or ways of doing things. Some distros are more n00b friendly than others. Some will require you to drop down to CLI while some other ones will have nice GUI menus to do these things. You just need to find one that you feel comfortable with.

Avoid Dual Booting if Possible

Having your machine set up with both Linux and Windows is great. Dual booting is an awesome feature and you should definitely try it at one point, but it is a lousy way to start your Linux experience. It’s not that it’s hard - it’s just that it’s not trivial. In most cases it will require you to resize your windows partition (which may hose your system), then format that partition (if you choose the wrong one you may hose your system) and then make sure that the bootloader works correctly. This process has many points of failure and you don’t really want to be dealing with all this stress and uncertainty.

Most distros come with a nice “wipe the drive and let me set up the file system my way” option and that’s the one you should be using your first time around. You can fuck around with custom partition on your third or fourth installation. The first time around though your mission is to get linux onto your box with as few steps, and in it’s most default form. It’s much easier to troubleshoot a system that was installed with the default configuration rather than with a meticulously tweaked one.

Know what you want

Before you start messing around with linux you should do some research and get to know the vocabulary we all use. At he very least you should be able to differentiate between different package management systems. You want to know whether you want a Deb based system or an RPM based one. You should also look into desktop managers - look at screenshots and reviews of KDE and Gnome and see which one you like better. Try live CD’s which ship with both of them. Your first linux experience will be largely depend on whether you like or hate the desktop manager. So it’s a good idea to try both Gnome and KDE beforehand. If you hate one of them, it will narrow down the list of distros you have to choose from.

Pick the right distro

Finally, do some research into different linux distributions. You want to pick one that is newbie friendly - so probably probably not Gentoo in which you compile everything from scratch. You probably don’t want slackware either which hails itself as the most unix-like linux out there. You want something like Ubuntu, or Fedora or SuSE. You want something with a graphical installer, shipping with either Gnome or KDE out of the box and providing a nice package management front end (ideally a GUI one).

You should also pick a distro that has a large community. This helps immensely - a large community means lots of backports, frequent patches and active forums and discussion groups where you can finds answers and solutions to many of your problems. At some point a distro reaches a critical mass where nearly every problem you run into is already well documented and resolved by the community.

How do you know if a distro is popular? You will likely know it by reputation - people on technology blogs will mention it and talk about it. If you are at a loss, you can try Distrowatch which tracks the trends on Linux distribution market. Just be careful with their data - you want to pick something that is consistently popular over a long period of time, not the flavor of the month.

If you follow these few suggestions, your first steps with linux will be a positive, rewarding experience even if you mess up. You will learn a lot, you will gain new perspective on things and most importantly you will have fun.