Wednesday, July 29, 2015

Screen video GIF

Use this software - LICEcap from
http://www.cockos.com/licecap/
to get a video screen capture of a portion of your screen and save in a GIF file.

.

Friday, January 9, 2015

Keeping a web page out of the cache

Recently I started maintaining a server for internal testing at work. This hosts, among other things, many web pages that we often modify.

Trying to make sure that we can modify the page and not have to wait an ungodly amount of time before the page goes out of the server's cache (not the client side browser cache) thereby now showing our changes, turned out to be a problem.

The solution we finally figured out was to add these meta tags to the head of the HTML.

<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Web Page Title< /title>
</head>
<body>
...
</body>
</html>
And while on the subject of Meta Tags, here's a meta tag to force the newer IE compatibility mode on a web page:
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
.


Thursday, July 28, 2011

Playing DVDs etc on Ubuntu 11.04

Step 1. Open a Terminal Window
Step 2. Type sudo apt-get install ubuntu-restricted-extras
Step 3. Type sudo /usr/share/doc/libdvdread4/install-css.sh

.

Thursday, November 18, 2010

Merging / putting together pdf files using ghostscript / gs on linux

------------------------- update : 04/16/2011 --------------------
install the pdftk package and use the following command
pdftk *.pdf cat output onelargepdfile.pdf

------------------------------------ original -----------------------------

Have always needed to stitch pdf files one after the other to make a big pdf file.

Searched online and came up with this solution which uses ghostscript / gs
http://www.linux.com/archive/feed/36815


To use Ghostscript to combine PDF files, type something like the following:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf ...

Unless you're very familiar with Ghostscript, that string of commands won't mean much to you. Here's a quick breakdown:

    * gs -- starts the Ghostscript program
    * -dBATCH -- once Ghostscript processes the PDF files, it should exit. If you don't include this option, Ghostscript will just keep running
    * -dNOPAUSE -- forces Ghostscript to process each page without pausing for user interaction
    * -q -- stops Ghostscript from displaying messages while it works
    * -sDEVICE=pdfwrite -- tells Ghostscript to use its built-in PDF writer to process the files
    * -sOutputFile=finished.pdf -- tells Ghostscript to save the combined PDF file with the name that you specified

.

Saturday, August 7, 2010

Getting the best of Gnome and Ubuntu Netbook Edition !

Buying an Asus EeePC tablet has been on my head for a while. And just recently I ordered one on Amazon, the Asus Eee PC T101MT-EU17-BK 10.1-Inch Convertible Tablet. And then the big question arises, what software do I use on the tablet?

The tablet comes with Windows7, and I'm paying Microsoft tax, because there's no government to protect the mavericks and the geeks. But yet, I obviously don't intend to use the windows since it's a bloated piece of useless software. So then, what are my choices?

I have become an Ubuntu fan by now. But then, there again is the big question whether to use Gnome, or the new Ubuntu Netbook Edition. To answer this question, I did a considerable bit of fooling around with a virtual box vm running the UNE. And finally I decided, I like the netbook launcher which gives a desktop background from which to launch applications, and I also like the start-maximized feature for netbooks. However, the panel on the Netbook remix is substantially crap and I'd rather have my Gnome panels, one on top and one on the bottom so that I won't have accessibility issues with a close button at one of the extreme corners being touch-inaccessible with my finger.

So, my final verdict. Install the Ubuntu desktop edition. Especially if your netbook supports 64 bit, which I believe the Asus tablet does, then the UNE is a disadvantage because it doesn't yet have a 64bit edition. Once the Desktop edition is installed,
sudo apt-get install netbook-launcher
sudo apt-get install maximus
The former is the Netbook launcher program, and the latter is the maximus daemon which maximizes and undercorates the windows when opened.

Once these are installed, they can be added to the system startup via the panels
System->Preferences->Startup Applications

Also if maximus does not undecorate the window when maximising, run
gconf-editor
apps->maximus
and then uncheck and then check again, the "undecorate" option again (it should be checked for maximus to undecorate).

BUG Note: When the netbook-launcher is added to the system startup, it behaves strangely; sometimes it just disappears, and I don't know how to get it back, and also, it only appears on workspace1, and not on all workspaces. I don't know a fix to this. If you do, please let me know.
Given this bug, I right now have a toolbar button on my panel to start the netbook-launcher, and haven't added it to the system startup list.

With the steps above, the 64bit ubuntu desktop edition can be easily enhanced to incorporate all useful features I see from the Ubuntu Netbook Remix.

And yes, don't forget to check out my post on using Easystroke
http://varghese85-cs.blogspot.com/2010/08/easystroke-gesture-recognition.html
.

installing all basic packages required for development on Ubuntu

It was always a pain figuring out how to install all the basic development packages required for simple stuff like compiling and installing something from source on Ubuntu. But now I realized after searching the web that there's a "build-essential" package (singular, not plural) which can be installed which will fetch and install all of these basic stuff like gcc, autoconfig etc.

sudo apt-get install build-essential

.

Easystroke Gesture Recognition

I just ordered an Asus EEEPC T101MT tablet last day from amazon.com. It hasn't arrived yet, but I was already looking at installing ubuntu on it, and since Apple apparently has patents on the Multitouch gestures, many of the multitouch features are not available on linux yet. I was looking at alternatives and came across Easystroke Gesture Recognition.

Project Page: http://easystroke.sourceforge.net/

What's better than a couple of demo videos to show you what it's like? So here they are

Source: http://www.youtube.com/watch?v=sOWXAyOde18



Source: http://www.youtube.com/watch?v=FGuKSEKNogQ


.

Wednesday, May 12, 2010

Running Ubuntu/Linux on Asus Eee PC T101MT

Ok, this post is like a prologue since I plan to buy this but haven't bought it yet. So this blog post is my research notes on Linux support for the Eee PC T101MT's support with linux.

As has been my recent inclination, I go for Ubuntu. So this is the netbook version download link for the distro
http://www.ubuntu.com/getubuntu/download-netbook

The above page links to this page
https://help.ubuntu.com/community/Installation/FromUSBStick
for creating the usb disk. I will probably first try running off the USB before installing.

And here's a sourceforge page for a USB boot disk creator tool for many platforms including windows.
http://unetbootin.sourceforge.net/

Here's a list of multitouch drivers available presently with linux.
http://www.lii-enac.fr/en/projects/shareit/multitouch-devices.html
Scroll down to EEFTI/eGlax, and there's the support for Eee PC T101MT mentioned on there.

Here's a couple of forum posts discussing the nuances of intalling ubuntu on the T101MT. Some of the info may be dated though.
http://ubuntuforums.org/showthread.php?t=1468376
http://ubuntuforums.org/showthread.php?t=1442164

.

2010 11 12
Subsequently, I found this page which gives all the details..
https://help.ubuntu.com/community/T101MT

.

Sunday, February 28, 2010

Metronome for linux

Gtick is a simple metronome application for Linux. I was trying to learn to play the Djembe, and some friends suggested using a metronome. However, attempts to look online for one, gave me the impression they were either expensive or riddled with flaws. Heck ! my laptop is my metronome now !

.

Friday, September 18, 2009

jaunty jackalope Ubuntu 9.04 compiz blacklists my video card

I have a Dell Vostro 1310, with I believe, the intel 965 chipset. The video card was working fine with Ubuntu 8.04 and 8.10 with compiz, but when I upgraded to Jaunty, the card was blacklisted. Don't know why, this link https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/363821 says some crap about video freezes etc.. I've never had any.. But it says to add the line:
SKIP_CHECKS=yes
to the compiz-manager file
~/.config/compiz/compiz-manager
or
/etc/xdg/compiz/compiz-manager
This will remove the blacklisting check, and allow the card to render compiz effects..

Also make sure you have the CompizConfig Settings Manager package installed for tuning your compiz desktop.

.

jaunty jackalope Ubuntu 9.04 keyboard and trackpad freeze at startup

I hit this issue on my Dell Vostro 1310 after an upgrade to Ubuntu 9.04 aka Jaunty Jackalope - amd64. When I boot, most often, the onboard keyboard and mouse are dead. Most people reset and when it comes up again, it works. I had found the workaround in suspend/resume of the system. But honestly, it was a pain.

Finally found this bug: https://bugs.launchpad.net/ubuntu/+bug/341094

The workaround mentioned there viz. adding the options
i8042.reset i8042.nomux i8042.nopnp i8042.noloop

at the end of the list of kernel parameters in
/boot/grub/menu.lst

works for me.

.

Thursday, July 30, 2009

DivX encoding under Linux

Well, I am jealous of all those windows folks who have amazingly good GUI apps for video format conversions / transcoding. I've always wanted some good idea of how to do this under linux. How could you rip DVDs and convert them to DivX files so that you can save a copy even if the flaky and trashy optical medium dies out after a while?

Stumbled across this link while searching online.. Looks good, though a bit dated.

Title: DVD ripping and transcoding with Linux
http://www.bunkus.org/dvdripping4linux/single/
http://www.bunkus.org/dvdripping4linux/

.

Wednesday, July 29, 2009

How to Rip and extract vob files from a css encrypted DVD

Refer to my previous post
Playing encrypted video DVD on linux
about installing libdvdread

Once you have libdvdread/CSS installed,
then apt-get install vobcopy, then just running the command
vobcopy -o [outputdirectory]
Will extract a decrypted version of the vob files into the mentioned output directory !

-------------------------------------------------------
Note: I'm not responsible for your indiscretions / violations of applicable law, if any,
in using the software mentioned above. Please ensure you have the right to copy
before ripping a dvd in the above fashion.

.

Tuesday, July 28, 2009

playing encrypted video dvd on linux

I had rented some movies from the College Library at the UW-Madison, and tried playing them on my dell vostro 1310 running ubuntu 9.04. However, none of them would play :(

I was using gmplayer (www.mplayerhq.hu), and so I always thought it was a problem with my disk drive, like it was not reading the disk properly or something. I couldn't imagine mplayer not having the required codecs, and besides the error I got was something like "seek failed".

I tried with other linux media players too, but ditto ! So I gave up.. But then, lately somehow this sudden enlightenment flashed in my mind (don't exactly remember the nature of the apple that struck my head), and I realized that the disc could probably be encrypted for copyright protection.

I searched "play encrypted video dvd on linux" and bingo, this is the link I got..
http://theos.in/desktop-linux/linux-playing-encrypted-dvd/

Basically what it says I should do is, as superuser/root:
$ cd usr/share/doc/libdvdread[N]
where [N] is an integer; for me it was 4. And then run the script "install-css.sh"
$ ./install-css.sh
or
$ sh install-css.sh
Make sure you are plugged into the internet ;) and the system will fetch and install the necessary packages.. Once that is done, all those dvds which wouldn't play till now would miraculously start playing !! Yeah !

.

Friday, January 16, 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"

.

Sunday, December 28, 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

.

Friday, December 26, 2008

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!

.

Saturday, November 22, 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

.

Friday, November 7, 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

.

Thursday, November 6, 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.

.