Monday, March 11, 2013

Non-Linux Tip

To know any VAS (Value Added Services) you have activated on your BSNL mobile, the USSD code to use is *456*00#
For Airtel, it is *121*5#

Thursday, October 13, 2011

RIP Dennis Ritchie

Today is indeed a very sad day for me. We have lost a great mind. Dennis Ritchie was one of my heroes. RIP Dennis Ritchie.

Saturday, December 19, 2009

Skype in Linux

Recently I have started using Skype in Linux for video calls (calling home). My webcam (Logitech QuickCam Connect) works well in Linux but not directly under Skype (2.1.0.47). I am on Ubuntu 9.10. After some net surfing, I found two solutions that worked:

Solution#1:
Install gstfakevideo.
If webcam is at /dev/video0, then move it to, say /dev/video1 (gstfakevideo will use /dev/video0 for itself by default. This also means that in Skype Video settings, /dev/video0 is to be selected).
Start Skype as follows:
gstfakevideo v4l2src device=/dev/video1

Solution#2:
Install libv4l (in Ubuntu it is libv4l-0).
Start Skype as follows:
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype

(change the above path names depending on where the libv4l and skype are installed in your system)

Now that I got video working under Skype, I faced another problem. The video was too dark, and the current Skype version for Linux does not provide any option to change the brightness, contrast, etc. Again, some net surfing, and the solution that works for me turns out to be xawtv.

xawtv includes along with it a tool called v4lctl, which allows one to control brightness, contrast, etc. of the video stream from v4l devices. For me, a simple

v4lctl bright 250

from the terminal during a Skype video call solved the brightness problem. For other options that can be changed via v4lctl, do a

v4lctl list.

I can't exactly remember the URLs from where I collected those solutions, but I do remember that all of that info was from the Skype forums.

Sunday, March 22, 2009

Narrowing down to a region in Emacs

Emacs is awesome! What a piece of software! Recently, I discovered a very useful feature in Emacs.

Let's say, you are writing some documentation in text-mode. Inside it, you need to write a piece of C code with proper indentation. You can switch to c-mode, but then the rest of your text starts looking weird with colors and all, and this is very distracting (to me at least). But Emacs, as usual, has a solution to this problem.

Select a few blank lines (where you want to insert your code) within the text, and give the command M-x narrow-to-region (the keyboard shortcut for this is C-x n n). You will find yourself in a buffer with only the region you selected. Then you can enter c-mode and write the code. When done, you can go back to your original full view by using the command M-x widen (or C-x n w) and switch back to whatever mode you were in (text-mode in this case).

I find this pretty useful.

Using "Abbreviated Skeletons" in Emacs

In Emacs, you can use code templates (using 'skeleton's in emacs) as abbreviations to speed up your coding. Here is an example:

Suppose I want to create a code-template for the for loop in c-mode in Emacs. To create the template, I can put the following function in my .emacs file:

(define-skeleton c-for
"Inserts a C for loop template."
nil
> "for (;;){" \n
> _ \n
"}" > \n
)

(see the Autotype section of the emacs info)

After that, I can edit the abbreviation table by using the command M-x edit-abbrevs (i.e., Press Alt+x, and then give the command edit-abbrevs and press enter).

Then, under the heading (c-mode-abbrev-table), leaving a blank line, I can enter the following line:

"forst" 0 "" c-for


Then, I can save the changes by pressing C-c C-c (i.e., press Control+c twice). That's it.

Now, whenever I am writing a C program, if I need to use the template, I will just type "forst" (without the quotes), and if the abbrev-mode is turned on, then as soon as I enter a space, my template for the for statement gets entered with the cursor inside the for loop as follows:

for (;;){
_
}


(If the abbrev-mode is turned off, "forst" can still be expanded to the template by pressing "C-x a e", which basically stands for "abbreviation expand".

Oh, of course I need to save my abbreviations using M-x write-abbrevs-file if I want to use them in future emacs sessions. But that is obvious... although I have forgotten that on many occassions :-)