Ubuntu apt-get install error

I tried installing few packages using apt-get on my Ubuntu machine and it kept failing and also the Ubuntu Software Center kept crashing on launch.

Error

Error

Reading package lists… Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/archive.canonical.com_ubuntu_dists_precise_partner_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

To fixed the issue by deleting all the package lists files inside “/var/lib/apt/lists/” and downloaded the package lists from the repositories and “updated” them to get information on the newest versions of packages and their dependencies (sudo apt-get update).

sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update

This seemed to fix the problem. Not sure what was the reason for the corruption of the files in the first place.

Advertisements

Splitting and joining files in Macintosh and Linux

There are lots of tools available on PC (Windows) for splitting and joining files. There are very few available on Macintosh and Linux. But on Macintosh and Linux we don’t really need a separate tool for splitting and joining files the OS comes with one for us.

Splitting and joining files are pretty straight forward. There are two simple command line tools to do it. In this entire exercise we will be using only 3 command line tools.

1. Change Directory.

cd – change the current working directory to a specific Folder.
SYNOPSIS
cd [-L | -P] [directory]

2. Splitting the File.

split — split a file into pieces
SYNOPSIS
split [-a suffix_length] [-b byte_count[k|m]] [-l line_count]
[-p pattern] [file [name]]

3. Joining the File.

cat — concatenate and print files
SYNOPSIS
cat [-benstuv] [file …]

Lets get down to business and start splitting the file.

File Split
I didn’t have any big file to try the commands on. So I compressed Google Chrome application.

Created Google Chrome Zip File

Get into the folder containing the huge file using cd (change directory) command

cd path/to/the/folder/containing/file
split -b 50m “Google Chrome.app.zip” ChromePieces

“Google Chrome.app.zip” -> Name of the file to be split
ChromePieces -> Prefix of output file name.
-b -> Create smaller files byte_count bytes in length.
50 ->byte_count value.
m -> indicates megabyte pieces. k can be used instead for kilo-byte pieces

Used “split” command to split the file

The zip file size was 93.1 MB. So it ended up creating two files. As can be seen from the image above.

Joining Files

Used “cat” to join the files

cat ChromePieces* > Chrome.zip

We are joining all the files that have prefix file name “ChromePieces” and the resultant file will be created as Chrome.zip

A new (Chrome.zip) file is created.

Unzipped the newly created zip file.

You can unzip the Chrome.zip file and Google Chrome application extracted would work as normal. Split and cat can be used on most of the files. I have tried it on binaries(Application & Installers), Audio and Video Files, Text files.

Ubuntu: Super Cow Powers

When I first thought of using Ubuntu I was warned by some of my friends that it would not be a pleasant experience but I decided to take the plunge. Now after few months of using Ubuntu. I can assure you there weren’t many hassles. On the contrary I found out that Ubuntu has a good sense of humor too. To illustrate it, consider the two commands

apt-get
aptitude

They are used for installing and uninstalling software on Ubunu. I was curious to find out the difference between these commands, Since they performed the same task.

First I typed “apt-get” and in the response I received the text “This APT has Super Cow Powers.” caught my eye.

Next I typed “aptitude“. It didn’t give the desired results. So I typed “aptitude -23“(You can type any wrong input) and this time I got another text “This aptitude does not have Super Cow Powers.“.

I dumped what I was looking for and decided to investigate the “Super Cow Powers” and I came across few Easter eggs in apt-get and aptitude. I have listed some of them down for you.

1. Type “apt-get moo

2. Type “aptitude moo

3. Type “aptitude -v moo

4. Type “aptitude -vv moo

5. Type “aptitude -vvv moo

6. Type “aptitude -vvvv moo

7. Type “aptitude -vvvvv moo

8. Type “aptitude -vvvvvv moo

If you want information on difference between apt-get and aptitude visit aptitude versus apt-get. I didn’t discover all the above Easter eggs on my own. I found it in the thread Super Cow Powers vs No Super Cow Powers. Lastly I would like to thank Bharat Pawar was convincing me to find out more about “Super Cow Powers”.

New Rupee Symbol of Indian – How to use it in Computers.

You can download the Rupee_Foradian font file from Rupee_Foradian.ttf

Installing and using on Linux

1. Copy Rupee_Foradian.ttf file to /home/Home_Name/ .fonts/ (create this directory, if not exists)
2. Open any word process applications (like open-office, Thunderbird etc), choose “Rupee Foradian” from the drop down box of fonts (If it was already open, restart the application).
3. Press the key just above the Tab button (with “~” symbol) to get the rupee symbol (`)

The button to press

Installing and using on Windows

1. Copy Rupee_Foradian.ttf file to OSDrive:/Windows/Fonts. Normally it would be “C:/Windows/Fonts”. When you paste the file to this location, OS would display say that it is installing the font.
2. Open your word processor and select the “Rupee_forindian” (If it was already open, restart the application).
3. Press the key just above the Tab button (with “~” symbol) to get the rupee symbol (`). Refer the previous image

Installing and using on Macintosh

1. Copy Rupee_Foradian.ttf file to /System/Library/Fonts if all the users need to use it and for a single user it should be /Users/Home_Name/Library/Fonts
2. Open your word processor and select the “Rupee_forindian” (If it was already open, restart the application).
3. Press the key just above the Tab button (with “~” symbol) to get the rupee symbol (`). Refer the previous image

NOTE: Since it is a true type font am not sure whether it will work on Tiger(10.4) version of Macintosh. There shouldn’t be any problems in Leopard(10.5) and Snow Leopard(10.6) version of Macintosh.

It's working!

The images and Windows OS installation is thanks to Joanne Debrass and Linux OS installation is thanks to Satheesh Prabu.

Missing days and Fools’ day

Have you every used cal command on Linux and Unix. Well those of you, who haven’t cal stands for calendar. It shows the month/years calendar.

I recently got a mail from my friend Pearl Fernandes. It had details about some missing days. The days were missing in the month of September in the year 1752(09/1752).

Not the one to accept the fact given by others I decided to give it a try to typed

cal 9 1752

on the terminal of both my Linux and Macintosh machine.

I found the following baffling results. The day following September 2nd is September 14! Strange but it’s true.

Calender on Macintosh

Calender on Linux(Ubuntu)

I didn’t have to work hard to find out the reason. Pearl’s mail had an explanation for this too. I verified the facts but there are multiple theories for this. The one below is one of the theory

Explanation :

A month with whole of eleven days missing. This was the time England shifted from Roman Julian Calendar to the Gregorian Calendar, and the king of England ordered those 11 days to be wiped off the face of the month of September of 1752. (What couldn’t a King do in those days?!) And yes, the workers worked for 11 days less, but got paid for the entire 30 days. And that’s how Paid Leave was born. Hail the King!!!

Before that April was the first Month of the year. Even then people didn’t agree to use the Roman Julian Calendar and celebrated 1st April as a New Year then the King announced that, those who celebrate April as the New Year are fools… (April fools…)
Histories are really interesting!!!

So now you know the origin of Paid leave and April Fools’ Day. Hopefully I get few days of paid leave this August.

NAN (Not a number)

This post basically deals with C++ and NaN. NaN(Not a Number) is a value of numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations.

I picked this list up from the wiki page.
Different representation of NAN

nan
NaN
NaN%
NAN
NaNQ
NaNS
qNaN
sNaN
1.#SNAN
1.#QNAN
-1.#IND

I have come across NaN and NaN% on Macintosh. I had seen NaN% on 10.4(Tiger) when I had my calculation go bad and ended up dividing a number by zero. That code was written in C++. Recently I saw NAN while debugging a piece of code written in JavaScript, this was on 10.6(Snow Leopard). So most probably representation of NAN has something to do with the operation performed or may be Apple has changed the representation of NAN in Snow Leopard

I had spent few days working on an interface to Web-kit. Where in I was receiving data provided by the java-scripts running on web-kit. I came across the NAN problem.


The code :

var valueInField= parseInt(document.getElementById(“field”).value);
var value = set(valueInField);

Now if the input value to “field” is a string and “parseInt” would convert the value into NAN. Although Nan stands for Not a Number it is represented as floating point number, so my checks went for a toss.

While looking for fix I came across a method defined in math.h for NAN checks.

isnan(floating_value_to_check)

This function is part of C99, it may not be available everywhere.

According to the IEEE standard, NaN values have the odd property that comparisons involving them are always false. That is, for a float f, f != f will be true only if f is NaN.

So I wrote a piece of code

if (float_val != float_val)
printf(volatile);

I didn’t have to use this check extensively, but if it has to be done many times it would be good to use it as an inline method

inline bool isnan(double x)
{
return x != x;
}

Viusal C++ does not provide neither std::isnan nor std::tr1::isnan, but it provides an extension function defined as _isnan().

On Xcode(Macintosh) it is a little confusing, it not only provides std::isnan but also provides __inline_isnand()(on Intel machines) and __isnand()(on Power PC). Read these post for more clarifications post 1 and post 2.

On Arjun’s request:

I have attached the image showing Nan. The code was debugged using Firebug plug-in for Firefox web browser.

Building Froyo on Snow Leopard

There have been few changes in Froyo source code since this article was posted. Please Refer to this page for issues and solutions related to building Froyo on Snow Leopard.

My efforts of building Froyo on my Snow Leopard turned out to be a bit of anti-climax. I anticipated lots of errors but mercifully Android team has pulled up its socks, there weren’t any error. Bharat did the building on Linux and he had no issues either.

But I do have a complain, Froyo uses java 1.5 and not java 1.6. Android should move on to newer version of java. Anyway complains apart let me put down the steps.

I would like you to read my previous blog on building Building Eclair on Snow Leopard. There are 13 steps in that blog. Follow all the steps other than step number 4.

Once you have done that type
. build/envset.sh
tapas
make -j2 sdk
and watch it fly.

I have attached few of the snap shots.

Up and Running

Home

Oops camera crashed!!!!!

The camera crashed on both Linux and Macintosh. I have been told by a friend that it was crashing on the sdk released earlier.

Wow!!! Hindi, can't wait for other Indian languages to make it

Language : Hindi. But we still need Hindi strings for it.

I hope somebody puts in Hindi strings for Settings applications. I can’t tell much about performance since I was using the emulator.

Hopefully next release moves to Java 1.6 and we would actually have full pledged support for Hindi and other Indian languages.