Revenge

October 26, 2009 prajwalit Leave a comment

revenge[Note: This post is not about C. Its not about linux. This post is related to Front End Engineering. If you're not interested, you may skip this post.]

Yesterday I was chatting with one of my friend. Like all other people who don’t understand the difference between Java and Javascript, he was cursing Javascript for its browser behaviors. To answer him, I told him one story. A story that was created real-time based on known facts. It goes as follows -

“Long long time ago, when the web, ‘the internet’ was young, browsers and web page authors knew only one language to communicate, that is – hypertext markup language (html). As it was new, neither authors nor browsers were fluent in speaking that language. Thus these browsers would just read whatever its written in that .html page n somehow try to render it.”

“After few years a community called w3c came up with standards for html and said ‘whatever you are doing is crap. do it this way’. Browsers agreed. They released newer versions with these standards enabled. The problem here was, browsers now were trying to render page considering html file is according to standards.”

“Obviously enough, all older pages broke apart because those were not standardized. Now the funny thing here is, people blamed these new browsers, instead of web page authors. To survive in such conditions, browsers started one technique called ‘quirk’s mode’ which will show page in older version on browser if its non standard page. Nice nifty trick does the job. Everyone was happy now.”

“Few years later pages started using javascripts, css. And before any standards standardize these new things, browsers adopted these techniques as they thought these should work. Some browsers supported same functions in different ways. “

“Now after these many years, HTML, JS, CSS all these things are standardized now.. But browsers are still not adopting these standards. The main difference in two cases is, now people are blaming language/programmers now, and not the browsers that are actually causing these things to happen”.

This, I call, is browsers revenge on programmers.

- x -

Note: Ok. Agreed. JS is not perfect. but as Douglas Crockford says – If you neglect the bad parts of it saying they do not exist, Then all that remain are The Good Parts.

Categories: Geek Stuff, Javascript, html

Wammu – Phone manager for Linux

July 12, 2009 CDK Leave a comment
On windows, MyPhoneExplorer is a great phone manager esp. for Sony Ericsson’s phones. I wanted to use it in Linux so I tried using it through wine using this guide ( actually a direct install also works now.) However, although the phone connected I could not sync any data. The app kept crashing. So I decided to find something native and found Wammu. ( Google sent me to AlternativeTo — interesting site).

Wammu seems to have all the features of MyPhoneExplorer and is quite good. I especially liked the phone connect guide. The UI needs a bit of tweaking , but overall it seems to be quite a cool app. I had blogged about Multisync earlier and I think Wammu is better.

Ubuntu users can click here to install it. Its also available for Windows. You can find screens here. The list of supported phone is available here.

Categories: General, Linux

Console Junkie: Conky Makes Your Desktop Awesome!

July 4, 2009 Vedang 2 comments

What is conky?

Conky is a light-weight system monitor, which can display any information you want on the desktop. You can get it here, or you can simply install it with:

sudo apt-get install conky

If you want my conky setup though, you should compile it from source. I’ve explained why further in the post, so read through the whole thing before you go setting up your own conky. Here’s what my desktop looks like:

Screenshot-1

As you can see, I show music stats on the right hand side. I use mpd for music. Now, conky has in-built mpd support, which means using these conky variables for mpd make it faster and lighter on resources. However, these variables are disabled by default in the version available in Ubuntu repos. You won’t be able to use them if you do a sudo apt-get install conky. Hence the compile-from-source bit. If you are not using mpd for music, you might as well do a sudo apt-get install. If you are compiling from source, this is an excellent guide.

So that’s done. Next you will need to download my conky config files and other scripts required for the setup. You can download them from here. Extract them and rename the folder as scripts. I keep all my scripts at /home/vedang/Source/scripts/, and this path is hardcoded into the scripts everywhere. Please search for the string and change it appropriately.
Read more…

Categories: Geek Stuff Tags: , , ,

Treat Warnings as Errors

July 1, 2009 Jitesh 3 comments

If you are reading this blog and have even a iotic sense of humour, you must have heard (and liked) this joke:

——

A man is smoking a cigarette and blowing smoke rings into the air. His girlfriend becomes irritated with the smoke and says, “Can’t you see the warning on the cigarette pack? Smoking is hazardous to your health!”

To which the man replies, “I am a programmer. We don’t worry about warnings; we only worry about errors.”

——-

Ofcourse, I laughed my ass off when I first heard the joke. Awesome it was! But then, the last month totally changed my perception. (Probably because I faced the side-effects of that).

So, ARM architecture is very specific about alignment. It hates mis-aligned access (Its the side-effect of being an arch for embedded systems). Here is an example of unaligned access:

1 short short_arr[4];
2 long *long_ptr = short_arr;
3 blah = *long_ptr;

since the data type of short_arr is "short", gcc forces only a 16-bit alignment on the array (on 32-bit systems). but then, long_ptr is probably 32-bit and that screws up alignment for line 3. Although, i386 would work perfectly fine (but require one extra memory cycle), ARM will just give garbage data (if misaligned).

And many many many software packages are filled with such errors. Just to give you an example:
# cat /proc/cpu/alignment
User: 1265555

(this file is present only an ARM architecture because of ARMs peculiar alignment requirements)

See the number of alignment errors?
Packages like mhash (which calculate hash) build fine but fail run-time, this makes such errors difficult to track down.

So, always make it a point to compile your C programs with "-Werror" option. It treat warnings as errors. It is *very* important for your programs to work on just about any platform. Please pay attention to warnings, because warnings are there FOR A REASON. gcc developers aren’t stupid!
(Although sometimes, you might be sure that even if gcc warns about misalignment, the access is aligned. eg, when you typecast an IP struct into a MAC struct, etc. These are the *only* times you can let go off the -Werror option)

But, until this point sinks into the mind of every developer, there’s no option but to live in this mess. :(

Categories: Geek Stuff

Giving the HOME directory it’s own partition

June 28, 2009 Vedang 3 comments

The more you use linux, the more you begin to realise that your HOME directory should be on a different partition from your ROOT directory. This way, your config files remain unaffected by system crashes, OS reinstalls etc. Now _if_ you started out without a separate partition for your home directory, here’s how you can rectify the problem.

Basically, we have to do three tasks.
1) Choose a partition for your HOME directory
2) Copy ALL files from your current home to this new partition
3) Make an entry in fstab to mount this partition as /home on bootup.

We’ll be using a tool called GParted to make our life easy.

sudo apt-get install gparted

Yes, it’s a GUI tool and yes, I also know how to do the same things in a more complicated way using pure CLI. However, this is a beginner guide. So I’ll leave that part as an exercise for the interested reader.

Right! So lets get started:

1) Choose a partition for your HOME directory

a) Run GParted. You will have to use sudo, as you need root privileges to use gparted. gparted messes with your partitions, so don’t fool around unless you know what you are doing.

b) Select the partition. It obviously has to have enough free space to hold all the files in your current home. You may or may not format it, though I recommend you format it with ext4 as the filesystem.

c) Note the UUID of the partition. You can do this by selecting the partition, clicking on the Partition tab in the main menu, and clicking on Information. Also note the device name of the partition (something like /dev/sda3)
Read more…

Categories: Geek Stuff, Linux