Archive for the 'howto' Category

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

Installing AUCTex with EmacsW32

Tuesday, December 18th, 2007

Here is part two of my quest to make Emacs my default LaTex IDE on both windows and Linux. Installation and configuration of Emacs and the LaTex add-on AUCTex on Ubuntu was surprisingly easy and uneventful. On windows however I ran into little bit more difficulty.

Of course I could download the precompiled Emacs + AUCTex bundle from the AUCTex website but I wasn’t really thrilled about that. You see, I was already had a nice copy of Emacs on my system - on windows I’m using EmacsW32. What is the difference you ask?

Well, EmacsW32 comes with a nice MSI installer that adds all sorts of registry hooks that make it act as a first class Windows application. It also makes the GUI look more polished and native. I prefer it to other ways of getting Emacs on windows because I get an up to date binaries that work right out of the box.

AUCTex unfortunately does not ship binaries you could just “plug” into place so I had to download the sources and compile them. Compiling? From Source? On windows? Yup, that’s what I said. I can sees shock and disgust sweeping all over your faces. Before you run away let me assure you it’s easy as pie. Well, at least it was for me.

You will need a working copy of gcc and make. How do you get them on Windows? You could always get the MSYS from MinGW. Since I didn’t have MSYS but had a working Cygwin installation I used that. I simply pulled up my cygwin bash sell and did:

$ ./configure	--prefix='c:/Program Files/Emacs/emacs/' 
		--with-texmf-dir='c:/Program Files/MiKTeX 2.5' 
		--with-lispdir='c:/Program Files/Emacs/site-lisp'
$ make
$ make install

You may want to tweak the parameters for the configure script with appropriate paths. As you can see I’m using MiKTeX 2.5 on my machine. If you are using something else, you should probably change that line. Also, if you are not using EmacsW32 then you might need to change the –prefix and –with-lispdir lines to point them to your emacs installation directory. If you get an error, tweak the parameter or download dependencies and try again.

I really had no dependency problems or anything but I don’t remember what exactly did I have in my Cygwin install. It’s possible that you may need to download a package or two like maybe the cygwin Emacs version. Before you ask - I don’t use the cygwin version of Emacs because I don’t feel like running a full instance of X server for the GUI. Besides, EmacsW32 is much more responsive being that it is a native app and all.

Note that I’m using the Windows path notation with inverted searator specifying the drive as c:/ instead of the cygwin notation /cygdrive/c/. Your cygwin installation should be able to map C:/ to /cygdrive/c/. If not you may need to adjust this. If you installed your cygwin in C:\ instead of C:\cygwin then you can just use / to indicate the root drive. This is actually the “smart” way to use cygwin - Steve Yagge says so, and when Steve says something you better listen and take fucking notes.

The make install command should seamlessly slip AUCTex files into your EmacsW32 directory. Unfortunately, you will need to configure your emacs manually to use them. How to do this?

Open up your C:\Program Files\Emacs\site-lisp directory and edit site-start.el file. Add the following lines somewhere:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(require 'tex-mik)
(eval-after-load 'info
       '(add-to-list 'Info-directory-list "c:/Program Files/Emacs/share/info"))
(setq TeX-auto-save t)
(setq TeX-parse-self t)

I actually got this snippet from Oliver Sturm who figured this configuration before me.

When I tried to use the inline preview feature of AUCTex it did not work for me. It game me some odd message saying that “gs” is not a recognized command or something like that. It turns out that it was right. On windws the default ghostscript binary is not called gs but gswin32c.exe. You will need to change this - simply open some LaTex file, pull down the Preview menu, go to Customize and find the GS Command option. Set it to: C:\Program Files\gs\gs8.54\bin\gswin32c.exe. Make sure you are not using the C:\Program Files\Ghostgum\gsview\gsview32.exe binary. That is the default windows DVI viewer which ships with Ghostscript and many people confuse the two.

All that was left was to add a command to convert the DVI files into PDF. AUCTex already ships with a DVI to PS script under Command called FILE (yeah, go figure why they called it that). I simply added the following to my .emacs:

(eval-after-load "tex"
  '(add-to-list 'TeX-command-list
                '("DVI to PDF" "dvipdfm %d" TeX-run-command t t) t))

This will add a DVI to PDF option in the Command menu which will let you generate pdf files.

So, was this really hard? I thought it was a piece of cake, compared to for example setting up that nethack server.

Happy Emacsing everyone!

The Only Way to Browse Myspace

Friday, November 23rd, 2007

I said it before, and I’ll say it again. MySpace is the new Geocities. It’s the place where everyone takes their first steps in web design, creating very shitty looking pages. The default layout is a revolting abomination built with few dozen levels of improperly nested tables. I once plugged it into the W3C HTML validator, and I shit you not, it punched me in the face for sending it such mangled code. To add insult to injury the popular thing nowadays is for users to inject malformed CSS into the body of their profile producing the ugliest shit on earth. It seems that chief MySpace design rule is: if you can read the text without highlighting it, it’s not done yet.

For some inexplicable reason most MySpace users absolutely love, ugly, cluttered, unreadable profiles. You can whine and complain but they are not going to listen. Ugly ass myspace pages that hurt your eyes, and provoke cause nausea and are here to stay. But there is a solution. There is a way to browse myspace without subjecting yourself to the shitty layouts and musing. There are two things you need to accomplish this:

  1. Firefox
  2. Greasemonkey

One thing that I hate more than the shitty page layouts is shitty music blaring at me from a page with a shitty layout. Auto-play is fucking inconsiderate, annoying and evil. And of course it is the default for MySpace media player. This is why I use the Automatic MySpace Media Remover script. It disables the flash media player by default, and replaces it with a placeholder. You can bring it back by clicking on it.

Then there is the matter of ugly ass layouts. We can make them go away with greasemonkey as well. Personally, I use the Custom Layout Dis/Enable which actually gives you a button in the upper right corner that you can hit to strip the site out of layout. If you don’t like it, there are several other similar scripts like this one, or even this one.

Now, if I could only have a Stupidity Filter script or plugin, MySpace would actually be a nice website to visit. )

Windows: Change Your Default Telnet Handler

Wednesday, November 21st, 2007

At this point I see basically two legitimate uses for telnet: mud’s and nethack. While both forms of entertainment are still popular, they are far from mainstream even in the geekier circles. They have mostly niche audiences, and general public has little or no use for telnet these days. You really do want to use ssh for any kind of remote shell stuff. This is evidenced by Microsoft disabling the telnet client by default in Vista. So the only remaining use for the tool is simply poking around by connecting to random ports. These days I mostly use telnet to see if I can access an email server from a remote location by telnetting to port 110 or 25. But then again, I could also use netcat for that with pretty much the same results.

As you may or may not know, I set up my own little public nethack server that can be found by telneting to luke.kicks-ass.org. And since for some reason he output is a bit garbled in the default windows client, I sought out replacement. PuTTY is probably on of the better free, open telnet clients for windows out there. There is simply not much competition on that market anyway, because the basic windows client is not that bad. Still, I find PuTTY superior.

The problem is, by default handling telnet links such as telnet://luke.kicks-ass.og is by default hard wired to the windows client. Therefore if I wanted to use PuTTY I had to manually open it, and type in the server address instead of just clicking on the link. I decided to change this behavior, and set PuTTY to be my default telnet handler from now on.

How to do it? You can use the little registry hack below:

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\telnet\shell\open\command]
@="\"C:\\Program Files\\PuTTY\\putty.exe\" %1

Copy the code snippet, paste it into your favorite text editor and save it as a .reg file. Then double click it to run it. From now on, telnet links should open in putty, as long as you have it installed in C:\Program Files\PuTTY. If you want to change it back to the windows client, here is a snippet to reverse it:

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\telnet\shell\open\command]
@="rundll32.exe url.dll,TelnetProtocolHandler %l

Enjoy!

Btw, can you think about other legitimate uses of telnet, that would not be appropriate for ssh or other tools? Let me know in the comments.