26 July 2014

Preview your webpage realtime while creating it

Wanting to see a realtime or near-realtime preview of the webpage I developed, I found only few options available (like this, this and this one). Strange that nobody mentioned Netbeans.

I'm aware of the Netbeans-Eclipse flame-wars and I happen to like Netbeans more :-) You can install it with an installer or use the portable version, it's simpler to use, simpler to get the settings of a project ready, has Git and Gradle support inbuilt and of course, has the preview option for multiple browsers and devices of varying screen-sizes. Have a look...


Choose the "Embedded Webkit Browser" option for having a preview within the Netbeans IDE itself.



When you press F6 to execute the program, the preview appears. The arrow I drew, points to the options Netbeans gives you to view the page in different screen sizes!


You also have a palette of html elements at your disposal, which you can drag and drop onto your HTML code! If you drag a table element onto your code, Netbeans creates all the relevant code for the table, at the place you dropped the table. Now isn't this cool or what!!!



Here's a look at the code. Also a side-note and a video, below



Use any IDE you like
On a side-note, any company with a mature software team, should not ask their developers to use only one particular IDE. The project should be designed to allow developers to use whatever IDE they like. Even if various developers working on the same project are using different IDE's.
Although Eclipse seems to be more widely used, you would find this video from James Gosling rather interesting. It tells us a bit about how the Eclipse hype came about (starts at around the 6th minute of the video).


19 July 2014

The advantage of compiler optimization and why it can sometimes mess up your program

Recently, I was working on a software that required high-precision computation of matrices stored in an advanced math library.
While working in the Debug mode of Visual C++, all calculations worked fine. Running the program in Release mode, gave me a "1.#QNAN" error and "-1.#IND" error. I was perplexed, because there were no changes I made to the code.

A couple of printf's showed me that the matrices which were supposed to contain small values like 0.5e-03, had been interpreted as negligible values by the compiler, and considered as zero. This caused numerous divide-by-zero errors, resulting in the QNAN and IND errors which are MSVC's way of displaying a NaN.

Here's how you can check for NaN in your program.
  • Boost has  template <class T> bool isnan(T t); under the header #include
  • If TR1 is available, then cmath includes C99 elements like isnan()
  • Here is a small function which should work if your compiler doesn't have the standard function: bool custom_isnan(double var) { volatile double d = var; return d != d; }


The solution
Going to "project properties > C/C++ > Optimization" and selecting the "/Od (Disable)" option prevented the compiler from optimizing away the little numbers to zero and the program worked fine in Release mode.


How compiler optimization can be helpful
A bit of background research led me to an article of Mr.Scott Robert Ladd on Dr.Dobbs. He said:
An optimizing compiler performs an analysis on a program being compiled, generating a more efficient program. Optimizers can delete unused code and variables, improve register use, combine common subexpressions, precalculate loop invariants, and perform other tasks that improve program performance.

At best, optimizing a well-written program will improve its speed by as much as 25 percent. An optimizer will not replace inefficient algorithms with better ones. As the saying goes, "garbage in, garbage out." Most of the responsibility for a program's performance lies with the programmer. Improving algorithms and manually optimizing a program will often increase program speed by several orders of magnitude. The purpose of an optimizer is to make sure that the compiler is producing the fastest code possible from your source code.
          /O1 optimizes code for minimum size.
          /O2 optimizes code for maximum speed.
          /Ob controls inline function expansion.
          /Od disables optimization, speeding compilation and simplifying debugging.
          /Og enables global optimizations.
          /Oi generates intrinsic functions for appropriate function calls.
          /Os tells the compiler to favor optimizations for size over optimizations for speed.
          /Ot (a default setting) tells the compiler to favor optimizations for speed over optimizations for size.
          /Ox selects full optimization.
          /Oy suppresses the creation of frame pointers on the call stack for quicker function calls

Optimization might not always be the best option for you, especially if you're working with high-precision calculations. There are places where an optimizer can optimize away calculations to improve speed.
Eg: If you use ++i (which is faster) instead of i++, it might not actually be of much consequence, because modern compilers would optimize it sufficiently to make the i++ equivalent to the ++i.

p.s: In Visual Studio project settings, if you ever need to use similar settings for Debug and Release mode and you want to avoid having to change the string "Debug" to "Release", then just use the variable "$Configuration". Visual Studio will substitute the string "Debug" or "Release" into "$Configuration", depending on which build configuration you choose.

16 July 2014

Solving the IMAP synchronization problem

If you're using a mail server like Zimbra, which uses IMAP and synchronizes emails between the server and the local machine, it could get disappointing when you delete an email on your local system (if you're using Thunderbird or Outlook) and you see that the mail got deleted on the server as well, or vice versa.

A smart colleague of mine, Ancelot Mark Pinto (who also happens to be the one who un-knowingly introduced me to Thunderbird), found a way to circumvent this problem.
His simple solution was to create local folders in Thunderbird...


and create a mail filter to move or copy incoming emails to the local folder. Note that moving the email from the folder that Thunderbird synchronizes with the server will be the equivalent of deleting it from the server (but the local copy will still be there in the folder you moved it into).



I improvised on it by also creating a filter which moves outgoing mails to the local folder too. [update: turns out that you'll have to run this filter manually. Moving the files yourself would be faster than opening up the filter and running it]


Of course, you wouldn't have to go through all this trouble if your IMAP based email server has the ability to configure synchronization (unfortunately Zimbra doesn't seem to have this facility).

In Outlook, you can create mail filters by creating a rule (personally, I've found Thunderbird to be far better than Outlook, in terms of usability, mail filters, extensibility via add-ons, themes, search capability and speed. And then there's the advantage of it being free and open source!).

What's special about IMAP?
Out of curiosity, I found that the POP (now POP3) protocol, can be used only from one mail server and all operations you perform on the emails, will be done on your local PC, after you've downloaded the email from the server. 
IMAP on the other hand, can have a single storage location that can be accessed from multiple mail servers. Besides, IMAP allows you to keep all emails on the server and constantly synchronizes the local copies and the server copies (which is why if you use the filter to move emails out of the inbox as I've shown above, IMAP thinks that the file got deleted, and the server copy also gets deleted). IMAP also downloads an email to the local machine completely, only when the User tries to open that particular email.

11 July 2014

LOL

Continued from the previous LOL page.


Malayalis sitting
share with this link




On-screen deaths
share with this link


Continued in the next LOL page
 
 
 

07 July 2014

Build a good reputation for volunteers

What comes to your mind when you hear the word "Volunteer"?

Some people think
  • "Hmm...volunteering is some nice thing to do. Something that people consider a noble cause" .
  • or "Err...I don't really know, but lemme participate and see"
  • or "It's one of those events with free t-shirts, caps and snacks, right? I'm in!"
  • or "It's an event where people put in their effort to make the world a better, more caring place"
  • or "Oh! That activity which is a goddamn waste of time! Nothing changes"
  • or "Searching for a bunch of scapegoats eh? Not me!"
  • or "I just want to do my bit for society"
Now what would come to your mind when you hear the word "Google"?
  • "Awesome!"
  • "Best search engine ever! Did you see today's doodle?"
  • "Hey, Google is launching xyz! I can't wait to start using it!"

Notice the difference? It's the brand value of the word. A reputation.
With time, Google has built for itself a splendid reputation with very good quality products and the best intellect on the planet!
But for volunteers, there's a mixed reaction. Why?

How people begin volunteering groups
Some people I know, began volunteering when they actually saw some area of society that badly needed to improve and got together friends/acquaintances, formed a group and started volunteering. No motive for fame. No motive for money. They just wanted to improve things or help someone who was helping society. This is real volunteering.

The other way is when people are asked to start a volunteering group and they catch a few people and ask them to become volunteers or ask them to start a volunteering group. These hapless people have no other option other than to do what they were ordered to do, and without a clue of what they're doing, they form a group of people who are usually forced to volunteer in a similar way and rather than evaluate areas of society where their help is truly needed, they go about mechanically performing what they call as volunteering activities and end up creating volunteering events which nobody really cares about, but you'd always see a bunch of people excitedly saying that they were part of a "noble cause" (often not even knowing why it's a noble cause). I call them non-volunteers.

Not all groups are like that though. I've seen some where they actually do care. They actually do take steps to improve the livelihood of people. They evaluate situations, brainstorm, connect with people who genuinely want to help, form guidelines and measure how they've progressed. Like the first group of people, this is real volunteering too.



Non-volunteers aren't actually welcome in many places
When you go to a place as a group to volunteer, you'll obviously be welcomed. People tend to try not to be rude to you. But when you go alone, you hear from people, the hard truth. I've been told by certain people, how they dislike having volunteers around, because "the volunteers just did some time-pass and went away". Or about volunteers who had to spend fifteen minutes doing volunteering and they looked at their watch and said "ok it's 13 minutes already. By the time we walk to the gate, it'll become 15 minutes".
People at these places can easily recognize which volunteers actually care and which don't. You'll only be breaking their hearts if you don't intend to help long-term. If your intention is just to donate something that helps them, then first ask the representative what they really need, and give them exactly that.

What people have to realize, is that non-volunteers aren't actually there because they wanted to. Somebody forced them to, so you can't really call them a "volunteer". When people grudgingly do the so-called voluntary work, they try to find ways to balance the sense of injustice they've been put through, by making the process more fun and entertaining (or by doing things for the namesake of it). There's nothing wrong in bringing some fun and excitement into volunteering, but it does become a problem when people focus only on this cream of the cake and forget the actual cake itself.
No wonder non-volunteers are disliked!

The alternative
The very act of being forced by someone to volunteer, is what corrupts the foundation of goodness and goodwill with which a volunteer offers their services to society. When you want to start a volunteering group, no matter how much of pressure you're under, please don't force people into it. Instead, either start volunteering yourself and set an example or join an existing good volunteering group and start volunteering with them. A fair bit of word-of-mouth advertising is also required to let people know and join in.

A volunteer or a volunteer group will have a good reputation when they have:
  • Good knowledge of what they're doing
  • and when they bring a lasting positive change in society by thinking, planning and doing things, long-term.

From my experience in volunteering, this is some of what I've learnt:
  • Don't think you're doing a favour to someone by volunteering. As a citizen of your country, you're enjoying many comforts of society. It's your duty to keep it a good society and to help others who don't yet have that privilege.
  • Volunteering requires genuine care, time, dedication and hard-work.
  • Encourage people to adopt volunteering as a way of life.
  • Don't volunteer just because someone told you to or because of some policy you have to follow. Do it because you really feel like wanting to do it.
  • Focus on one objective you want to achieve, rather than on many.
  • If you feel you've got no time to volunteer, then I assure you, you've misunderstood what volunteering is (I'll explain more in future blog posts).
  • Build a good reputation for volunteering, by doing work that actually helps society. This is done when a volunteer educates themselves about the field they're volunteering in, analyzes, consults experts, takes the help of more people, utilizes their core competencies and builds a framework with a long-term vision of sustainability. I have seen volunteers who do this, and these are the volunteers who have my utmost respect and admiration!

The next time someone says "Volunteer", let it have a positive response from everyone. There's a lot to be done to create this good reputation. How about starting right now!


_____________________________________


More on volunteering

Say thank you or donate

05 July 2014

Adios amigos, Orkut

It was today, that I received an email saying that Orkut was shutting down.

To preserve your memories of Orkut, use Google Takeout to save your account into a zip file (you'll be able to do this only until September 2016).

If you've created communities on Orkut, you should know that Google will create archives of the communities that are public (communities that aren't public won't be included in the archive), so it will still be available on the internet as read-only archives. Individuals can login to Orkut (before 30th September 2014) and delete posts they don't want as part of Google's archive.
You can't transfer communities to Google+. The Orkut mobile app will stop working, and nobody can create new Orkut accounts from 30th June 2014 onward (oops, it's already July).

Nostalgia. That's the word that describes a place I found many of my friends again, shared memories with them, created the Stage Anchoring community which helped numerous newbies who were afraid of speaking on stage, became moderator of the Ipe/Iype community and had fun. For some people, Orkut means a lot more.
Faking news came up with a funny article on Orkut's funeral, ending it with
A highly placed source within Google tells Faking News that servers of the search engine will not perform any search operation during the entire event.

Named after its creator, Google employee Orkut Büyükkökten, Orkut has been around for 10 years, and very popular in India and Brazil. I still remember the time that friends were encouraging everyone to move to Facebook, and I didn't want to, because Facebook's UI was much more difficult to use than Orkut's. Of course, things have changed, and the domino effect of people abroad using Facebook and (probably) thus, the practice of others in India too joining Facebook continued.

Apart from it's controversies, Orkut had also introduced nice features like "fans", testimonials (did you know this feature was introduced to find out which profiles were genuine) and a funny feature where you could mark a person as someone you had a crush on, and if that person also did the same to your profile, both of you would get notified of it.

For me, Orkut is primarily about the communities I created and moderated. Some screenshots:


Really, this was just for fun. Glad both ended up getting an exactly equal number of votes :)

This nice community was created by Ashish Ipe





And a special testimonial from a college-mate who admired how I used to win prizes in college fests in college and in neighbouring colleges. Also because of the hobby project I won.


June 15, 2006:
"Ace of Kalpatharu Institute of Technology...The jack of all traits n some of we guys call him master..You talk of talents b4 him n u get into a super market. Oh man, he is juss a programming freak. Being a mechie mechie its kinda unusual but there is lot much in store behind dis innocent face. He is a total sellout @ college fests n not only me but our gang being d prima facie of it..hey master be innovative as u are n be in touch.."


Well, a big thank you Orkut team, for the connections and memories you created!!!