Saturday, January 17, 2009

Turn hibernation on or off on windows vista

Needed to start using windows vista because iPod need iTunes, and Banshee, etc doesn't seem to work for me. But then, I'd shrunk my windows partition too small and so space is precious.

To turn off hibernation:
Click start > In the "start search" box, type "powercfg /hibernate off" > press "CTRL+SHIFT+Enter" (this I guess runs the command as administrator.
Now do a disk cleanup to delete the huge hibernate file.

The command for turning hibernation back on is "powercfg /hibernate on"

.

Monday, December 29, 2008

Adding something to the startup scripts.

Just penning this down because I am afraid I'm quite likely to forget !

First off, create a script in /etc/init.d/ which you want to be executed at startup.

Next, use the update-rc.d command

update-rc.d [script-name] start [seq-num] [list-of-run-levels]
[seq-num] = 0 - 99
[list-of-run-levels] = separated by space, and terminated by "."

.

Saturday, December 27, 2008

Installing 32 bit programs on 64 bit machines (.deb packages)

Was trying to install adobe reader on my ubuntu 64bit box, and came across issues with 32 bit and 64 bit. Apparently, there's this program "getlibs" which will download all required libraries that your application needs. So if you need to install an i386 deb package, first force install it

dpkg -i --force-all package-name.deb

Then get all the libraries required by the executable

getlibs /path/to/executable

Getlibs can be obtained from http://www.boundlesssupremacy.com/Cappy/getlibs/getlibs-all.deb
I gues, it should also be in the ubuntu repository. You should be able to do an

apt-get install getlibs

For more info, refer to the thread http://ubuntuforums.org/showthread.php?t=474790

.

Skype on ubuntu 64 bit

Upgraded my laptop to ubuntu 8.10 64 bit today. The Microphone works finally !!
Decided to install skype but apparently, the skype download page doesn't give a link to skype for 64 bit linux. The 32 bit version wouldn't install with gdebi ! Searched a bit online, and came across this page:
http://ubuntuforums.org/showthread.php?t=432295

The gist of the page is

sudo apt-get install ia32-libs lib32asound2 libasound2-plugins; wget -N boundlesssupremacy.com/Cappy/getlibs/getlibs-all.deb; wget -O skype-install.deb http://www.skype.com/go/getskype-linux-ubuntu-amd64; sudo dpkg -i skype-install.deb; sudo dpkg -i getlibs-all.deb; sudo getlibs -p libqtcore4 libqtgui4 bluez-alsa
NOTE: That is the procedure for 8.10. For others it may be different.

Also, I'm not sure, but I guess, this link will work:
http://www.skype.com/go/getskype-linux-ubuntu-amd64
If anyone's trying to install 64 bit skype, please download that from the above link and try installing with gdebi / dpkg. If it works, that's actually a better option I suppose. Please post a comment, if did/did-not work for you!

.

Sunday, November 23, 2008

weird bug with ctrl, alt, shift keys going haywire after running vmware on ubuntu

If I use ctrl+alt+enter to full-screen a vm in vmware, then when I return to the host, my special keys - ctrl, alt, and shift - will stop working !

The "xmodmap" command can be used to see the keycodes assigned to the modifiers. When the keys are working fine,
root@vmathew-laptop:~# xmodmap
xmodmap: up to 3 keys per modifier, (keycodes in parentheses):

shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40), Alt_R (0x71), Meta_L (0x9c)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x7f), Hyper_L (0x80)
mod5 Mode_switch (0x5d), ISO_Level3_Shift (0x7c)
Now, once I run a vm in vmware and use ctrl-alt-enter, to full-screen it, and then come back to the host (ctrl-alt), the output goes.
root@vmathew-laptop:~# xmodmap
xmodmap: up to 1 keys per modifier, (keycodes in parentheses):

shift
lock
control
mod1
mod2
mod3
mod4
mod5
The fix is to use the "setxkbmap" command. This will restore the keycodes for the modifier keys.

[Ref]
http://ubuntuforums.org/showthread.php?t=792737
http://ubuntuforums.org/showthread.php?p=4990785

.

Saturday, November 8, 2008

Remote procedure calls are SO EASY !! (XMLRPC / Python)

I just love python !
And the XMLRPC implementation for python just made me fall in love with it. (Ok, XMLRPC is language independent, but I just loved the python implementation)

A bit of context; we were discussing the paper "Implementing Remote Procedure calls" (Link), in our CS736 / Advanced Operating Systems class. I was skeptical of the whole idea since I was wondering why in the world would anyone use this, when the socket api is so neat and clean.

I was wrong !

My CS740 / Advanced Networks project mate, Ian Rae, pointed me to XMLRPC within the context of our networks project. And I realized how simple and elegant programming RPC can be.

The gist of the code is as follows:
Server:
from SimpleXMLRPCServer import SimpleXMLRPCServer

def poke(n):
print "I was poked %d times" % n
return ("dumb_server", "8000")

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(poke, "poke_the_server")
server.serve_forever()
Client:
import xmlrpclib

proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
reply = proxy.poke_the_server(3)
print "The server %s is listening on port %d" % (reply[0], reply[1])
Reference: http://docs.python.org/library/xmlrpclib.html

.

Friday, November 7, 2008

Using pipes with python.

This lists a bit of code I developed to use pipes with python
import os
import sys

def function():
r1,w1 = os.pipe()
r2,w2 = os.pipe()
if (os.fork() == 0):
# we're the child
os.close(1)
os.dup2(w2,1)
os.close(0)
os.dup2(r1,0)
sys.stdin = os.fdopen(0)
sys.stdout = os.fdopen(1,'w')
os.execl("/bin/bash")
else:
# we're the parent
to_child = os.fdopen(w1,'w')
from_child = os.fdopen(r2)
to_child.write("ls\n")
to_child.flush()
to_child.write("echo hi\n")
to_child.flush()
temp = from_child.readline()
while temp:
print temp
temp = from_child.readline()

function()
The only problem with this code at the moment is, I don't know how to get readline() to return when there's nothing to read. In short, we always end up hanging!

A much simpler way to achieve the effect of the above would be to use the popen3 function.
>>> import os
>>> i,o,u = os.popen3("/bin/bash")
>>> i.write ("ls\n")
>>> i.flush()
>>> o.readline()
'bin\n'
>>> o.readline()
'Desktop\n'
>>> o.readline()
'Documents\n'
>>> o.readline()
'mounting-vmdk.pdf\n'
>>> o.readline()
'order-cardbus-to-express.pdf\n'
>>> o.readline()
'public_html\n'
>>> o.readline()
'vmware\n'
>>> o.readline()
# at this point, again we hung !!
The problem with readline hanging still exists, but the code's much simpler

.

Mouting partitions with losetup

References (previous posts):
Virtual Drives on Linux
Playing with mount and loopback devices
Encrypted Filesystems

One issue I faced with using loopback devices to mount hard disk images was that everything works fine as long as you have the disk image as one single filesystem. But if you use fdisk on the loop back device and created partitions, then I could not quite figure out a way to mount these.

One intuitive way to do this would be as described in http://vytautas.jakutis.lt/node/26 . In brief, what they do is:
# rmmod loop
# modprobe loop max_part=63
# losetup -f /path/to/your/disk/image.raw
# mount /dev/loop0p1 /mnt/path
Unfortunately, that doesn't work for me. The max_part=63 parameter is rejected by modprobe for me. Guess something else needs to be enabled/compiled-into my kernel for me to support this. (My kernel qualifies by the version info they give there, though)

But then, there's a simpler option. One can specify an offset in the file where the loop back device should begin. From what I've gathered, the first sector, sector 0 in a disk contains the partition table I guess. And then, the first partition starts at sector 1, and ends at sector n. The next from n+1 to n+m and so on.

So if we specify the start sector's byte offset (start_sector * 512 normally) as the offset for the loop back device, we can access the particular partition.
Reference: http://www.docunext.com/blog/2007/07/08/losetup-working-with-raw-disk-images/

So say if we have a disk image data.raw, ( say we used qemu_img to create this from a vmware vmdk disk) then we can attach the whole disk to a loop device and run fdisk to get the start sector of the partition
vmathew:/data/vmathew/vmware/dsl # losetup /dev/loop0 data.raw
vmathew:/data/vmathew/vmware/dsl # fdisk /dev/loop0

Command (m for help): p

Disk /dev/loop0: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb96bb154

Device Boot Start End Blocks Id System
/dev/loop0p1 1 63 506016 83 Linux
/dev/loop0p2 64 130 538177+ 83 Linux

Command (m for help):
But note here that the units displayed is cylinders. Our second partition starts at cylinder 64, but we don't know the exact sector. To find this information
Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/loop0: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xb96bb154

Device Boot Start End Blocks Id System
/dev/loop0p1 63 1012094 506016 83 Linux
/dev/loop0p2 1012095 2088449 538177+ 83 Linux

Command (m for help):
Now we quit the fdisk tool. We have our start sector = 1012095. So our start offset = 1012095*512 = 518192640. Thus to mount this file, we first detach the loopback and create it at this offset, and then just mount it.
Command (m for help): q

vmathew:/data/vmathew/vmware/dsl # losetup -d /dev/loop0
vmathew:/data/vmathew/vmware/dsl # losetup --offset 518192640 /dev/loop0 data.raw
vmathew:/data/vmathew/vmware/dsl # mount -t ext3 /dev/loop0 temp/
vmathew:/data/vmathew/vmware/dsl # ls temp/
jklh.txt lost+found
vmathew:/data/vmathew/vmware/dsl #
Additionally, checkout the manpage on qemu-img (you need qemu installed) to learn to use this gorgeous converter which can convert between some standard disk image types.

.

Tuesday, November 4, 2008

Merging PDF files

This was something I used hit a dead end on quite often.
Now that I found it, I'm posting it here..

It's basically ghostscript to the rescue
gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf ...
Source (yeah, I'm "plagiarizing" !! )
http://ansuz.sooke.bc.ca/software/pdf-append.php

.

Thursday, October 16, 2008

Damn Small Linux

This one's more of a rambling.
For use with condor, I have to setup a small virtual machine with linux on it..
So I'm choosing DSL and my experiences are being blogged down here.

The first issue I faced was installing DSL to disk.
To do this
1. right click on the desktop
2. choose Apps > Tools > Install to hard drive.
Note: install to hard drive may fail if your VM doesn't have plenty of memory. So start up the VM with say 320 MB or more of memory, do the hard disk install and then cut back on memory to say 64MB.

The next issue was setting up the VM so that ssh access is enabled at startup
To do this
update-rc.d ssh defaults 20
The third issue was how to install more packages in dsl
This can be done using the MyDSL extensions to DSL
http://www.ibiblio.org/pub/Linux/distributions/damnsmall/mydsl/
http://distro.ibiblio.org/pub/linux/distributions/damnsmall/mydsl/

.

Thursday, July 24, 2008

Free man's recipie (Open source alternatives for common windows programs)

Bought an Acer Extensa 4620Z laptop for my mother a few days back. My mom's used to windows, and so I had to get her a genuine copy of Microsoft Windows XP Home Edition. However, that's the only piece of software I bought by paying money. Everything elese, I have freeware alternatives..

Here's the list

1. ImgBurn: http://www.imgburn.com/
This's a freeware (not open source) CD/DVD writing tool that supports all usual features. And guess what, it's extremely lightweight. The install file size is just 1.84 MB !!
Advantages:
- supports normal CD/DVD writing, erasing, creating and burning images etc.
- can be used with rewritable discs.
Disadvantages:
- presently does not support multi-session.

2. OpenOffice: http://www.openoffice.org/
A free and opensource alternative for Microsoft Office and numerous other office suites.
- has feature parity with most of microsoft office. Not yet a match for the latest versions of office, but fits the bill for ALL normal usage one can anticipate.
- supports microsoft office document formats as well as a much more compressed native document format.
- supports exporting documents directly to pdf.

3. Mplayer: http://www.mplayerhq.hu/
free and opensource. The media player that truly plays anything.
I found support for all formats that I could think of ! Even windows proprietary codecs are supported by wrapping over the dlls.
And the best part is the numerous keyboard shortcuts ( Link ) The player allows syncing audio and video even when the original file's in error, subtitles, advanced seek capabilities, frame by frame advance, playlists and almost everything you will ever need.
I rate this software better than ALL other media players, whether opensource/free/proprietory.

4. Firefox: http://www.mozilla.com/firefox/
free and opensource. They call it the fastest browser on earth. I'd say, it's the best browser on earth. It's fast, extremely light weithgt, fully standard compliant, and feature packed. Even windoze internut exploder wouldn't come close to it.. Only, there are moron website administrators who still build websites with windows proprietory widgets which only work with the nut exploder. That aside, you will never need another browser if you have Firefox !
That firefox is the most favored browser among techie community says it all !

5. IZArc: http://www.izarc.org/
A free archiving (.zip, .tar.gz, .rar, .cab etc) software. It supports a much more broad spectrum of formats than winzip and others. And its perfectly free, there's not even an optional registration unlike with winzip. And I'ven't used another archiving software other than this, within a windows environment, for the past 5 years..

6. AVG Antivirus: http://free.avg.com/
free for personal use. If you run windows and you're sane enough, then you better have an antivirus. And AVG suits one's normal antivirus requirements.. And it's FREE.
Recently, this free factor has increased AVG's popularity greatly. I know a lot of people who run AVG free edition. And when an antivirus gets to be more popular, it's list of know viruses also becomes more exhaustive :)

7. Mozilla Thunderbird: http://www.mozilla.com/thunderbird/
free and opensource. Thunderbird is a very good email and usenet client. And with the lightning (http://www.mozilla.org/projects/calendar/lightning/)plugin, it supports a calendar too ! Forget outlook and such fancies..

8. PDF Creator: http://www.pdfforge.org/, http://sourceforge.net/projects/pdfcreator/
free and opensource. Adobe PDF (.pdf files) is the best portable format for carrying documents. Almost every platform supports it. It's presentation is in a print-format. And once created, it is viewed in a viewer program like acrobat and hence will not be modified accidentally.
But how does one create pdfs?
With PDFCreator, a (simulated) printer gets installed onto your computer, and whatever you print to that printer is saved as a pdf file. So "if it can be printed, it can be made into a pdf" !!

.

Thursday, July 10, 2008

And the dictionary talks !

By now I have made dictionary.com my default dictionary. It's good, and gives most information I require.

Today, I also realized that it includes a recording for the word's pronunciation too.

I mean, the last I checked the little speaker icon next to the word was when I used to use windoze, and at that time I don't remember it working. (guess it was a premium service)

But today, I clicked on the speaker icon out of some un-fathomable curiosity, and it worked !!

Other lovely aspects of the dictionary:
- firefox search engine plugin available.
Hence search is just a CTRL-T + TAB + a few CTRL-arrow_keys away.
- Companion sites: encyclopedia, thesaurus etc.

.

Wednesday, June 25, 2008

NVIDIA and ATI on openSUSE 11.0

Sorry, this one's mostly a rambling bucket of links and a newsgroup post replicated.
Subject: NVIDIA and ATI on openSUSE 11.0
From: houghi
Date: Wed, 18 Jun 2008 20:34:23 +0530
Newsgroup: alt.os.linux.suse

With the coming of 11.0 juste hours away now, many people will be asking
on how to install NVIDEA and ATI.

This is the posting that explains it all.

The URL with the information
http://dev.compiz-fusion.org/~cyberorg/2008/06/13/getting-nvidia-and-ati-drivers-on-opensuse-110/

The text version:
ATI drivers 1-click-install : http://opensuse-community.org/ati.ymp
NVIDEA drivers 1-click-install : http://opensuse-community.org/nvidia.ymp

Via the command line:
su -c "OCICLI http://opensuse-community.org/ati.ymp"
su -c "OCICLI http://opensuse-community.org/nvidia.ymp"
This also shows on how to use the _OneClickInstall_on_CLI_

Another via cli:
zypper sa http://download.nvidia.com/opensuse/11.0 nvidia
zypper in x11-video-nvidiaG01

zypper sa http://www2.ati.com/suse/11.0 ati
zypper in x11-video-fglrxG01

No manual configuration of xorg.conf or switching on Xgl required to get
compiz goodness, just launch simple-ccsm and enable compiz from there
after installing the drivers.

Missing window titles on compiz:
http://forums.suselinuxsupport.de/index.php?showtopic=61418

openSUSE XGL page:
http://en.opensuse.org/Xgl

An appeal for open drivers for linux
http://uk.news.yahoo.com/vdunet/20080623/ttc-linux-developers-push-for-open-drive-6315470.html

My experiments with compiz (failed):
http://varghese85-cs.blogspot.com/2008/06/compiz-on-thinkpad-t43-using-opensuse.html

.

Some good way to search

Search this string:

-inurl:(htm|html|php) intitle:"index of" +"last modified" +"parent directory" +description +size +(wma|mp3) "Nirvana"

What it basically does is to find file listings of type wma or mp3 for Nirvana songs. One can modify it to search for any particular file one might want to find on ftp servers and that sort.

Source: http://www.employees.org/~smitha/myblog/?q=node/46

.