Inspirated

 
 

March 31, 2009

The joys of Conspire

Filed under: Blog — krkhan @ 1:54 pm
<Aerdan> that's essentially what SoC is doing, tbh; offering students a 500 bribe to contribute.
<nenolod> 500?
<nenolod> no
<nenolod> it's 4500
<Aerdan> ah, the joys of Conspire
<Aerdan> that was $4500 before Conspire ate it. :D
<krkhan> how does conspire eat 000
<krkhan> oh :P
Tags: ,

March 29, 2009

wmartagu: Viewer/editor for WMA metadata info

Filed under: Blog — krkhan @ 11:05 am

As part of a Google Summer of Code application challenge, I was required to code an application for which the check-list was:

  • Accepts 1 WMA file name on the command line
  • Accepts -a for artist
  • Accepts -t for title
  • Removes the current tag from a WMA
  • Writes a new tag to the WMA file containing the new artist & title

And the bonus points:

  • The program does not obliterate the existing tag but merges the new information
  • The program is robust and does not destroy any of the test WMA files
  • The program does not emit any compile warnings during build
  • The program is UTF-8 clean

Consulting the ASF specification, my first attempt to code the application resulted in wmartag.c. However, since the last bonus point wasn’t present in the list at the time, the program didn’t support UTF-8 (and used hand-tweaked dirty functions for converting between ASCII and low-endian UTF-16). After I found out about the bonus goal, I reimplemented the program from scratch and renamed it to wmartagu. The new code relies on GLib for character code conversions which really does work like a charm:

[krkhan@orthanc wmartagu]$ make

make wmartagu
make[1]: Entering directory `/home/krkhan/Desktop/wmartagu’
cc -Wall -g `pkg-config –cflags –libs glib-2.0` wmartagu.c -o wmartagu
make[1]: Leaving directory `/home/krkhan/Desktop/wmartagu’

[krkhan@orthanc wmartagu]$ ./wmartagu O\ Fortuna.wma

Title: O Fortuna
Author: Carl Orff

Copyright:
Description:
Rating:

[krkhan@orthanc wmartagu]$ ./wmartagu -t ɹǝqɯǝʇdǝs O\ Fortuna.wma

Title: ɹǝqɯǝʇdǝs
Author: Carl Orff

Copyright:
Description:
Rating:
Tags updated successfully.

[krkhan@orthanc wmartagu]$ mplayer -v -v -v O\ Fortuna.wma

MPlayer SVN-r28461-4.3.2 (C) 2000-2009 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz (Family: 6, Model: 15, Stepping: 2)

Playing O Fortuna.wma.
ASF file format detected.
[asfheader] Audio stream found, -aid 1
Clip info:
name: ɹǝqɯǝʇdǝs
author: Carl Orff

===================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24002->176400)
Selected audio codec: [ffwmav2] afm: ffmpeg (DivX audio v2 (FFmpeg))
===================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback…
A: 3.3 (03.3) of 153.0 (02:33.0) 0.4%

MPlayer interrupted by signal 2 in module: play_audio
A: 3.3 (03.3) of 153.0 (02:33.0) 0.4%
Exiting… (Quit)

This does not go without saying that if you do try to tackle the UTF character encodings without using any libraries, may God have mercy on your soul, because Unicode won’t. Also, “wmartagu” simply means “WMA Artist/Title Tagger with UTF-8 support” and does not — as it would lead one to otherwise assume — represent any noble African philosophy such as Ubuntu.

Tags: , , , , , , , , , , , , , , ,

March 19, 2009

Video: The Centenary Rant — X11tasy

Filed under: Blog — krkhan @ 7:10 pm

The 100th post, and considering that the most popular ones on the blog so far have been screencasts, there wouldn’t have been a better way to commemorate the occasion than editing a short music-video which would demonstrate the prowess of Linux on desktop.

Tags: , , , , , , , , , ,

March 15, 2009

HOWTO: Use USB devices in Virtual Machine Manager with QEMU

Filed under: Blog — krkhan @ 3:09 pm

Every once a while, I need to take the backup of my Nokia N72 using PC Suite. Since the task had to be performed on Windows, I expected my virtualized machine to be able to do so. Unfortunately, Virtual Machine Manager does not provide any option in its interface which would allow me to use my USB devices in virtualized machines. Going through the documentation though, here’s the method through which I was able to solve my issue.

First of all, you should have the vendor and product ID’s of the USB device you want to use. Sounds alien? Use the command:

[user@host ~]$ lsusb

Which will show you something like:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 0421:04c4 Nokia Mobile Phones
Bus 003 Device 002: ID 09da:000a A4 Tech Co., Ltd Port Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The bold numbers in the line containing “Nokia Mobile Phones” are the vendor and product IDs respectively. Once you’ve noted them down for your required device (in my case: 0x421 and 0x4c4), list the virtual machines’ configuration files:

[user@host ~]$ sudo ls /etc/libvirt/qemu

networks windoze.xml

My virtual machine was named “windoze”, so windoze.xml is the file that I need to edit:

[user@host ~]$ sudo gedit /etc/libvirt/qemu/windoze.xml

In the editor, add the highlighted hostdev lines under the devices section (replacing the vendor and product IDs with the ones noted down from lsusb output):

<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<hostdev mode='subsystem' type='usb'>
<source>
<vendor id='0x0421' />
<product id='0x04c4' />
</source>
</hostdev>

Save and close the file. Restart the service:

[user@host ~]$ sudo service libvirtd restart

If everything went smoothly, the USB device should now be accessible from within the virtual machine:

Screenshot of Nokia PC Suite connected to a USB device in virtualized Windows
(Click on the thumbnail for larger version.)

Tags: , , , , , , , , , , , ,

March 9, 2009

HOWTO: Access Windows machines by their names on Eee PC

Filed under: Blog — krkhan @ 8:25 pm

More often than not, Linux users will end up in a situation where they’d need to access their Windows neighbors on LAN. This can easily be accomplished using IP addresses, but using NetBIOS names is just too convenient to be overlooked.

The Xandros distro on Asus’ Eee PC does not resolve NetBIOS names by default. To make it perform that, you can do the following:

[user@host ~]$ sudo apt-get install samba samba-common smbclient winbind
[user@host ~]$ sudo kwrite /etc/nsswitch.conf

Once the editor opens, spot the line:

hosts: files dns

And append “wins” at its end, making it:

hosts: files dns wins

Save the file, exit the text-editor, back on command-line:

[user@host ~]$ sudo /etc/init.d/samba start
[user@host ~]$ sudo /etc/init.d/networking restart

Reconnect your network, and viola — easy peasy, Eee PC!

Screenshot of Eee PC accessing a Windows PC on LAN by name
(Click on the thumbnail for larger version.)

Tags: , , , , , , , , , , ,

March 6, 2009

Using Cisco Packet Tracer on Linux

Filed under: Blog — krkhan @ 6:15 pm

(Or: Using Wine where plain-water should have been more than enough.)

Packet Tracer is a network simulator for Cisco devices. Caveat: It runs only on Windoze. Hence, there are three possible solutions for someone in need of using Cisco simulation on Linux:

  • Wine: Wine’s setup varies from distribution to distribution. If you’re using Ubuntu, following commands should do the trick:
    [user@host ~]$ sudo apt-get install wine
    [user@host ~]$ winecfg

    Alternatively, for Fedora/RHEL/CentOS, use:

    [user@host ~]$ sudo yum install wine
    [user@host ~]$ winecfg

    Followed by:

    [user@host ~]$ wine /path/to/PacketTracerSetup.exe

    Once installed, you end up with:

    Screenshot of Packet Tracer running in Wine
    (Click on the thumbnail for larger version.)

    Pretty much usable. Although, fonts appear hideously ugly on default settings. Fortunately, you can change their sizes by going to Options >> Preferences >> Fonts from the Main Menu.

  • GNS3: Setting up this particular piece of software is considerably difficult and definitely an overkill for newbies. This blog attempts to bridge the difficulty by providing video tutorials for installation, but that does not make GNS3 any lesser intimidating for users not already familiar with Cisco terminology or network simulation. For example, you’ll have to scavenge the Internet for IOS images you want to use, something you’d never have to think about in Packet Tracer for its supported devices.
  • Pursue Cisco to release Packet Tracer on Linux: I was a bit surprised when I spotted that Packet Tracer is actually based on the cross-platform Qt GUI toolkit which would make porting it to Linux a trivial task for developers. Regrettably, knocking some sense in Cisco execs’ head is likely to be a far more laborious task than either of the solutions before.

“Sparrows who emulate peacocks are likely to break a thigh.” — Burmese Proverb Some geek Buddha annoyed at the trend of software developers relying on emulation for portability

Update: Cisco had after all started providing a native Linux version of Packet Tracer since last summer which I somehow missed because of its lack of appearances in my initial Google search. Here are the download links:

Fedora RPM: Rapidshare Part 1, Rapidshare Part 2
Debian/Ubuntu Installer: Rapidshare Part 1, Rapidshare Part 2
Linux Addons: Rapidshare

Tags: , , , , , , , , , , ,

March 1, 2009

Top Five Improved Open-Source Projects

Filed under: Blog — krkhan @ 3:55 pm

“Evolution is God’s way of issuing upgrades.”

It’s a wonderful age to live in as an open-source enthusiast. The warm feeling is especially accentuated in one’s mind after recalling countless hours of hair-pulling trying to make that goddamned VGA monitor work with Red Hat Linux 6. Software for GNU/Linux has improved at an exponential rate. There are still plenty which lack the user-friendliness and all, but technologically the overall rate of improvement has been nothing short of astounding.

Ask any newcomer to the GNU/Linux world about their favorite open-source projects, and there’s a strong likelihood that the answer will be one of the “prominent big-guns”; the likes of Compiz Fusion, Firefox, KDE or Gnome. Ask any veteran the same question and you’re much more likely to get a diverse stock of answers ranging from Vim to Anjuta or probably even some obscure Window Manager like Fluxbox. The opinion about the most “improved” projects would thus be highly polarizing. Still and all, there are few projects which have eased my life substantially with their progress. To compliment the ones that have almost made me kiss virtual bits of code at one point or other, I’ve decided to choose the top five:

  1. recordMyDesktop
    The Dark Ages: Recording a video of an X session was nothing less than a nightmare. With sound, all the more so. The popular method was to run a VNC server and then use a tool such as vnc2swf to capture the footage.
    The Messiah: Once you install recordMyDesktop and one of its GUI frontends, recording becomes as easy as launching it and selecting “Record”. Really, you don’t have to use multiple software now for doing something as simple as that.

  2. NetworkManager
    The Dark Ages: You went to your workplace, geared up your Linux distribution and tried get some connectivity and to your utter horror, the Wireless network used WPA encryption for passphrase. wpa_supplicant was the command-line utility you could’ve used for connecting to such networks after hours of tinkering around, but it sadly wouldn’t have prevented you from getting fired because the execs weren’t that much amicable with open-source evangelism in the first place.
    The Messiah: Red Hat, for all the criticisms it receives for RHEL, is still the caring patron figure for desperate Linux users crying out for help. Hence, it’s no co-incidence that this project as well as next two on the list were initiated by the same company. NetworkManager makes mobile connectivity as peachy as it could’ve been. You spend a few days with NM on your notebook and it starts choosing the best network for you wherever you go, that too with least possible intrusion in your workflow.

  3. SELinux Troubleshooter
    The Dark Ages: In this particular case, the dark ages don’t belong to that much a distant past since the cause of all the mess was also a recent innovation. Security Enhanced Linux, while obstinately preached by Red Hat and enabled by default on its shipped operating systems, was unanimously loathed by all system administrators who had at one point or other given up their hopes and had disabled it completely on their networks. The error messages it churned out on regular bases were not only cryptic, but also critically hampered regular everyday usage of their host operating systems.
    The Messiah: With improved default policies, the situation was somewhat resolved for general user. Nevertheless, irregularities still kept popping up occasionally and hence came SELinux Troubleshooter to the rescue. For every cryptic denial that SELinux now pops up, the Troubleshooter will analyze it and even suggest workarounds for them so that you don’t have to manually mess with policy modules every time something perfectly legitimate starts getting labeled as “unauthorized” access.

  4. PulseAudio
    The Dark Ages: The music player was playing a song and you tried having a voice-call or playing another video = epic fail. The audio device was usable by only one application at a time. In fact, sound was the Achilles’ heel for default setups of pretty much every Linux distribution that existed.
    The Messiah: Playing a soundtrack in one application with volume tuned to max and having a video run in another with volume at half is no longer a fantasy. And no, ESD doesn’t even come close to PulseAudio in “seamless” multiplexing of such sounds. If you want more, Pulse can combine multiple soundcards into one and also — hold your breath — redirect audio streams to different hardware on the fly.

  5. TrueCrypt
    The Dark Ages: Disk encryption had been an ultra-geek thing for quite a while, especially on Linux. Software that provided such features needed to have modules compiled manually and loaded into the running kernel which opened up a whole plethora of compatibility issues which almost always made newcomers decide against the whole idea per se.
    The Messiah: God bless the developer who had the idea of using FUSE in TrueCrypt for mounting encrypted containers. As a consequence, once a user has installed TrueCrypt, the whole thing doesn’t need to be recompiled again from time to time with updated kernels. Also, thanks to wxWidgets, the GUI has drastically improved too; making it easier for even Linux newbies to utilize disk encryption.

Fortunately, unlike commercial operating systems, GNU/Linux users don’t have to wait for decades before seeing actual new “innovations” in action. Who knows, maybe next year we’ll have LOLPython topping my list. Anything’s probable.

Tags: , , , , , , , , , , ,