28 February 2016

National science day: The cultivation of scientific temper

Today was Breakthrough Society's celebration of National Science Day and the observation of the "Cultivation of scientific temper". It included many school children and adults who were invited to the Raman Research Institute at Bangalore for a seminar and an exhibition.





It was my first visit to the campus, and I just loved the beauty of it. Reminded me of Bangalore, the way it was before concrete, asphalt and smoke took over the city!




The conference touched upon topics of scientific importance, about the need for research in India, the realization that people should have about science and the way it impacts humanity and an appeal that people go through some trouble in life; even if it involves some amount of struggle, so that their research and discoveries can bring greater good to humanity.

The seminar was followed by a documentary on Dr.C.V.Raman's life.




and a visit to the science museum, where there were various exhibits and publications of Dr.C.V.Raman.

We were shown how Dr.Raman (at the age of 16 or 17), had questioned why the Veena sounded like a human, and pursued the question. Even though Helmholtz had said that a plucked string could oscillate in only an odd number of ways (1, 3 or 5) etc..., Dr.Raman went on to prove that the Veena could even oscillate in even numbers, hence producing sounds similar to that of a human. This was because Helmholtz had experimented with a Violin, whereas the strings of a Veena are strung very differently, and when plucked, they oscillate differently.

Dr.Raman also dropped a metal bearing on glass and noticed the circular crack it made on impact. He tried the same on quartz crystals and noticed that here, the cracks were triangular in shape. Typical scientist :-)

The science museum has a large collection of objects he studied and collected. Said to be the largest collection any scientist has. Photos were forbidden since they said that if the photos were shared on social media, that would dampen the curiosity of the children. I disagree. The collection is so unique and amazing, that people would actually want to send their kids to actually see it. Believe me; there are no photographs that can capture the glimmer and wonder of those stones which are captured by the eye.

Also on display were some interesting quotes:






There was also an interesting quote from Einstein, which I followed up on:
I have now reached the point where I may indicate briefly what to me constitutes the essence of the crisis of our time. It concerns the relationship of the individual to society. The individual has become more conscious than ever of his dependence upon society. But he does not experience this dependence as a positive asset, as an organic tie, as a protective force, but rather as a threat to his natural rights, or even to his economic existence. Moreover, his position in society is such that the egotistical drives of his make-up are constantly being accentuated, while his social drives, which are by nature weaker, progressively deteriorate. All human beings, whatever their position in society, are suffering from this process of deterioration. Unknowingly prisoners of their own egotism, they feel insecure, lonely, and deprived of the naive, simple, and unsophisticated enjoyment of life. Man can find meaning in life, short and perilous as it is, only through devoting himself to society.
The economic anarchy of capitalist society as it exists today is, in my opinion, the real source of the evil. We see before us a huge community of producers the members of which are unceasingly striving to deprive each other of the fruits of their collective labor—not by force, but on the whole in faithful compliance with legally established rules. In this respect, it is important to realize that the means of production—that is to say, the entire productive capacity that is needed for producing consumer goods as well as additional capital goods—may legally be, and for the most part are, the private property of individuals.

But perhaps one of the most important quotes the community was missing out on, was this one:


It's not really about the survival of the strongest or the most intelligent. It is about the one that is most responsive to change.

My view

We see many protests in our country about growing intolerance and the lack of promotion of science. Makes me wonder why this happens. Many decades ago, it was the will of certain curious people which helped them make discoveries, helped the world to advance and brought pride to the nation. Any government would be happy to encourage such people and I believe this is why science was given importance. This is why we had impressive research institutes and dedicated people.

It created value for the nation.

As the years passed by, did something else create more value for the nation? Did research cease to add as much value as something else? Did our nation become self-reliant enough that it no longer needed science? Is it more economical to purchase a technology from a neighboring nation than to invest in our own research? Does the work of private enterprises add more value to our nation?

As Darwin's quote in the above picture says; it is the species that is most responsive to change that survives. Has our scientific community adapted to the changes? We live at an age that has seen more peace on Earth than in historical times. Is this an age where the entire world works as one (except North Korea)? Where research in basic sciences, can be done at select countries so that other countries can focus on other things? Does a country really need to worry that it is not doing enough research?

What exactly is the bigger picture here? I'm quite sure that if a nation needed more research, the government would have actively pursued it. If a government isn't doing so, there's a reason. What is that reason?

Is our advanced, industrialized society really deteriorating (as Einstein said) and becoming focused on the trivialities of life?

I believe things will change. Not by dissent; not by protest. The change will be brought about by a mind that conceives such a thought, that it would alter the very way we live our lives. In the same way that a hundred years ago, everyone who predicted the future did not in the least bit take into account or conceptualize the advent of software.

There is hope.

27 February 2016

Descriptive names

We've all been through our initial programming lessons, creating for loops as for(int i = 0; i<10; ++i) and so on. float s = d / t.

Variable names didn't matter much then.

The confusion begins, when you enter the professional world, write large programs, forget about them and months later, look at the code and wonder what in the world you had written long back. Class names, variable names and function names don't make any sense at all!!!
If you took care to write comments, then they are a saving grace, but only for a while.

Which of these would make more sense to you?

//check if customer age is equal to threshold
void check(double v
{
   if (val == v) {print("yes");} else {print("no");}
}

or

void checkIfCustomerAgeIsEqualToAgeThreshold(double customerAge
{
   if (ageThreshold == customerAge) {print("yes");} else {print("no");}
}

See the difference? No need of comments. No confusion. You understand what the function and variables are there for, just by looking at the code.

The other big advantage is that if you decided to do some refactoring, you wouldn't have to bother changing any comments, because the class/function/variable name itself is the comment!

Same goes with macros.
I see a lot of C++ programmers using...

#if 0
//some code
#endif

...to temporarily deactivate some code. If these programmers get hit by a bus or even if they look at the code many years later, they won't have a clue of why the code was deactivated and whether it is ok to simply delete it.

What if they used this instead:

#ifdef YEAR_CALCULATION_CODE_TEMPORARILY_DEACTIVATED_DONT_DELETE
//some code
#endif

or

#ifdef CODE_FOR_DEBUGGING_DELETEME_ANYTIME

or

#ifdef SWITCH_ON_COLOR_OUTPUT


Same goes with class names. Which makes more sense?:

class Filter{}
class MicroFilter extends Filter {}

or

class AirFilterSuperclass {}
class SpecializedMicroFilterOfCompanyABC extends AirFilterSuperclass {}


  • It makes a world of a difference to the person who maintains the code.
  • It makes another world of a difference to the person who reviews your code.
  • And it makes an entirely different world of a difference to the business that profits because developers, tech leads and QA teams spent lesser time figuring out the code and spent more time in being able to create a splendid product!

08 February 2016

Aha!

 Continued from the previous Aha!


Signatures
Share with this link




After the sneeze
Share with this link



Continued in the next Aha!

22 January 2016

Aha!

 Continued from the previous Aha!


The game of life
Share with this link





Choices! Choices!
Share with this link




Continued in the next Aha!
 
 

12 January 2016

Files and folders to add to gitignore for a Netbeans project

You're obviously on this page because you're a Netbeans fan. Congrats for choosing it over Eclipse!

When it came to creating a .gitignore file for my Netbeans project, it was hard to find resources on the internet to figure it out. Needing to push and pull to a Git repository meant that I shouldn't mess up my colleague's or my project settings, but still be able to share code.

So after some trial and error, these are the files I figured that need to be added to .gitignore.


/.project
*.o
*.o.d
/build/
/dist/
/lib/
/nbproject/private/
/nbproject/Makefile-Debug.mk
/nbproject/Makefile-impl.mk
/nbproject/Makefile-Release.mk
/nbproject/Makefile-variables.
mk

/nbproject/Package-Debug.bash
/nbproject/Package-Release.
bash
.dep.inc

DefaultComponent.mak
DefaultConfig.cg_info
MainDefaultComponent.cpp
MainDefaultComponent.h 


Some interesting trivia about the Netbeans-Eclipse war from James Gosling himself: http://nrecursions.blogspot.com/2014/07/preview-your-webpage-realtime-while.html#useanyideyoulike

03 January 2016

A bashrc for Windows!!!

Today I came across a script I had written long ago and had completely forgotten about. Once you start using Linux, you'd want pretty much the same functionality in Windows. So I had created a bashrc equivalent for Windows.

Create a file named WindowsBashrc.cmd and follow the instructions in the comments below (REM is the short form for "Remark", and it's the equivalent of a commented out line. REM is used in BASIC and Windows batch files for commenting out lines). These are the steps.

@echo off

REM This has to be enabled in [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
REM "AutoRun"=C:\pathToYourFile\WindowsBashrc.cmd
REM It basically makes this script run whenever a command window is started


@echo "Hi Nav. Missed you! :)"
@doskey ls=dir
@doskey f="cd.."
@doskey ff="cd..;cd.."
@doskey fff="cd..;cd..;cd.."
@doskey ffff="cd..;cd..;cd..;cd.."
@d:




btw, in Linux, thse are some handy bashrc aliases you can use: http://nrecursions.blogspot.com/2010/09/setting-up-your-bash-prompt-for-colours.html

02 January 2016

Ugly Indian: The UFO project

During the past many months, Bangaloreans began seeing the pillars of flyovers all across Bangalore getting a snazzy makeover. While I have participated in and blogged about other Ugly Indian projects...


...this UFO (Under The Flyover) project made me wonder how they painted it so neatly.

  • Who draws those white lines so accurately? 
  • How do they prevent the paint from trickling down?
  • Is it really a few hours of work?

Screenshot from Facebook

Turns out that before the orange paint was applied, the flyover pillars were covered with posters from people who obviously didn't know how to advertise.

Screenshot from Facebook

So this is not just a few hours of Saturday work. Before Saturday, before the invitation is sent out to Bangaloreans to come and paint the flyover, there are a bunch of Ugly Indian volunteers who spend many hours in removing the posters from the pillars, cleaning the pillars and then spending a lot of time in carefully painting the entire pillar!!!

That's not just a lot of work, that's a LOT of time and money too!

I wanted to know how this is done, so early Saturday morning, I visited Nagavara flyover. I didn't have time to participate, but this is what I found:


The pillars were already painted orange and white.

But a closer examination revealed...


The white lines were not paint. It's white tape.

And sure enough, a little away there were people applying more tape.


On the other side of the road, some pillars were labelled with chalk.


And if you are an early bird, you get to choose which colours everyone has to paint on the triangles.



By 11:30am, most of the pillars had been painted by volunteers wearing yellow aprons...






...and as I suspected, they had painted onto the tape as well, so the nice white outlines you saw earlier, were no longer visible. There was some paint that had dripped down too. The tape is removed eventually, leaving orange lines separating all the triangles. The bottom of the pillars, where some paint dripped down, would also be re-painted with the orange paint and I'm quite sure some volunteers would return to put finishing touches to the triangles where the paint of one triangle slightly overlapped the paint of another triangle.




These are some of the other UFO paintings. This photo was sent to many of us by email, from the Ugly Indian group.




Splendid effort!

The takeaway from this is not just about using your free time to volunteer to make this world a more beautiful place, but the takeaway is also that when you volunteer, make sure you put in enough of effort to do it correctly.

There are far too many volunteering groups in India, which do not care about going into detail. This holds especially true for corporate employee volunteering, where the objective is just to hold a tiny event for a few hours, not so that society is benefited, but so that the company is benefited because they got a chance to amuse their employees and de-stress them for some time.

When you volunteer, do it because you want to improve things. Not because you want to make a name for yourself or impress someone.


More on volunteering


Say thank you or donate

12 December 2015

Conference: Sales for startups

This time around, I decided to go for NSRCEL's live streaming option via UStream, rather than lose 2 hours of travel time toward IIM-B and back. Turned out that actually going there would have been better. Streaming connectivity was very poor. On the up-side, there was a lot of knowledge I could gather anyway (as you see below), it saved some travel time and I could type my notes into my computer in real-time.

Today's session by Prof.Ramesh Venkateswaran was what I believe is one of the most important lessons that a CEO or a sales and marketing person should learn about business.


Perception vs reality


In tennis, Goran Vanesevic of 2001 Wimbeldon was a wildcard entry and there was just a 4 point difference when he beat Patrick Rafter. 4 points out of 304 points!
When you are talking about world class competition, there is no virtually no difference between you and your competition.
The international competition difference between top brands is 0.001% when you compare them in terms of price and features.

When a consumer looks at alternatives, they have pretty much the same choice everywhere. Rewards are not linked to your companies capability or potential. Whether it's a billion dollar company or a small one, there is no difference to a customer. It's a commodity world. You have to survive and succeed in this market. But we still think "this does not apply to me".

Example: In order to buy car worth Rs.6 lakh, you'd expect people to take a rational decision. The professor created a chart to compare cars of that price range, and he was surprised that the difference between cars of that price range was just 1%.
He asked an acquaintance what made her buy her Ford Accent at that price. The answer he received was shocking and was a revelation into how the consumer thinks. She said "We bought the car because it had very cute headlights and because the salesman was damn nice".

That is the reality of business. 1.8 billion of research that went into the car and a grand announcement of launching the car on the same day in India and Germany, was all ignored by a customer who just went by the niceness of the salesman!

Technology has changed our lives but it is now just one more thing in our life. Commodities have been "technologized".
The professor showed us an ad of Sony Vaio being endorsed by Kareena Kapoor (actress). The ad just showed the laptop being available in different colours. No mention of any of the features that the tech guys at Sony would have worked so hard at.


What do you think this ad is about?




No, it's not about an air hostess training institution or about pens or about hospitality services or about nurses.

It's about a dot-matrix printer!!!





This is the market. This is the world today. It doesn't matter what you are doing. You need to keep customers happy and sales people are a necessary evil. Think of what can you do to make your customer's life simple. That's it. You really don't need any of the business concepts or jargon you learn in classes.
Today tech companies are like commodities and simple consumer items and commodities are like tech products.

Ultimately, whichever way you look, the customer is just buying a commodity. How do you survive? Why should a customer choose A vs B. You must have prod quality. Without that you can't succeed.


If you have product quality success is not necessarily guaranteed. If you don't have it failure is guaranteed. What makes the difference?
It's happy customers? Experience makes them happy. Experience is about everything the person goes through when they come in contact with your company.

Amazon CEO says: Today customer experience is everything (70%). Advertisement's are about visibility, but that is only 30%. You don't build a brand by advertising. It's customer experience that builds the brand. Nothing kills a bad product better than good advertising. we are in a world where every idea has already been thought of. It's difficult to be different.
"Customer's trust" is a result of a hundred things, and not the starting point to make a customer happy.


So how do you deliver a good customer experience?
It's simple: What can I do to make the customers life easier? This is your competitive advantage. For B2B, it is in making the business more competitive.

Experience is everything I go through, right from the time I get to know about your product to the time I dispose of it. It's not always about using the product.


Product strategy

Involves every element of the interaction of the customer and product.
50% people say they stopped doing business with a company because of poor customer service.
86% customers stopped doing business with a company because of bad experience.


The challenge
  • How do we stand out?
  • Why should the customer choose me?



Some examples

Indian railways example


The professor had always wanted to travel in 1st class AC in Rajdhani. It was more than the air-fare, but one day he decided to travel from Delhi. The coach was tiny and not inviting at all. This set him thinking:

Who is Rajdhani's competitor?
The airlines. So you'd expect certain minimum things in the train, as an airline customer. This was a bad customer experience.

Who is responsible for it?
It's the designers of the train. Not the coach attendant.

The coach attendant cannot do anything about it because of the way it has been designed right from the beginning. You cannot do anything downstream if you do not build experience into the product design. This kind of design-thinking is what Steve Jobs did very well.


Massage parlour example


The professor loves massages. He looked up some numbers on the internet (JustDial) and called up GreenTrends massage parlour on a mobile number at 9:15am. Nobody took the call and nobody called back. Meanwhile, a Malayali named Ganesh (from another massage parlour) calls asking if he was looking for a massage, and gives him an address. At 12pm again, Ganesh calls up to remind him of his appointment. Until now Green Trends hasn't called back.

The professor went for a massage to Ganesh's place for Rs.1200, and after the massage the person offered him some more suggestions and eventually, the professor came out spending out Rs.15000. The professor being a Palghat Iyyer, he says it's very difficult to make him part with money. But still, he spent Rs.15000.

Ganesh's sales pitch did that. He extracted out that much money and the customer was happy. In a place where there are so many other massage parlours, he grabbed an opportunity which wasn't even there for him. GreenTrends on the other hand, lost a lifetime customer. Customers aren't going to come and tell you "please take my money".


Taxi driver example


This is about a commodity called "a taxi". A taxi driver (Sheikh Ahmed) once just offered a taxi ride to the professor. An illiterate guy without a website or much of technology knowledge. What he did provide, was a very reliable taxi service with SMS'es at every stage of engagement with the customer.

The engagement SMS'es:
  • Will be at airport at xyz time
  • Am waiting at entrance
  • Will be at residence tomorrow morning at xyz time
  • Will wake you up at xyx time
  • Picked up your guest. On our way
  • Happy Diwali
  • This is to inform you effective.. taxi fares are going up...
  • Wake up call

He just used a phone to create a reliable service for the professor and he's always on time. Now the professor's whole community uses Sheikh Ahmed.
If you calculate the lifetime value of customer that Sheikh Ahemed has got, you'll notice that he has knocked off more money than the massage parlour guy, and customers are happy!

This is how you look at sales and opportunities.


India post example

There was a letter delivered to the professor, and the envelope just has his name and the pin code mentioned on it. Nothing more than that. The postman does not know him either.
The post office department had every reason and were completely justified to throw that letter into the waste-paper bin, but they didn't. They ensured that it got delivered.
Why did the postman deliver the letter? Does he get a promotion or ESOP or increment? No. He gets kicked around and walks all over the place.
He delivered the letter because it's important for him. Not because it's important to his boss or market share.
Do it to make the customer happy. Not for your annual report or for anything else.




The letter above was one delivered to the professor's wife, and it had the wrong address mentioned on it. See the number of seals on the letter. Would any private company have gone through so much of trouble to get it delivered? If you want business, this is what you should do. It's not about attending sales conferences and networking. You need to want to do everything for the customer, and do it happily.

We deal with a business of dealing with human beings. Sheikh Ahmed the taxi driver had used CRM to the ultimate advantage with just an SMS.

A man without a smile should not open a shop. 

The professor advises that if you are a techie nerd, stick to your computer and stay away from the customer.


Customer response

At your doorstep, when you see a sales person wearing a tie on a Sunday morning. What do you say?

You say: "Whatever you are here to sell, I don't want it". *slams door*

As a sales person, you realize the world doesn't see things the way you do; and then you say "customers are idiots". For some sales people, the customer is a terrible person. You don't see that you are also a customer to someone else. Although when you are a customer, all you see are lousy sales people.

The customers job is not to create hassles for you. The customer wants to solve some problem of his. If you are not contributing to it, you aren't adding value.

Here's a new marketing concept: People aren't buying products. They are buying solutions: What does your product do for me?

It's also about access. Access is not about just delivering. It's about information too. People are not buying price. They will buy only when they see value. Price is about fact. Value is about perception. Facts contribute toward building perception.

What is your job in communicating with the customer? Today the word is "education". Educating the customer with solutions, access, value propositions and promotions.

Jeff Bezos created a practice in Amazon that every time a new feature is proposed by an employee, the narrative should take the shape of a mock press release. The goal was to get employees to distill a pitch into its purest essence to start from something the customer might see.

The professor says historical case studies are useless, because what worked for someone under certain conditions, might not work out for you.
The challenge for startups is to test your product out. Identify target people. People who are willing to try new things and willing to listen to you. Your job is to hit the target. Simple. Large companies take a sprinkler and keep spraying randomly. A startup should aim carefully because the attempts are limited and we never get to see the full picture.


Value

What is value? When do you say something or someone has value?
How do you operationalize these in a sales call?

A customer believes that they have got value when they have got more than what they have given. The job of a sales person is to make the customer believe that.  

There are tangible and intangible aspects to it.
  • Ego
  • Risk
  • Uncertainty
  • Brand
In today’s world there are a huge number of things to be taken into account.

Value: Shirt purchase example

Let's say you are buying a shirt. When you're quality conscious and brand loyal. When you go to a store and the sales people are joking and chatting with each other and they just point you to a shirt and continue with their chatting, what will you do? You will walk out.
You walk out because you can still get a shirt of that brand from another store. The customer is not losing anything. You go to a few more showrooms, and you go through the same experience.

At this point of time, what exactly is ticking you off?
Behaviour and respect.

Why does it matter if they didn't behave properly? If you think rationally, you'll realize you just went to buy a shirt and you could have bought it without the sales-person's help.

When you're satisfying needs, there is a physical and psychological need to be satisfied. You are paying Rs.2000, not just for the shirt but also for the respect. People at a minimum want to feel important and respected.
That's why the lady paid Rs.6 lakh for the nice car salesman. That's what the Ayurveda massage parlour person and the cab driver did. They made their customer feel important.

Cash, risk and uncertainty are what the customer is giving. You have to be able to measure that.



To put it simply...

...there's the product and the customer.



That's not enough. The product has to fill the customer need fully.



But in the real world, only a part of the circles overlap.


And the professor says that's not value. Not yet.


The next definition of selling: I will be successful in sale if I either get the product to do what the customer wants or to get the customer to want it. Without this minimum condition, you don't make the sale.


The reality in life is that there is a competitor.



The competitor adds some value to the customer too. Points "A" and "B" are points of differentiation. The overlap "C" is called a point of parity and not differentiation. Parity won't add value. Differentiation won't add value.

The customer will buy from you only when "A" is larger than "B". This is the fundamental of value.



The point you want to remember:

Value is never in isolation. It's relative to something else. If you don't know what the 'something else' is, you can't create value.

Our sales job objective should be to make "A" much much bigger than "B".


Differentiating

No manager goes out with the intention of failure. But 95% of them fail because there was something unpredictable.

Focus your startup's energy in getting the potential target audience. You can't afford to waste energy in blindly shooting widely and hoping there would be customers.

You may be different but not be a differentiator. The customer sees a differentiator.

Use technology to deliver outstanding customer experience to build relationships and loyalty. use technology for the sake of technology and use it sensibly.


Final objective
The professor showed us a video of a baby on a swing. Whenever the swing moved forward, the baby could see the McDonald's logo through a window, and the baby smiled. When the swing swung backward, the baby could not see the logo and the baby cried briefly until he could see the logo again.
Your final objective is to make the customer to cry (like that baby) when your company is not there to fulfill their task. The services you provide should be so good that they should want to use the services of your company so badly.




The ultimate test of your customer
We were shown a video where a boy goes to a vending machine, inserts a coin into a slot that's just within his reach, to get a Coca-cola can. Then inserts another coin to get another Coca-cola can.
He then keeps both Coca-cola cans on the ground, stands on them to be able to reach a higher coin-slot on the machine, which is for Pepsi. He inserts a coin into the slot, gets a Pepsi and walks away with the Pepsi, and ignores the Coca-cola cans.




More from NRecursions, on startups:



Say thank you or donate

Fixing the Grub boot options if your Linux installation does not see the Windows installation

A colleague and another experienced colleague had trouble installing Linux on a machine because Windows wasn't being recognized after Linux installation. The department head as usual, recommended me to them, as the go-to guy when others couldn't solve it either.

This problem was new to me. I had never had any problem with a dual-boot system. First install Windows, and then Linux. Grub would always show Windows as one of the boot options.
But here, after installing Linux, only the Linux boot options were shown. At first all of us thought that all hope was lost, and we'd have to reinstall Windows and settle for a lower version of Linux which would recognize the Windows partition.

A bit of searching showed me that all that actually had to be done, was to point Grub to the Windows partition.


The technique
  • First, login to Linux.
  • Open a terminal and use "su" to login as root user.
  • Type "cfdisk". This will show you all the partitions available, including the Windows partition.
  • At the left of the cfdisk output, you'll see "boot". Take note of the partition name which is on the same line. It might either be "sda1" or "sda2".
  • Open the Grub config file with "vi /boot/grub2/grub.cfg".
  • You'll see some lines which say "menuentry". Above one such "menuentry", add a menuentry for Windows, like this:

    menuentry "WINDOWS"{
    set root='(hd0, msdos1)'
    chainloader +1
    }


This is if  the partition name you saw near the "boot" flag was /dev/sda1.
If it was /dev/sda2 you saw, then change the "msdos1" text to "msdos2".
 
Then type "grub2-mkconfig" to finalize your changes.
Reboot the system, and you'll find Windows also as a boot option!!!

p.s: When the system boots, if you want a more fancy name instead of just "Windows" in the Grub menu, you can change the "WINDOWS" text in the above code to make it "Nav's awesome Windows OS" or something like that.


The wish for a better bootloader

For a long time, I have wished that boot-loaders would be more reliable. If a person installs five different operating systems on five different partitions of the same hard disk, is it so hard to create a third-party boot-loader which is on a separate tiny partition, and able to recognize all five OS'es without even being told that there are OS'es on each partition? It would have been such a boon to have such a boot-loader which would automatically create the menu for us.
I even asked on SuperUser and got two upvotes but no response: http://superuser.com/questions/1009739/have-separate-bootloaders-for-windows-and-linux-on-a-single-hard-disk


03 December 2015

Donating to every cause is impractical

People were in urgent need for help, some NGO's decided to help and they needed your help! Money, clothes, books, food....whatever you could give. It was urgent! People were suffering and you had a big heart.

No sooner that the donation drive was over, another request for donations came up. And then another one. Phew! Exhausting, isn't it?

What should one do when confronted with multiple genuine charity requests and are posed with these questions?


NEED TO ALWAYS HAVE A BIG HEART ?
It’s not practical to donate to every cause.  Requests will keep coming. Choose which ones you are comfortable donating to and try to be consistent to those.


YOU EARN SO MUCH AND DONATE SO LESS ?
Nonsense. Don’t let anyone guilt-trip you. Let donations be a genuine wish to help. Identify the need and donate what you are comfortable with donating.


IS MY SMALL DONATION USEFUL ?
That’s why we donate together. $1 donated by 1 million people is not small.


IS IT HELPING PEOPLE IN THE RIGHT WAY ?
Very important. It’s better to see the bigger picture and create sustainability (creating a system that can help itself without depending on you) rather than keep donating, but there are always situations where immediate aid is more urgent. Choose to work with reliable people and NGO’s.


Donations to a cause are decided from the heart. A genuine feeling of caring and wanting to help. Let donations be about that feeling, and not about how much is donated or who donated or how many people donated how often or a competition of who donated the most.

It’s about sustaining a culture where we know that we are there for each other.


More on Volunteering


29 November 2015

07 November 2015

Get through the certificate problems which show "This connection is untrusted"

At some places, the SSL security certificates used, don't get recognized properly and users are put through the hassle of adding an exception an innumerable number of times to connect to perfectly valid websites. This is the screen you get to see on Firefox:


Instead of always clicking the "Add Exception" button, I searched if there was something I could use to get rid of this error. Turned out that Firefox had an addon named SkipCert which automatically adds the exception and in a few seconds, you'll be taken to the website you wanted to view.


Get the addon here: https://addons.mozilla.org/en-US/firefox/addon/skip-cert-error/

As for Chrome, these appear to be the solutions: http://superuser.com/questions/104146/add-permanent-ssl-certificate-exception-in-chrome-linux


Using TBB's concurrent containers

When searching for a tutorial on TBB's concurrent containers, you might end up finding a 1 minute video on it which doesn't play because you don't have Flash installed, or might just want a tiny program to show how to start using it. This blog post shows you exactly that!

You can use a TBB concurrent vector exactly like you use an std::vector.

#include <iostream>
#include <tbb/concurrent_vector.h>

int main(int argc, char** argv)
{
    tbb::concurrent_vector vec;
    tbb::concurrent_vector::iterator vecIter;
    vec.reserve(100);
    vec.push_back(1);
   
    for(vecIter = vec.begin(); vecIter != vec.end(); vecIter++)
    {
       std::cout<< *vecIter << "\n";
    }//for
   
    vec.clear();
   
    return 0;
}//main



Just make sure you

  • Include TBB's includes folder (/usr/local/tbb44_20150728oss/include/)
  • Point the project to TBB's lib folder (/usr/local/tbb44_20150728oss/lib/ia32/gcc4.4/libtbb.so)
  • Add TBB's lib folder to LD_LIBRARY_PATH in ~/.bashrc. (export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/tbb44_20150728oss/lib/ia32/gcc4.4/")


For concurrent queue, the pop function is different.

#include <iostream>
#include <tbb/concurrent_queue.h>

int main()
{
    tbb::concurrent_queue q;
    q.push(10);
    q.try_pop();//This is thread safe. Better than using if (!q.empty()) {q.pop();}
}//main


A C++ debugging helper

When working with C++ and you're in debug mode, you might be accustomed to these:
  • Using a lot of std::cout statements.
  • Seeing a clutter of outputs.
  • Introducing a lot of temporary code which you don't want to be part of the final build
  • Commenting out useful code which you don't want others to delete later because it's useful

and more...

I needed a way of color coding various outputs, so I used this:

/* Include this hpp file in any file where you need to output
 * cerr or cout.
 * 
 * Usage: In your code, instead of typing std::cout<<"Hi";
 * Just type cout("Hi");
 * Same way, instead of std::cerr<<"Error"; just type cerr("Error");
 */

#ifndef DEBUGHELPER_HPP
#define DEBUGHELPER_HPP

#define DEBUG_MODE

#define USEFUL_CODE_TEMPORARILY_COMMENTED_OUT_DONT_DELETE_IT
#define CODE_FOR_TESTING_FEEL_FREE_TO_DELETE_IT

#ifdef DEBUG_MODE
    //Colour code by Vaughan Schmidt. http://www.codebuilder.me/2014/01/color-terminal-text-in-c/
    #define RESET   "\033[0m"
    #define BLACK   "\033[30m"      // Black
    #define RED     "\033[31m"      // Red
    #define GREEN   "\033[32m"      // Green
    #define YELLOW  "\033[33m"      // Yellow
    #define BLUE    "\033[34m"      // Blue
    #define MAGENTA "\033[35m"      // Magenta
    #define CYAN    "\033[36m"      // Cyan
    #define WHITE   "\033[37m"      // White
    #define BOLDBLACK   "\033[1m\033[30m"      // Bold Black
    #define BOLDRED     "\033[1m\033[31m"      // Bold Red
    #define BOLDGREEN   "\033[1m\033[32m"      // Bold Green
    #define BOLDYELLOW  "\033[1m\033[33m"      // Bold Yellow
    #define BOLDBLUE    "\033[1m\033[34m"      // Bold Blue
    #define BOLDMAGENTA "\033[1m\033[35m"      // Bold Magenta
    #define BOLDCYAN    "\033[1m\033[36m"      // Bold Cyan
    #define BOLDWHITE   "\033[1m\033[37m"      // Bold White
    #define CLEAR "\033[2J"  // clear screen escape code
    #define coutBlack(x) (std::cout << BLACK << (x) << RESET)
    #define coutBoldBlack(x) (std::cout << BOLDBLACK << (x) << RESET)
    #define coutRed(x) (std::cout << RED << (x) << RESET)
    #define coutBoldRed(x) (std::cout << BOLDRED << (x) << RESET)
    #define coutGreen(x) (std::cout << GREEN << (x) << RESET)
    #define coutBoldGreen(x) (std::cout << BOLDGREEN << (x) << RESET)
    #define coutYellow(x) (std::cout << YELLOW << (x) << RESET)
    #define coutBoldYellow(x) (std::cout << BOLDYELLOW << (x) << RESET)
    #define coutBlue(x) (std::cout << BLUE << (x) << RESET)
    #define coutBoldBlue(x) (std::cout << BOLDBLUE << (x) << RESET)
    #define coutMagenta(x) (std::cout << MAGENTA << (x) << RESET)
    #define coutBoldMagenta(x) (std::cout << BOLDMAGENTA << (x) << RESET)
    #define coutCyan(x) (std::cout << CYAN << (x) << RESET)
    #define coutBoldCyan(x) (std::cout << BOLDCYAN << (x) << RESET)
    #define coutWhite(x) (std::cout << WHITE << (x) << RESET)
    #define coutBoldWhite(x) (std::cout << BOLDWHITE << (x) << RESET)   

    #define cerr(x) (std::cerr << (x))
    #define cout(x) (std::cout << (x))
    //... etc
#else 
    #define cerr(x)
    #define cout(x)
    //... etc
#endif

#endif // DEBUGHELPER_HPP

Not only are the cout's easier to type now, they are also easy to disable.
 
UPDATE: As someone commented below, you could use a logger too, but the #defines helped me in the specific way I wanted.

25 October 2015

Aha!

 Continued from the previous Aha!.


The road hump jump
Share with this link



Continued in the next Aha!