Wednesday, December 30, 2009

Magic Jack error 9 no internet connection

I was struggling to be the tech-support for my mother back home and getting her to talk to me over magic jack. It kept saying, Error 9: no internet connection.

And yet at the same time she could hear me properly on Skype but I was not able to hear her at all. Video was working both ways.

I asked her to unplug the magic jack ("Safely remove hardware" and all), and viola, the skype audio started working! :)

I haven't ascertained yet, but I am pretty sure the solution to the magic jack also lies somewhere there - some other device must be using the network itself.

Saturday, December 19, 2009

Minitube: native client for Youtube

Even though the support for Adobe Flash is getting better on *nix systems, it is far from what it should be. Youtube especially seems to have problems interfering with audio settings, not running fullscreen properly on multiscreen displays to name a few.

Solution: use Minitube, a Flash-less native Youtube client for Linux & other Unix-like systems.
http://flavio.tordini.org/minitube

Wednesday, December 2, 2009

Ubuntu eclipse no java perspective

For those of you installing eclipse for the first time on Ubuntu (using the System -> Administration -> Synaptic Package manager), the Window -> Open Perspective -> Java might not appear (even under Other).

Here is what you need to do:
1. Close eclipse if you are already running it.
2. Open the Synaptic Package Manager (as above) and select the eclipse-jdt package as well.
3. Install (basically, Apply)

That'll do it! :) Start up eclipse again!

Wednesday, October 21, 2009

Google Doc Viewer

Google Docs has the functionality to render PDF/PPT documents into HTML webpages on the fly. If you have attachments in GMail, you might have seen this already. Now, Google has opened this for any document on the web.

Just add your document URL after "http://docs.google.com/viewer?url=",
Having http://, www prefixes before the URL doesn't hurt.

The Greasemonkey addon for Firefox & its equivalents for other browsers go one step ahead. This script modifies each document link automatically with the viewer prefix.

Thursday, October 15, 2009

Firefox crashing with Adobe PDF plugin

I had struggled for quite a while with the way Mozilla Firefox would crash each time I tried to open a PDF document - I always had to save the link independently and then open the doc. The default behavior of in-browser opening of the document was the problem, it seemed. So here is how you solve it.

From the Firefox menu, go to Tools->Options. There, on the Applications tab, you will find a long list of applications/document types and what is supposed to be used to open each of those. It would look like this:

In there, like I've shown here, find the Adobe Acrobat documents and instead of "Adobe Acrobat (in Firefox)", select "Adobe Acrobat Reader", i.e. the program itself. If that does not show up by default, select "Other", and browse to find Adobe Acrobat Reader.

There you go - no more crashes! :)

Sunday, September 13, 2009

Suspend/Hibernate from command line

On a *NIX system, there are two main message buses: a system-wide one and one for each user session. The "dbus-send" command can send messages to either of the buses with --system or --session options along with a variety of options. Long story short, if you want to suspend or hibernate your machine, you need to send messages to org.gnome.PowerManager, not sure how it is for KDE systems. This is what your respective GUI options do internally.

To suspend, say:

$ dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Suspend

To hibernate, say:

$ dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Hibernate

Thursday, September 10, 2009

Changing HTML class attributes using Javascript

If you try to change the HTML class of an object on the fly using javascript, you might find that it works on Firefox but doesn't work with Internet Explorer. In that case, you're probably doing this:
document.getElementById("myObject").class = "newclass";
However, after being ready to bang my head on the desk for two days and doing a binary search on 500+ subversion revisions to find the exact working/non-working combo for IE, I have discovered this. You ought to use
document.getElementById("myObject").className = "newclass";
Heh... the joys of life.

Thursday, August 13, 2009

The Rules of SYS::SYSLOG

From the Perl documentation of Syslog:

The First Rule of Sys::Syslog is: You do not call setlogsock .
The Second Rule of Sys::Syslog is: You do not call setlogsock .
The Third Rule of Sys::Syslog is: The program crashes, dies, calls closelog , the log is over.
The Fourth Rule of Sys::Syslog is: One facility, one priority.
The Fifth Rule of Sys::Syslog is: One log at a time.
The Sixth Rule of Sys::Syslog is: No syslog before openlog .
The Seventh Rule of Sys::Syslog is: Logs will go on as long as they have to.
The Eighth, and Final Rule of Sys::Syslog is: If this is your first use of Sys::Syslog, you must read the doc.

Sunday, August 9, 2009

Downloading flash videos

Here is a hack where you have to do very little actually, its mostly about the discovery. When using Firefox on GNU/Linux, the Adobe Flash plug-in automatically downloads flash videos you are viewing in Firefox to your /tmp directory.

e.g. when I view http://www.youtube.com/watch?v=xO0gSJGJ7Fs in Firefox, a randomly named file /tmp/Flashn3T33b shows up, which I can play using mplayer, copy, rename, do anything with. When I close the tab, this file is deleted, but the plug-in does forget to clean up on few occasions.

Saturday, July 25, 2009

Viewing man pages in Emacs

As the default Emacs shell is designed as a text buffer (with its advantages of close text-editor integration), it makes it a bit inconvenient to view man pages. A special way for doing that is by invoking man: "M-x man" and entering the command you need to look up. If you would rather view the listing in color, use the aptly named "M-x woman".

Saturday, July 11, 2009

10 programming languages worth checking out

A stimulating article and a good starting point for hackers interested in experimenting with new languages.

http://www.h3rald.com/articles/10-programming-languages

Wednesday, June 24, 2009

PHP SQLite 3 exec not working

I've spent at least a week wondering why my db->query statements work on my PHP files whereas the db->exec randomly seems to work or ceases working. This is mostly with the PDO opening of SQLite 3 onwards, where it behaves almost read-only.

Turns out, not only do you need to allow write access to the database file itself, but also to the folder containing it. Some google searches also seem to suggest that the full path needs to be given. But trust me - simply enabling write on the directory worked. This seems like a potential security issue, though :(

P.S. - For my facebook friends being forced to read this note - sorry, I'm still trying to figure out how to decouple the RSS I had once linked. :(

Thursday, June 4, 2009

Migrate or roll back an entire svn repository

If you have suddenly been stuck doing a stupid commit to svn and don't know how to just get back, here is a quick hack which I found at http://stackoverflow.com/questions/402159/roll-back-or-revert-entire-svn-repository-to-an-older-revision.


svnadmin create --fs-type fsfs /svnroot/<repo>.fixed
svnadmin dump -r 1:24 /svnroot/<repo> --incremental > dump.svn 
svnadmin load /svnroot/<repo>.fixed < dump.svn
 
The next step, as you might have guessed, is to move the repo.fixed to . This way, you can also copy a repository as it is to someplace else by just doing the load into some other server somewhere.

Saturday, May 30, 2009

Mounting iso files

Unlike Windows where we need to install third-party apps, GNU/Linux or other Unix-type OSes have a built-in way to access disk image files as block devices as "Loop Devices." This can be done using the mount command as:

mount -o loop example.iso /media/disk

Thursday, May 21, 2009

Concatenating videos with MEncoder

Some video formats like mpg allow files to be merged directly by concatenation. You can combine other complicated formats like avi, flv with MEncoder which is a free video encoding/decoding utility and a close sibling of MPlayer. The way to do this is:

mencoder -of lavf -oac copy -ovc copy -o output.flv input1.flv input2.flv

Friday, May 15, 2009

Boost your volume on toshiba laptops running ubuntu

If you have a Toshiba Satellite laptop and run ubuntu, then you probably hate the fact that you cannot hear the sound as loud as you would want it to be. Doing a
sudo apt-get install gnome-alsamixergui
will not help too much as well, since it will still show only Master and Capture in the alsamixergui under Applications -> Sound and Video -> Alsa Mixer

So here is what you need to do: you need to install alsa from source. First, download the latest ones from here: http://www.alsa-project.org/main/index.php/Download. The volume control is under Utilities, but you will also need the Library to install that stuff.

So first, install the library:
tar -xvjf alsa-lib-1.0.20.tar.bz2
cd alsa-lib-1.0.20
./configure
make
sudo make install

Then install the utilities:
tar -xvjf alsa-utils-1.0.20.tar.bz2
cd alsa-utils-1.0.20
./configure
sudo make install
NOTE - there is no make step here - direct make install!

If you get an error that says "`t-ja.gmo': No such file or directory" then you need to install gettext.
sudo apt-get install gettext

After that, once your utils are fully installed, go ahead and see the alsa in full glory: open Applications -> Sound and Video -> Alsa Mixer Gui and increase the Master, Head and Front volumes to full! Yennjoy!

Tuesday, April 28, 2009

Vim convert whole word to lowercase

UPDATE: following whatever is typed below the horizontal line will convert your entire file into uppercase. The better way for just a word is to use

gUw

Yep - no funny colons or commands - just get your cursor under the word and type gUw.




If you are a vim user and want to change some whole config to lower case, here is the quick shortcut:

:%s/[A-Z]/\l\0/g

That's a backslash-el, backslash-zero, by the way.

Thursday, April 23, 2009

Annoying right clicks on the google talk icon in your taskbar

It can be annoying when you want to right click and exit or sign out of google talk and you right click on the icon on the taskbar. Not always, but sometimes it shows this menu instead of the one you want:
 
So the way out is to just left-click somewhere empty on the bottom taskbar. This will hide the menu above. Then you right-click on the google talk icon again...

and voila - you can exit!! :)

Thursday, April 9, 2009

Cygwin ls command not found

If you are a linux enthusiast and really miss those greps and sed/awks on the windows box, you've probably installed cygwin. You tried running it either by double-clicking the cygwin icon on your desktop or the cygwin.bat file in your "C:\cygwin" directory and got the bash-3.X$ prompt. However, although the pwd or cd commands work, if you try ls, it says:"ls: command not found".

Here is what you need to do to fix it:
  1. Right click on "My Computer" -> Properties -> Advanced -> Environment Variables
  2. Add a new environment variable, called CYGWIN_HOME and set its value to C:\cygwin
  3. Edit the PATH environment variable and add C:\cygwin\bin to it (usually separated by a ';').
  4. Just click okay, exit any command prompts or bash shells (over cygwin) you may have open, and open it again - it'll work!
Note: this assumes that you have installed cygwin at C:\cygwin. If you've kept it someplace else, please modify the above accordingly.

Sunday, March 22, 2009

ASCII videos in mplayer

Mplayer comes with different video drivers each providing fine tuned adjustments from choosing graphics accelerators to viewing images. "$ mplayer -vo help" will give you a list.

My favorite of course is the ascii art driver AAlib. Here's how to view videos in ascii and replace aa with caca to see color.

$ mplayer -vo aa video.avi

If a picture is worth 1000 words or not, see for yourself. Try to guess what movie this is...

Thursday, March 19, 2009

Copy paste '?' characters on Cisco IOS CLI

The Cisco IOS command line interface (CLI) has the special character '?' which you cannot insert into a literal string. One method of doing that is to do a and then type '?' (without the quotes) and then the special character gets inserted in the string.

However, when you are copy-pasting IOS CLI commands, it might be tough. The simplest way is to open the file in vim and just do this:
:%s/?/Control-V Control-V?/g
which will add the special escape character "Control V" in front of every question mark.

The other method (for all you Windows Notepad folks) is to copy paste the character in the next line:

without the trailing newline and do a search and replace of every ? with ? in the text file. Then you can copy paste the file.

Tuesday, March 3, 2009

Changing or hiding HTML label texts

If you are doing a simple javascript program and want to change the text inside a label (or hide it, maybe?) you can do it by this simple code:
document.getElementById("whatever_your_label_id_is").innerHTML 
= "Text you want"

So now you can hide/show labels, change texts etc on the fly.

Saturday, February 28, 2009

Merging PDF documents

Having its origins in the GNU community over 20 years ago, Ghostscript (gs) was designed as a free interpreter for Adobe PostScript with an intention of saving trees and named as a play of words on that. Along with providing tools for raster image processing and converting between different document formats, it also comes with a peculiar pdf/ps viewer called Ghostview (gv), which I am not sure of ever using over good old evince.

Nevertheless, I find some command line gs utils incredibly powerful. Lets say you wanted to merge two pdf files. Just say:

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

The options are somewhat involved and long to explain here, but you can read through the documentation. If you want to save the typing, add

$ alias mrg='$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf'

to your .bash_profile and then use

$ mrg file1.pdf file2.pdf

to get a merged output.pdf. Pure GNU.

Sunday, February 22, 2009

Automatic mail notification from gmail

On Ubuntu or any gnome desktop that you're using, simply put the command "mail-notification" in your .bash_profile and sync it up with your gmail/yahoo mailboxes. Every time a new message comes, you can see a small popup on the right. No new tools to install for each website, no thousands of things to consider.

If you want to just give it a try, go via Applications->Internet->Mail Notification and give it a shot.

Friday, February 20, 2009

Enabling backspace in gVim on Windows

I found it really annoying for a few days that my backspace key wouldn't work on my gVim on windows, but it would work fine on linux. I found a pretty nice explanation somewhere after googling, but here is the short answer: put this in your _vimrc in C:\Documents and Settings\\_vimrc --
set bs=2

Yeah yeah... we all know, we need twice the bs ;) From the open or current vim session, of course, you type :set bs=2 (i.e. the same thing with a colon before).

Thursday, February 19, 2009

Command Spell Correction in Bash

If you tend to make mistakes while typing, bash can be a a little less than helpful; just spitting out a "No such file or directory." One small hack which helps towards this is the automatic spell correction built into bash. This will correct small typing errors made with the cd command as follows.

user@host:~ $ cd /ect
/etc
user@host:/etc$

It can be enabled for the current shell by

$ shopt -s cdspell

As before, you can make the effect more permanent by echoing the command into .bash_profile.

Wednesday, February 18, 2009

Case-insensitive Tab Completion in bash

Tab-completion is one of the major things which makes the command-line so powerfully fast to use. It has apparently been around for decades and its preliminary versions would even predate Unix. IMO, bash does it just right while the shells in Windows mess it up. However, many initial bash users find the shell too rigid and less suggestive. Here are a couple of ways I found which makes bash a bit more easy to use.

Most hardened Unix hackers tend to name all their files and directories in the lower case (to save on hitting shift), while less hardened users, especially those using GUI interfaces to browse their files use proper case. So if you are on the command-line and are not sure if the directory is Coursework or coursework, here's a hack for you. Just say:

$ set completion-ignore-case on

If you want to do this across sessions add this line to /etc/inputrc. You might want to do that as root as below.

# echo set completion-ignore-case on >> /etc/inputrc

about:blog

hello, world!

-- A small blog about the little hacks which make life easy and fun.

Actually, a little more than that. Over the years, I have collected/found/conjured up many little hacks & tricks which make life a little more exciting. This blog is sort of a "log" of these for myself.