What is linked list and how pointers work?

Today, I was talking with one of my friends about how we studied data structures in freshmen/sophomore years and how some troubled in understanding pointers. Joel probably says that, it is an aptitude that not everyone can have. So, just then an analogy for linked list hit in my imagination and my friend told me to write about it.

Think of a treasure hunt:
– You are given an address of a house, you should start by visiting there
– In each house you will find an address to another house, you have to visit that house next
– At some point you will reach a house which do not refer to a next house; your treasure is in that house

Traversing a (singly forward) linked list works exactly the same way.

Hope this analogy helps.

Anguish of BANGLA (script) lost amongst English (alphabet)

Once, I made LikhonPad for phonetically typing Bengali (type using English keyboard and let it convert to Bengali). I never liked phonetic typing, so I ended up building Sonnivo - a very QWERTY like Bengali touch typing keyboard layout. Meanwhile, Avro (a smart phonetic typing tool) became much popular and let Bengali people write Bengali (in English, but finally rendered in Bengali). Then there came, keyboards for mobile phones too.

Yet, people tend to write Bengali, not using Bengali Script but English (subset of Roman) alphabet – which always renders horrible looking text pieces – I cannot bear reading them.

I often thought of building a JavaScript extension for Firefox (and for other browsers, for those to whom it mater) that will convert English-encoded Bengali for us.
The primary problem in building that tool is, I never freaking found time for it, and I often don’t freaking care to give a head to something written in roman letters but is Bengali.
But, naturally, the actual solvable problem will be to define a set of grammars (hence automata) for transliterating En characters to Bn. Nevertheless, everyone do not use same grammar, moreover same person would use different grammar from time to time. Thus, a solution will be to use some AI/ML/DM for this.
Sounds like, a rather much complex solution for a way to easy problem, right?

Then, WHY CAN’T YOU PEOPLE WRITE BENGALI IN BENGALI SCRIPT?

Read_file_bytes

Yesterday, I needed a tool for reading files as bytes. Hexdump programs generally do some formatting and stuff. I did not want that. I wanted to have a straight forward, simple sweet tool, that simply reads a file and prints it’s bytes. Time required for searching such a tool is indeed greater than the amount of time you can simply write a tool by yourself. I wrote the following:

/* read passed file and show bytes in hex val, consicutive each byte */
/* Released in Public domain by nafSadh.khan */
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	FILE * pFile;
	int c;
	int n = 0;
	if (argc < 2) return 0;
	if (strlen(argv[1]) < 1) return 0;

	pFile = fopen(argv[1], "r");
	if (pFile == NULL) perror("Error opening file");
	else {
		while ((c = fgetc(pFile)) != EOF){
			printf("%02x",c);
			n++;
			if (n % 32 == 0) printf("\n");
		};
		fclose(pFile);
		printf("\n");
	}
	return 0;
}

Next time, I am not re-writing this same program though.

Just another comment on Tablets

Today one of my friends was asking on Facebook, what are the utilities of Tablets? I commented what I thought about it, and here it follow:

Until Surface came, tablet was immature. Now, it is getting a shape and user base too. Here, at US, I see a lot of people using tablets. They have a certain, limited, but handy use case. First of all, tablet is light, weighs light and performance is low too. It is designed to be single app threaded (user will focus on one app at a time). You can use tablets while you are on the move, say attending a seminar, waiting somewhere or just not on our desk. Laptops are portable, but those ones which you can carry around with offer too small a view port (13″). They are relatively useless compared to their price range and weight.
If for only reading ebooks kindle (ink based) are best. But, tablets let you browse too.

With all these limited use cases, you can always be happy by having one tablet as your tertiary device, after your computer and phone. For tablets, I prefer Surface, probably Pro. Android tablets are still crappy (you need a great touch screen on tablets if you don’t get a real keyboard). Apple’s tablets are on per and could be best for most users.

I am currently settled with a mid weight, high performance laptop – which gives me most of the computation power I need, yet allowing me to carry it around if I have too.

Next, when I am going to change my setup, I’d like to have a full fledged desktop as primary device and a Surface Pro as on the fly device and probably a Nexus or something light as phone and no laptop.