Sunday, May 15, 2011

Download YouTube videos from Terminal


If you are a YouTube fan, and have always wanted to download the tons of videos available online from Linux based distros, there are quite a few good options available, like Flashgot (Firefox plugin), etc.
However, if you are of the CLI-types, and prefer a Terminal based solution, just download and install youtube-dl
su -c ‘yum install youtube-dl’
And you are done.. now use it in the following way and enjoy :-)
youtube-dl video_url

Multiple commands from a single Keyboard Shortcut


After doing the keyboard binding, i wanted to experiment further and try to run multiple commands from the single keyboard shortcut. Basically, the inspiration was managing the OLD style eject operation found in Gnome, wherein the notification daemon used to show : “Ejecting Media Drive” followed by the eject operation.
After alot of tricks (even trying putting semi-colon between commands in the keyboard shortcut assigning window, which grandly failed !!), i zeroed in onto creating a simple bash script :
#!/bin/bash
notify-send -i /usr/share/icons/gnome-colors-common/scalable/notifications/notification-device-eject.svg “Eject” “Ejecting Media Device”
eject
NOTE THAT you need the libnotify-cil or libnotify-cli package in your distro to make the above shown notification happen.
Thats it. Save the file (name = script.sh) in your homefolder somwehere, say : /home/laptop/Public/
Now, perform the following steps:
  1. in your terminal, type : chmod +x /home/laptop/Public/script.sh
  2. Now, open Keyboard Shortcut Window from preferences menu
  3. Click on ADD button
  4. Name the entry as Eject CD Drive
  5. Enter the command as : /home/laptop/Public/script.sh
  6. Click OK
  7. Click on extreme right of the new entry you  just made
  8. Specify your keyboard binding for this entry.
And its done.. When you press the key combinations you just specified, it’ll show up the notification as shown in the image above. ENJOY !!!

Broken Eject keyboard shortcut in Gnome 2.30


There  is a configurable and pre-defined keyboard shortcut in GNOME for CD drive eject, suited especially for keyboard junkies who hate to take their hands off the keyboard for any operation.. However, since previous 2-3 releases of GNOME, i have observed that the keyboard shortcut binding is broken.. in the sense, that it doesn’t work.
So, i defined my own custom shortcut from the “Keyboard Shortcuts” window in Preference menu of Gnome based Distro, by the following method :
  1. Click on ADD button in “Keyboard Shortcut” window
  2. Specify a name for the keyboard shortcut you are defining (in my case: EJECT DISC)
  3. in the command text box, specify : eject
  4. Click OK to get a new entry in the shortcuts window (at the bottom)
  5. Click on the entry at extreme right hand side
  6. Press the key combinations you desire for the binding.
And you are done ! try pressing the keyboard combination, and you’ll see it working absolutely fine.
Hope this bug is fixed in upcoming GNOME 3.0 release..

Wednesday, May 4, 2011

Virus Removing Script


There is a set of folders that were affected by virus from a Windows environment. The viruses are in the form of various windows executable formats like .bat, .com and .exe. What separates them from safe windows executables is that malicious ones have same name as their parent directory. Remove all such occurrences. (There can be many levels of folders)

Be careful while reading a code segment

#include<stdio.h>
int main()
{
          int a=10;
          switch(a)
          {
                  case '1':
                      printf("ONE\n");
                      break;
                  case '2':
                      printf("TWO\n");
                      break;
                  defau1t:
                      printf("NONE\n");
          }
          return 0;
}
If you expect the output of the above program to be NONE, I would request you to check it out!!