Saturday, September 22, 2012

Network painfully slow on Ubuntu

If you are suddenly seeing a painfully slow network connection on Ubuntu, with lots of dropped packets, chances are that you recently upgraded the kernel and restarted the computer to use that kernel.

In my case, the problem was a bad ethernet Realtek driver, which was included with  (or chosen by) the new kernel(r8169). The solution is to patch the kernel to use the correct driver (r8168), which is free from this issue.

The steps to fix this issue are simple... ( source - this page )
  1. Download the Linux driver from here.
  2. Extract it somewhere.
  3. Run "sudo ./autorun.sh"
Enjoy the fast speed...

Monday, September 17, 2012

Playing with Phong shading

While going through an example in the OpenGL SuperBible 5, I came across the Phong lighting model. Its  one of the tricks which helps create those amazing 3D pictures.

Looking closer at the equations, I found that a bug in the specular lighting calculations, which is reported here... https://code.google.com/p/oglsuperbible5/issues/detail?id=47

Here is what a phong shaded sphere looks like...


Now, its time to play with the fragment shader a bit... added some trigonometric beauty (  cos(600*x)*exp(-pow(20*x, 2.0)) ) to the reflection point...

Math is fun.

Tuesday, September 11, 2012

Eclipse theme on Ubuntu

Changing the look and feel of Eclipse on Ubuntu 10.04...

Problems:
1. Eclipse defaults to a white background. We need themes.
2. It has unbelievably large tabs on the top... are they taking some tips from the IE behemoth? No... its just does not play well with Linux.

Solutions:
1. Open Help -> Eclipse Marketplace. Search for "theme" and install Eclipse Color Theme. Once installed and restarted, go to Window -> Preferences -> Appearance -> Color theme.... pick a color theme you like and rejoice.

2. On the terminal, say "gedit ~/.gtkrc-2.0" and in the resulting window, type....


style "compact-toolbar"
{
GtkToolbar::internal-padding = 0
xthickness = 1
ythickness = 1
}

style "compact-button"
{
xthickness = 0
ythickness = 0
}

class "GtkToolbar"   style "compact-toolbar"
widget_class "*<GtkToolbar>*<GtkButton>" style "compact-button"

Save and restart Eclipse. The tabs should now be smaller. You are welcome.

Thursday, September 6, 2012

MP3 tag editor


If you are like me and listen to audio books, chances are that the random ordering of the chapters / sections must have driven you mad at some point of time.

The audio books I have usually have their order specified clearly in their filenames. Of course, this ordering info has been irritatingly left out of the id3 tag.

Because of this, iTunes does a lousy job or ordering the items when they are added to the library. And it lacks a good way to edit the tags. I wished Steve Jobs had listened to audio books and faced this problem. He would have got it fixed.

However, I found this extremely useful id3 tag editor which allows me to edit the tags of many files at once. It allows me to derive the id3 track name from the file name in an intuitive and user friendly GUI. And its free... http://www.mp3tag.de/en/

You can also change the file names from the tag, or even from the filename itself. It doesn't get better than this.

Ubuntu 10.04 VirtualBox USB woes

I was setting up a Windows 7 64bit guest OS on a Ubuntu 10.04 host, just for running iTunes. I needed to get some audio books into the ipod. Of course, no USB devices showed up when Windows finally booted, displaying the message "no usb devices connected". I dont understand how it can say that so confidently, specially since I am sitting right here and looking at the ipod connected to the computer. Even Ubuntu sees that its connected. I suggest that the message be changed to "no usb devices identified"... or something similar... something which is not a blatant lie.

On google searching, I found that I needed to add my username to the vboxusers group. Can someone make that a default option when VirtualBox installs? I restarted VBox and Ubuntu. USB still does not work.

After another google search, I found that I needed to add my username to the lp group as well. Additionally, make sure you have the VBox downloaded from Oracle and not the one that comes with Ubuntu. The Ubuntu bundled VBox apparently does not have USB support. Mine was already downloaded from Oracle.

After this, USB works.... yayy.

Steps to get USB to work in VirtualBox...
1. Make sure you have installed VBox downloaded from Oracle.
2. Also install guest additions and extension pack. The extension pack is separately downloaded from the VirtualBox website.
3. Now, add your username to the groups vboxusers and lp. This is done in Top menu -> System -> Administration -> Users and groups -> Manage Groups -> Properties (for vboxusers and lp).
4. Restart computer. You might get away by restarting only VBox...

Enjoy

Tuesday, September 4, 2012

Building Panda3D on Ubuntu 10.04 with Python 2.7

First, install Python 2.7 from sources ( follow the instructions here, or do the following... )

sudo apt-get -y install build-essential
sudo apt-get -y install libreadline5-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd ~/Downloads/

wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xvf Python-2.7.2.tgz
cd Python-2.7.2/
./configure
make
sudo make altinstall

Now, install flex (I was missing this... you might be missing more stuff).
Let me know in the comments what else you needed and I will try to update this page.

sudo apt-get -y install flex


Get the sources for Panda3D from here... ( direct link to Panda3D SDK 1.7.2 source tar.gz)

cd ~/Downloads/
wget http://www.panda3d.org/download/panda3d-1.7.2/panda3d-1.7.2.tar.gz
tar -xvf panda3d-1.7.2.tar.gz
cd panda3d-1.7.2
python makepanda/makepanda.py --everything
sudo python makepanda/installpanda.py --prefix /usr/local
sudo ldconfig








Install Python 2.7 on Ubuntu 10.04

Had to build Python2.7 from source today to get Panda3D to build on my system (yeah... its a convoluted story why I need to do that and cant live with the Python 2.6 which came with Ubuntu)... here are the instructions in brief.

# install the prerequisities
sudo apt-get -y install build-essential
sudo apt-get -y install libreadline5-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

# download the python sources

cd ~/Downloads/
wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz

# untar and build

tar -xvf Python-2.7.2.tgz
cd Python-2.7.2/
./configure
make

# alt install so as not to screw up the regular python
sudo make altinstall

# original instructions from
http://askubuntu.com/questions/101591/how-do-i-install-python-2-7-2-on-10-04