Wednesday, September 21, 2011

Installing Haskell in Ubuntu

We can install Haskell Compiler like GHC and Haskell Platform using synaptic package manager in Ubuntu. But to get the latest version, we might have to install it manually.

1. Download the Glasgow Haskell Compiler binary.
2. Decompress the downloaded file and go into the ghc directory.
3. Now you need to configure the ghc binary. You can give the path of installation using the prefix flag.
./configure --prefix=/usr/local/ghc/7.0.3
Here I have downloaded v7.0.3. Since I wanted to keep different version of the compiler, I keep folders with version number under the ghc folder. Accordingly, you give the path to the configure script.
4. Install. It is already compiled, because you downloaded the binary.
sudo make install
5. Now you need to add the ghc directory to your path so that your bash shell can find it. There are numerous ways to do it. Create a file say "" in "/etc/profile.d"
sudo vim /etc/profile.d/
# Add the below contents to the file, save and quit.

# ghc-7.0.3 path
Log out and log in. Open your terminal (Ctrl + Alt + T) and type "ghc --version" to ensure ghc is available.
6. Now you have a working Haskell Compiler. It is highly recommended to install Haskell-Platform which are a set of libraries for Haskell. For that you go to Haskell-Platform page and download the tar.gz file under the "Build from source" section. Decompress the downloaded file.
7. There are dependency files that you need to have installed before proceeding to compile the Haskell-Platform. So, let us install aptitude, which is a ncurses front-end to APT. Then we shall install 'happy', 'alex' and 'darcs' using 'aptitude' which are haskell libraries.
sudo apt-get install aptitude
sudo aptitude install happy alex darcs
Now we need to install C dependencies. To find that we will use a script. In general, the C dependencies are 'libedit-dev', 'libbsd-dev', 'libgmp3-dev', 'zlib1g-dev', 'freeglut3-dev'. You will need to run the below script to find out.
Let us call the below script 'depcheck'. Put it in 'bin' folder under your home directory. The 'bin' folder is added to you bash path. So bash can find all the scripts inside that folder.
# check dependency of a package. The libs with -dev need to be installed
# before building

strace -f -o /tmp/log ./configure
# or make instead of ./configure, if the package doesn't use autoconf
for x in `dpkg -S $(grep open /tmp/log|\
perl -pe 's!.* open\(\"([^\"]*).*!$1!' |\
grep "^/"| sort | uniq|\
grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|\
cut -f1 -d":"| sort | uniq`; \
do \
echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; \
Set executable permission for the depcheck script.
chmod +x depcheck
Now go to the haskell-platform directory which you decompressed in step 6 and run depcheck. (Just type depcheck and press enter).
It will print out a lot of library names. You need to install all the ones which ends with a '-dev'. So the libraries shown to me are 'libedit-dev', 'libbsd-dev', 'libgmp3-dev', 'zlib1g-dev', 'freeglut3-dev' and 'libglu1-mesa-dev'. (Just in case, if your installation aborted saying that it is missing some library, then you can install them and continue the installation).
sudo apt-get install libedit-dev libbsd-dev libgmp3-dev zlib1g-dev freeglut3-dev libglu1-mesa-dev
8. Now that you have got all your dependencies installed, you can proceed with the Haskell-Platform. (You are now in the haskell-platform directory).
./configure --prefix=/usr/local/haskell-platform/2011.2.0.1
sudo make install
It will take a while to complete.
9. After the successful installation of Haskell-Platform, you need to add the directory to your path. Like in step 5, you create a file say '' in '/etc/profile.d/' folder.
sudo vim /etc/profile.d/
# Add the following contents to the file, save and quit.

# Haskell-Platform 2011.2.0.1
Log out and log in.
10. All done! Now do a cabal update to get the latest list of all the packages in hackage, which will take a while. Now you can install libraries (eg: hscurses) using cabal.
cabal update
cabal install hscurses #ncurses binding for haskell

Sunday, August 7, 2011

Commandline Compression and Decompression

There are various compression formats, of which the mostly used under GNU/Linux are gzip and bzip2.

To use gzip to create .gz package, you need to first create a container. For that tar can be used. Packaging files into a container and compression are two different things. gzip is mainly used for compression of a single file, which can be a container made from tar as well.
tar -cvf filename.tar dir-or-file
gzip filename.tar

Its same as tar.gz done using tar
tar -czvf filename.tgz file-or-dir

tar -cvf filename.tar file-or-folder
bzip2 filename.tar
tar -cvjf filename.tar.bz2 file-or-folder
Both gzip and bzip2 will delete the source file after compression.

Decompression (expand):
tar.gz or tgz
tar -zxvf filename.tar.gz   #or filename.tgz

tar -xvjf filename.tar.bz2

Saturday, August 6, 2011

Install Restricted Multimedia Codecs in Ubuntu

Some codecs like libdvdcss2 are restricted due to its proprietary nature. They are required to play dvds. To install them in Ubuntu, you can add the medibuntu repository and do an apt-get.
1. Add the repository
sudo wget$(lsb_release -cs).list --output-document=/etc/apt/sources.list.d/medibuntu.list
sudo apt-get -q update
sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring
sudo apt-get -q update
sudo apt-get --yes install app-install-data-medibuntu apport-hooks-medibuntu
2. Install the necessary codecs:
sudo apt-get install w64codecs libdvdcss2
You can install w32codecs as well.
3. Done.

Also you can install the mplayer essential codecs package
wget  #download the codecs
tar -xvjf all-20110131.tar.bz2 #decompress (expand)
sudo mkdir -p /usr/lib/win32 #make win32 directory under /usr/lib
cp -R all-20110131/* /usr/lib/win32 #copy the contents to it

Add and Remove PPA in Ubuntu

With newer versions of Ubuntu (>= 9.10) you can add PPA (Personal Package Archives), a convenient way to get latest versions of software.
To add a ppa:
sudo add-apt-repository ppa:<repository-name>/<sub-directory>
sudo add-apt-repository ppa:ubuntu-wine/ppa
You need to have 'python-software-properties' installed. Usually its installed by default. But it's the dependency, just-in-case.

Remove PPA:
1. Install ppa-purge and purge the ppa repository as shown below:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:<repository-name>/<sub-directory>
eg: ppa-purge ppa:ubuntu-wine/ppa

Adding repository or software channel:
1. First backup the sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
2. Append the repository links (deb,deb-src) to
deb natty main restricted
deb-src natty main restricted

Play RealVideo in Ubuntu

To play videos, .rm and other realvideo formats in Ubuntu, the only way that seems to work is to install RealPlayer under Wine.
I have tried custom build of mplayer, w32codecs, kaffeine etc. None of them works. Also the realplayer for GNU/Linux. It loads the video, displays the first frame, crashes and quits just like that.
And to convert them, using mencoder fails giving the error "Video Stream is mandatory!".
The command I used to convert is given below:
mencoder in.rm -oac mp3lame -lameopts preset=128 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200 -ofps 25 -of avi -o out.avi

The ultimate saviour is using realplayer under wine.

1. Install the latest version of wine (previous post).
2. Now download RealPlayer Gold.
3. Install it. Just open it with wine and continue the installation steps.
4. Done.

Now you can play realmedia files like .rm!

Install Wine in Ubuntu

To install the latest version of wine (1.3) under Ubuntu (11.04), open the terminal and give the commands as shown below:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.3

Monday, June 27, 2011

Restore Windows Bootloader

If you have Ubuntu installed along with Windows, you will have Grub as the bootloader. So if you decided to remove Ubuntu, then restoring the default Windows bootloader is required (else you can keep grub, but that's not the point), which you must do at first.

The easiest and the least time consuming way to restore Windows bootloader is to install lilo bootloader under ubuntu. And do a restore as shown below:
sudo apt-get install lilo
sudo lilo -M /dev/sda mbr

Now you have updated the MBR (Master Boot Record), and it will boot into Windows. You can use any harddisk management tool to format the GNU/Linux partition back to NTFS.

Sunday, May 22, 2011

Compile Objective-C in Windows

Objective-C programs can be compiled under Windows using the GNUStep mingw gcc compiler with the necessary libraries.

The easiest way to compile is to write a GNUmakefile.
Let's say that you have a HelloWorld Project that has a main.m file.
#import <foundation/foundation.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]
NSLog(@"Hello World");
[pool drain];
return 0;
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = HelloWorld
HelloWorld_OBJC_FILES = main.m
include $(GNUSTEP_MAKEFILES)/tool.make

Now type
inside the directory and you'll get a directory called obj were you have the executable.

Alternatively, you can use any of the following commands:
gcc `gnustep-config --objc-flags` -o main main.m -L /GNUStep/System/Library/Libraries -lobjc -lgnustep-base
gcc -o main main.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

Saturday, April 30, 2011

Adobe CS5: Installer failed to initialize

When you try to install Adobe CS5 products, you might get an error like: "Installer failed to initialize. Please download adobe support advisor to detect the problem". Downloading the support advisor didn't help me because it showed me what OS version I'm running, and a link to adobe support. Hmm.
Here is what you need to do.
1. Goto to your temp directory. (Press Windows+R key and type %temp% and press enter).
2. Open the file PDApp.log.
3. Look for any [Fatal] entries.
4. What I have got is that the installer wasn't able to create C:\DOCUME~1\username\LOCALS~1\Adobe\OOBE\PDApp\PDApp.exe.
5. Now create those folders for the installer, and run the installer once again.

Sunday, April 10, 2011

FreeBSD: "su: Sorry for normal user account"

If you get "su: Sorry for normal user account" under FreeBSD implies you are a normal user and cannot switch to root. To enable the current user to switch to root by 'su' command the user must be a member of the group "wheel".
You can add your user account to the wheel group by:
pw user mod username -G wheel
pw user mod Alice -G wheel
Btw you need to be root or have sufficient privileges to add a user to the group.

Monday, April 4, 2011

Install Tor in Ubuntu

(This post is up-to-date with Ubuntu release 12.04).
These are just the steps to install tor and the necessary software to make it run smoothly on your Ubuntu. For detailed info on what each parts does, you can always refer to the tor docs.
1. Add the following to the end of your /etc/apt/sources.list file.
The format here is
deb <distribution> main
Since we are using Ubuntu 12.04 we will use 'precise' for the distribution
deb precise main
2. Import repository GPG key
gpg --keyserver --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
sudo apt-get update
To keep the repository key up-to-date, install the debian package
apt-get install
3. Install tor, tor-geoipdb, polipo, privoxy
sudo apt-get install tor tor-geoipdb polipo privoxy
4. To Configure polio, first backup the original.
sudo mv -i /etc/polipo/config /etc/polipo/config.orig
sudo vim /etc/polipo/config
5. Add the following to the file or find those lines and uncomment them.
socksParentProxy = "localhost:9050"
socksProxyType = socks5
diskCacheRoot = ""
disableLocalInterface = true
6. (Optional but recommended) If you want a GUI frontend for tor install vidalia
sudo apt-get install vidalia
Vidalia will show a message on how it should handle tor. You can choose 'complete takeover'.
7. Append the following at the end of /etc/privoxy/config file or uncomment the line
sudo vim /etc/privoxy/config
forward-socks5 / .
Note that there is a space and a dot after 9050
8. Now we have successfully installed and configured the tor and its family, we need to tell the browser to use the network.
Assuming that tor is running else, start tor by
sudo /etc/init.d/tor start
Open firefox, and install tor addon.
If you install the tor button addon, then choose use polipo in the browser network settings.
Else to configure manually goto preference->advanced->network->settings->manual proxy configuration and enter the values for the following
HTTP Proxy: Port: 8118
SSL Proxy : Port: 8118
SOCKS Host: Port: 9050
Choose SOCKSv5
No Proxies for:
And click test settings. If things went well you'll get 'Tor proxy test successful' message.
You can check you IP address to see the difference.
9. Take about:config in the Firefox browser and set the value for network.proxy.socks_remote_dns to true to avoid DNS leaks.
NB: Its better not to run P2P software in tor network. The main purpose of tor is to provide anonymity for browsing. To make the tor network faster, you can consider running a tor relay on your system as well.
I highly recommend using the HTTPS Everywhere extension for firefox from It will make your browser to choose https protocol over http if the target server supports one.

Friday, March 11, 2011

Flashing Nokia N900

This is a video tutorial on how to flash Nokia N900 completely.
Here I'm flashing using the Global firmware. If you don't have skype pre-installed, its a good idea to flash it using a global version since it includes skype.

Things needed
1. RX-51_2009SE_10.2010.13-2.VANILLA_PR_EMMC_MR0_ARM.bin
2. RX-51_2009SE_20.2010.36-2_PR_COMBINED_MR0_ARM.bin
both of which can be obtained from
3. flasher-3.5 which can be obtained from
For detailed reference you can goto maemo wiki.

Flashing procedure
1. Install maemo-flasher.
2. Switch off the device, press 'u' on the phone's keyboard and plugin via USB. The phone will boot with a USB icon on the top right corner.
3. Run the following commands as required.

NB: The commands for flashing are (in order):
flasher-3.5.exe -F "path to eMMC image (vanilla)" -f
which is for flashing eMMC, and then
flasher-3.5.exe -F "path to Combined image (fiasco)" -f -R
for flashing the OS.
To flash the OS only, run the second command (fiasco). It is not recommended to only flash the eMMC (user content). So in that case, we need to flash the OS as well.

Download the video tutorial.
If not able to view the video, install Flash Player Projector Content Debugger from Adobe and run the swf.

Friday, February 18, 2011

Office 2007 Installation Error in Windows XP

"Windows installer service can not update one or more protected windows files, installation failed" and the setup rolls back any changes. This happens because some dll are missing in your Windows XP.
1. Download fp4autl.dll and Fpencode.dll
2. Copy them to the "C:\Program Files\Common Files\Microsoft Shared\web server extensions\40\bin" directory.
3. Run the Office 2007 setup once again.

Sunday, January 16, 2011

Add Chromium to Launcher in Ubuntu

After installing chromium, you might not see "Add to Launcher" for the chromium browser in the Ubuntu Unity interface. For that to appear what you need to do is just reboot. Now run chromium, right-click the icon and you'll see "Add to Launcher" option.

Friday, January 14, 2011

Install Appcelerator Titanium in Ubuntu

Appcelerator Titanium is handy if you like to develop desktop as well as mobile (and web applications) entirely using JavaScript or other scripting languages like Python or Ruby. It supports html5 and css3. Its an alternative solution to the proprietary Adobe AIR and Adobe Flash. Yes, flash is still proprietary and the eclipse pig IDE, the Flash Builder (without which it would be an overkill to use the Flex sdk) costs like crazy.
Back to installing titanium v1.2.2 on Ubuntu 10.10 Maverick Meerkat.
1. Download the linux package from the appcelerator download page.
Mine is 32 bit OS. Note that if you have less than 4 GB of RAM, don't even bother installing a 64 bit OS, because its useless in every sense.
2. Extract it and navigate into the folder.
3. Run Titanium Developer.
You can do it by using
./Titanium\ Developer
4. Install to say your home directory.
It will download two packages and it closes.
5. Run it again (step 3).
It will throw the error:
./Titanium Developer: symbol lookup error: /usr/lib/ undefined symbol: g_malloc_n
6. cd to ~/.titanium/runtime/linux/1.0.0
7. Delete the following files as shown below:
rm libgobject-2.0.*
rm libglib-2.0.*
rm libgio-2.0.*
rm libgthread-2.0.*
Note the * at the end of the filename. There are files ending with .la*, .so@, .so.0@ etc. Its to delete all of them.
8. Also the python linked by appcelerator is version 2.5 where as in Ubuntu 10.10 it has version 2.6. So fix it.
sudo ln -s /usr/lib/ /usr/lib/

Tuesday, January 4, 2011

Spell Check in Flex Using Squiggly SDK

Squiggly SDK can be used to add spell check for your Flex components.
1. Download Squiggly SDK from Adobe Labs.
2. Create a new Flex Project.
3. Copy the libs in the SDK to the libs in the Project folder.
4. Copy the contents in the src folder of the SDK to the src folder in your Project.
5. Import the Class
import com.adobe.linguistics.spelling.SpellUI;
6. Create a text area component
<s:TextArea id="txt" initialize="txt_initializeHandler(event)"/>
7. In the initialize handler add spell check
private function txt_initializeHandler(event:FlexEvent):void {
SpellUI.enableSpelling(txt, "en_US"); //spell check for en_US
8. Done.

Download the flex project example (fxp).