Showing posts with label Tricks. Show all posts
Showing posts with label Tricks. Show all posts

Monday, July 6, 2009

Accessing Operating System Environment Variables in Apache (Fedora)

I was facing the problem of accessing the Operating System Environment Variables in Apache. After searching a lot, I got to know that there are environment variables in apache too. Although these variables are referred to as environment variables, they are not the same as the environment variables controlled by the underlying operating system. Instead, these variables are stored and manipulated in an internal Apache structure.

For setting the operating system environment variables to be used by apache, we will export these variables to the apache server when it starts. The procedure is as follows :

0. Switch to root.

1. Open /etc/init.d/httpd in vim

vim /etc/init.d/httpd

2. You will find following lines

# Source function library.
. /etc/rc.d/init.d/functions

Open /etc/rc.d/init.d/functions in vim

vim /etc/rc.d/init.d/functions

3. You will find following lines

# Set up a default search path.
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH

Now append whatever environment variables you want to set and accessed by apache.

VAR="/path/to/var"

export VAR

For example,

LD_LIBRARY_PATH=/usr/local/lib:/usr/local/cuda/lib
export LD_LIBRARY_PATH

You could have added these lines anywhere in the file.

4. Save the file and restart the apache server.

/etc/init.d/httpd restart

Hope it helps. I will add the fix for Ubuntu soon.

Sunday, June 28, 2009

SVN Proxy Settings

Subversion (SVN) is a version control system used to maintain current and historical versions of files such as source code, web pages, and documentation.

If you are behind a proxy you will have to set the proxy before using svn.

The procedure for the same goes as follows :

1. Open "servers" file located in ".subversion" directory in your home directory.

vi ~/.subversion/servers

2. You will find following lines of code located in the file

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = defaultproxy.whatever.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword

Set the appropriate values and remove the '#' from the beginning. Make sure you don't leave any whitespaces at the front of the lines being edited.

After editing the code will look like

[global]
http-proxy-exceptions = *.exception.com, www.internal-site.org
http-proxy-host = defaultproxy.whatever.com
http-proxy-port = 7000
http-proxy-username = username
http-proxy-password = password

3. Save the file and exit.

You are now ready to use svn.

Friday, June 26, 2009

Setting NumLock on automatically in Fedora

The NumLock is not activated by default at start-up (in FC-9/10). I am not sure of the fact in other distros. Everytime when the computer starts, you have to manually activate the NumLock key.

The following solution works :

Execute the following commands as root in a terminal.

1. Install numlockx

yum install numlockx

or

Install using numlocx rpm.

rpm -ivh numlockx*.rpm

2. gedit /etc/gdm/Init/Default

3. At the end of the file you will find a line like

exit 0

Above this line add the following code

if [ -x /usr/bin/numlockx ];
then /usr/bin/numlockx on
fi

4. Save the file and restart the computer.

You will find the NumLock activated by default at startup.

Thursday, May 28, 2009

Cure Of The Notorious Ubuntu futex_wait Bug

It all started two months back, when DC++ suddenly stopped working on my Ubuntu 8.10 - the Intrepid Ibex. Each time I tried running it, it would hang : the Interface Window would turn gray and not respond. I'd have to use the Force Quit application or kill the process from the System Monitor list of processes. I tried reinstalling DC++, but it didn't solve the purpose. Soon other programs caught the infection and started exhibiting the same strange behaviour : Firefox, Gnome-do, EOG, python, and gvfs-fuse-daemon would hang at different times without issuing any warning. One day I noticed - in the Waiting Channel tab of the System Monitor - that they had a common waiting channel, “futex_wait”. I looked at the futex man page and learnt that futexes ( or better Fast Userspace muTexes ) were semaphores or mutex locks provided by Ubuntu to allow threads to work concurrently. The implications were clear : these multi-threaded applications were waiting on a futex and the duration of the wait indicated a deadlock.

The book “Operating System Principles” by Silberschatz, Galvin and Gagne says that in most Operating Systems, the method of handling deadlocks is to ignore deadlocks altogether and pretend that they never occur in the system. Further, it says that both Windows and UNIX use this solution. I researched a bit on the Internet and found that indeed it was a bug in the latest Ubuntu 2.6.27-* Kernels and the Ubuntu community was working on it to make sure the newer kernels don't fall prey to this problem.

I had learnt to live with the shortcoming until today when luckily I found a workaround for the problem. It turns out that switching off the "Assistive Technologies” does the trick.

Go to System > Preferences > Assistive Technologies
uncheck the "Enable Assistive Technologies" options.

Sunday, April 12, 2009

Selecting a block of text in Microsoft Word

Have you ever tried selecting a rectangular block of text in Microsoft Word as shown below :



The trick is to press 'Alt' key and then select a piece of text. This enables you to select a rectangular block of text.

The selected text can be cut/copied in the usual way.

Friday, April 10, 2009

Open Multiple Homepages in Different Tabs in Mozilla Firefox

I was looking to achieve this on my Firefox in Ubuntu. Initially I was looking for some addon which could do this for me,at one point Juneja and I thought about writing a plugin which could bring this about. But luckily I found a trick that worked. I've seen it work on Firefox in Windows and Ubuntu.

The trick is,

In Ubuntu:
Go to Edit>Preferences>Main
In Windows:
Go to Tools>Prefences>General

Now in the Homepage text area,put the URLs you want to open simultaneously at Firefox startup, using '|' as a separator.

For clarity, see the screenshot below


Tuesday, April 7, 2009

Wireless Problem on Fedora 8/9/10

This post is for those people who are not able to use wireless on Fedora 8/9/10. The problem arises in computers with Broadcom wireless cards as the drivers are not packaged with the Operating System. I first encountered this problem on Fedora 9. That time I had to use NDISwrapper to wrap the wireless driver. That was quite a tedious task.

After moving to Fedora 10, I had to again set up the wireless drivers. But what I found was that RPM's are available for Broadcom 802.11 STA Wireless Driver from rpmfusion.org for Fedora 8, 9 and 10. It means that you now have an easy way to set your wireless working.

To install the drivers using yum, follow the following steps :
  1. Enable the rpmfusion non-free repository and rpmfusion non-free repository.

  2. su -c 'rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'

  3. Update & Install the driver.
  4. su -
    yum update
    yum install broadcom-wl
  5. The installation is done. Reboot your computer. Enable Network Manager and you will see your wireless device working.

P.S. The above procedure is applicable to Broadcom's BCM4311-, BCM4312-,BCM4321-, and BCM4322-based wireless card.

You can check your wireless card type by typing 'lspci' command.
If the last line of the output matches the following line, then you are
having a Broadcom based wireless card.

0b:00.0 Network controller: Broadcom Corporation BCM43** 802.11b/g (rev 01)

Gmail : Email Galore

Recently while logging in to my gmail account I accidentally put an extra dot in my username. I was about to hit the stop button to rectify the typing error but I realized that even with “ the error” my gmail page loaded. Later I tried the same trick, putting the dot elsewhere in the username string; it worked still. I repeated the exercise several times, placing as many dots as I wanted and at random positions in the username string. It worked each time. Next I sent myself an email from my yahoo account to my gmail account, putting extra dots in the recipient gmail id. As expected, the mail was received.

Apparently the gmail server neglected any dots in the usernames. This was news. That meant any gmail user had infinite number of email ids, all sharing the same alphabetical substring. I searched on google to find out if it was aware of the 'bug'. I found out it was no bug, rather a policy. Further, I learnt about a similar policy called the + addressing. This allows emails to be sent to UserName+ExtraText@gmail.com where the actual email id is UserName@gmail.com . “ExtraText” refers to any random string. For instance you could send me a mail on robinchandra19+gotohell@gmail.com in place of the plain robinchandra19@gmail.com. I would receive the mail and you would have your fun. But before you try this with your Boss's mail id, know about the catch. The catch is: by reading the details of the email, the recipient can know the exact username string the mail was addressed to. Even the best of rogues leave trails!! Jokes apart, this can be used as a means of filtering mails into appropriate folders. Say, tomorrow is 14th February. I send mails to 100 hot girls and ask them to mail their rendezvous times to robinchandra19+exquisitedinnerfortwo@gmail.com . I can now filter all mails addressed to robinchandra19+exquisitedinnerfortwo@gmail.com and label them accordingly. Sounds great, isn't it?

Try these tricks.