Saturday, October 9, 2010

How do we get Fat?

Since long time I have been thinking about how fat gets creates/stored in our body. I found a very good link on how stuff works which explains exactly how does fat gets stored in our body. this is what I found.

Fat is stored in fat cells, muscle cells and liver cells. The propotion is very less in muscle and liver cells.
The number of fat cells in our body remain same, but as we eat more fatty food, their size increase as they accumulate more fat in them. These cell are usually found under out skin.
My thinking was that fat is created from fatty food only. But I found that our body also converts excess glucose into fat. After we eat food it gets digested in stomach and through intestine, fat and glucose enters blood stream.
Fat cell first prefer to absorb fats from blood stream since that is very easy and less energy consuming (well everybody is entitled to their choices and everybody tends to be lazy :) ) work while converting glucose into fats is longer and energy consuming process so that is not preferred.
If you have 100 extra calories in fat (about 11 grams) floating in your bloodstream, fat cells can store it using only 2.5 calories of energy.
On the other hand, if you have 100 extra calories in glucose (about 25 grams) floating in your bloodstream, it takes 23 calories of energy to convert the glucose into fat and then store it. So what this means is that any extra calorie that goes into our body gets converted into fat.
Well to answer the question in title of the post, its clear that we get fat by eating access to what our body needs and that get deposited as FAT, and keeps on accumulating until our pants start to tightening and we get bigger pant size :) Hope thats not the case. Eat limited and healthy.
Hope this information was helpful to you. Don't forget to put your comments on this article and all credit for the information goes to HowStuffWorks link posted below.

All the information is obtained from HowStuffWorks. Visit there for more detailed information.

Update: I also found a very good video on youtube explaining all that I wrote above.


Monday, September 6, 2010

PIMPL (the beauty marks you will want your libray to have :) )
Private-Implementation is a Software Engineering paradigm which allows us to enhance encapsulation, reduce compilation times and retain binary compatibility. The idea here to add another layer of abstraction between the library and the user code.

The Story
Consider that you are create a library which you will be shipping to customers when done. Since Software is never perfect and always extensible, after you shipped you Version 1.0 you plan to change the way your memory allocator functions . So you start updating the library and ship another version. You don’t change the signature of the function, just the internals. So at the backbox view, everything is same, just the feeling this version would be better than the previous since its Version 2.0. But, there is always a ‘but’, you have to add some private member in the .h file. So along with the Version 2.0 library you also ship update .h file.
Now let’s say that I am one of the users of your great library. I use it to develop UI framework for my mobile device. So now when you release Version 2.0, there are two options for me. Either I stick to older less efficient version of upgrade to 2.0. I decide to upgrade to 2.0, I place the new .h and library to correct location and start compiling my code.
Now to my surprise I see that my complete code base (which is 10000 files big and more that 10,000,000 lines of code, lets assume it) is rebuilding. Now why did that happen. None of your changes affect the way my code works. I mean you didn’t change signature of any of your functions (beware, that’s a very bad practice in ‘Library Developer World’) or add new functionality, you only changed how your ‘new’ and ‘delete’ operators work internally which I don’t care until they do what is advertised. But I see lot of my code being recopiled.

Why PIMPL?
PIMPL helps you avoid the issue by adding an extra layer of abstraction between the application code and library.
Lets say that the name of your library class is Foo. In which you have implemented getMessage(), setMessage(std::string) and printMessage() functions. What PIMPL idiom suggests that you create another class FooImpl in which you have all the members variables and functions of Foo, declared and implemented as if it was Foo, as shown in listing below.

FooImpl.h

#ifndef FOOIMPL_H
#define FOOIMPL_H
class FooImpl
{
public:
FooImpl();
~FooImpl();
void printMessage();
void setMessage(char* );
char* getMessage();
private:
char* m_message;
};
#endif // FOOIMPL_H

FooImpl.cpp

#include "FooImpl.h"
#include "string.h"
#include "stdlib.h"
#include "stdio.h"
FooImpl::FooImpl()
{
}
FooImpl::~FooImpl()
{
}
void FooImpl::setMessage(char* message)
{
m_message=message;
}
char* FooImpl::getMessage()
{
return m_message;
}
void FooImpl::printMessage()
{
printf("%s\n",m_message);
}


Now create another class Foo which will act as abstraction class for FooImpl. Look as code below.

Foo.h

#ifndef FOO_H
#define FOO_H
class FooImpl;
class Foo
{
public:
void printMessage();
void setMessage(char* );
char* getMessage();
Foo();
~Foo();
private:
FooImpl* m_fooImpl; //d_ptr
};
#endif // FOO_H

Foo.cpp

#include "Foo.h"
#include "FooImpl.h"
Foo::Foo(): m_fooImpl(new FooImpl())
{
}
Foo::~Foo()
{
}
void Foo::setMessage(char message[])
{
m_fooImpl->setMessage(message);
}
char* Foo::getMessage()
{
return m_fooImpl->getMessage();
}
void Foo::printMessage()
{
m_fooImpl->printMessage();
}

main.cpp

#include "Foo.h" //no need to include "FooImpl.h"
int main(int argc, char *argv[])
{
char* myMessage="Hello PIMPL";
Foo f;
f.setMessage(myMessage);
f.printMessage();
return 0;
}


Let me quickly explain what is happening in the code.
You access everything in FooImpl class, using private member variable, m_fooImpl of Foo.cpp class. The client or user of the library does know nothing about FooImpl. All he has to do is create an object of Foo class and access its public members as if they were implemented in Foo class.
Now the thing to note here is that any change you make in FooImpl class will not need you to recompile main.cpp or Foo. This helps us to avoid recompiling our code incase of changes in library. And since Foo class doesn’t include any implemention other than pointer indirection to FooImpl.
You can check by copying above code in respective .cpp and .h files and compiling with your favorite compiler. Try to see what files are compile upon changing each file.

But this idiom does have following drawbacks.
  • More work for the implementor.
  • Doesn't work for 'protected' members where access by subclasses is required.
  • Somewhat harder to read code, since some information is no longer in the header file.
  • Run-time performance is slightly compromised due to the pointer indirection, especially if function calls are virtual (branch prediction for indirect branches is generally poor).
References:

Monday, May 3, 2010

Are you afraid of Failure??

The most common reason people don't pursue their dreams is FEAR OF FAILURE. Well in that case below is the list of failure of a very successful person we all know very well (along with some successes also).
  • 1831 - Lost his job
  • 1832 - Defeated in run for Illinois State Legislature
  • 1833 - Failed in business
  • 1834 - Elected to Illinois State Legislature (success)
  • 1835 - Sweetheart died
  • 1836 - Had nervous breakdown
  • 1838 - Defeated in run for Illinois House Speaker
  • 1843 - Defeated in run for nomination for U.S. Congress
  • 1846 - Elected to Congress (success)
  • 1848 - Lost re-nomination
  • 1849 - Rejected for land officer position
  • 1854 - Defeated in run for U.S. Senate
  • 1856 - Defeated in run for nomination for Vice President
  • 1858 - Again defeated in run for U.S. Senate
  • 1860 - Elected President (success)

Select blank space below to see that great person's name

ABRAHAM LINCOLN

Source: failures

Saturday, December 13, 2008

What is money?

Recently I came along a very good podcast in while the orator explained what is money and how the money (currency) came into existence. The explanation is very basic and complete. I am putting down the transcript of that presentation. The explanation is with respect to UK's economy but it seems that it generally applies to almost all the economies.

OK, so on with part One: What is money?
In brief, it’s anything generally accepted within a group as a means of exchange. Some things that have been used as money have value of their own such as gold or silver. This is known as the ‘intrinsic’ value. Other things used as money such as paper or shells have little or no value in themselves. Either way they are accepted as tokens to be used for the purchase of goods or services.
Another form of money in Britain for many centuries was the use of ‘tally sticks’ as receipts for large-value taxes. These were sticks of hazel, notched in a way to indicate the value. They were then split along their length, and the tax-man kept one half, while the other formed the receipt, which then could be used as money.
This system only finally ended in the 19th century when a fire being used to dispose of them got out of hand and burnt down the Houses of Parliament!
So how is money created? Most people think that money is just the notes and coins in their pockets and that it is created by the Government and spent into circulation. Well, some of it is.
In the 1940’s about 40% of the money in circulation was in the form of Government issued notes and coins. It is now only about 3%.
Why is this? In the Middle Ages, Merchants would put their spare gold into the safekeeping of the Goldsmiths, who had secure vaults. They were given paper receipts for the gold. The Merchants soon realised that instead of having to go to the Goldsmiths to take out some gold to use for payments they could pass on the receipts instead. This was how our paper money started.
The Goldsmiths also ‘loaned’ gold from their vaults. They charged interest on the loans. However, they could only lend actual gold from the supply they had in their vaults.
The greedy Goldsmiths realised that they could make loans in the form of the paper receipts that were being used ‘as’ gold. They then realised that most of the gold in their vaults was never taken out by the depositors.
So they started issuing receipts for much more gold than they actually had. As long as no one found out then there wouldn't’t be a problem. This increased the money supply, and as long as they were not too greedy, they wouldn't be found out.
So began the modern system called ‘fractional reserve’ banking.
The interest they charged on the loans eventually proved more profitable for some, than their work as Goldsmiths, and they had become the first Modern Bankers.
Gradually, the new banks took over the task of money-creation from the rulers (Kings, Governments, etc.), by issuing their own banknotes. This practice went on until it was outlawed in Britain in the 19th century.
The Bank of England, which was still a private bank, had special privileges granted to it, along with special responsibilities, and was the only bank then allowed to issue banknotes.
As the other banks could no longer print their own banknotes, and therefore couldn't’t make profits from loaning them out, so they started encouraging the use of cheques, and, more recently, credit or debit cards and electronic transfers.
This allowed them to continue to create money by making loans. As already noted, by the 1940s, after the Bank of England had at last been nationalised, about 40% of the money supply was still in the form of Bank of England issued notes and coins. This has now dwindled to only about 3%.

So How do banks create money?
When a bank makes a loan, it does two things: First it credits the borrower’s account with the money and records it as a ‘liability’ of the Bank. In other words, the Bank has entered into its system the ability for the borrower to go and spend the value of the loan at some future time.
Then it records the loan as an ‘asset’, owed by the borrower, to the Bank, again in the future. Thereby ‘balancing’ its books. In addition to the amount of the loan, the borrower has to pay interest. The money loaned does not come from any depositor’s account.
What it’s done is to create the money it lent out of nothing – or rather, out of account entries.
The bank has to keep available enough ‘reserve’ to meet demands for payments. This limits the extent it can expand the money supply by making loans. For much of the last century there was a statutory ‘fractional reserve’ required of around 10%. That means that banks had to keep reserves made up of notes and coins and deposits in their own accounts with the Bank of England.The reserves had to equal at least 10% of the amount they had out on loan.
In the 1970s this legal limit was lifted, so reserves have dwindled to much less, and the money supply has mushroomed!

Let’s look at an example.
With a reserve requirement of 10%, bank#1 starts with assets of £1,000 in its account. It now lends £900 to someone else, so it has £100 reserves and an ‘asset’ of the £900 owed to it.
With the remaining £100 in its reserves and the £900 loan it still has £1000 of assets.
The borrower then spends the money and it is deposited into another bank, Bank 2.
Bank 2 can now lend out £810 of the £900 to someone else, and keep the remaining £90 to add to its reserves (the 10% reserve requirement).
Again, the borrower spends it and the money goes to Bank 3.

This bank now has an asset of £810 and can lend £729 to someone else; and so on.
Bank 1 £1000 £100 £900
Bank 2 £900 £90 £810
Bank 3 £810 £81 £729
Bank 4 £729 £72.90 £656.10
Etc.... Totals ~£10,000 ~£1000 ~£9000

This can continue with ever-decreasing amounts, until eventually the original £1000 has allowed the banks between them to create another £9000.And the banks are charging interest on all of this new money. This has expanded the money supply by £9000.

So, the bank creates money. The bank ‘lends’ the money to society. The bank charges interest, just like the Goldsmiths did. The money that the bank created is eventually re-paid to the bank and is cancelled out of existence but there still remains a debt to be paid in the form of interest.

Let’s think about this for a moment.

Another Example
Let’s simplify the numbers and give an example of the underlying problem of the current system. We have 11 people in a closed room. 10 of them have nothing and the 11th has a bowl of beads. We’ll call the 11th person The Bank. The Bank now lends each person 10 beads for 1 hour and charges 10% interest on the loan. The people in the room are free to sell whatever they have to the other people in the room in exchange for beads. An hour passes.
Some people have now got the 11 beads they need to repay the Bank. This means that others don’t. It is obvious that there are not enough beads in the room for everyone to repay The Bank.

So, what can be done?
Well, some could ‘declare themselves bankrupt’ and hand over their assets to The Bank or, some people could take out further loans from The Bank. If The Bank allows these people to take out other loans that would ‘boost the economy’ and allow all of the people to repay their debts from the original round of lending. Of course, anyone who borrowed is now in further trouble. They must repay the new loan plus the interest.
As you can see, there are never enough beads in the room to repay The Bank. This growth of the money supply, along with the even greater growth of debt is the fundamental cause of the current ‘credit crunch’, because of the interest imposed on all this 'bank created' money.
Since the deregulation of the banks in the 1970s, the banks have been able to expand their money-creation greatly. They now have only tiny reserves, but huge profit from the interest they make on all the loans. This enriches them and their shareholders, at the expense of society.
The banking system has always been precarious, and is now far more so. With such small reserves to call on when customers withdraw their money it only takes a few ‘bad debts’ to be written off, or a few people to lose trust in the bank and to withdraw their money, for the bank to run into problems. Once news gets out that a bank is in trouble, others start withdrawing their money and the bank becomes bankrupt. With the ever-growing levels of debt due to the way the banks create our money by making loans, and the growing amount of interest to be paid on those loans, any slowing of ‘economic growth’ can threaten the whole banking system with collapse as the debts become un-repayable – which is why the authorities are now so desperate.
With ‘globalisation and deregulation’ since the 1970s, the banks have been heavily involved with international trade, and so the ‘credit crunch’ is affecting the whole world.

Information Source: http://moneymyths.org.uk/

Friday, November 14, 2008

Software says oops to Mars Climate Orbiter '98


Since the dominance of computers in our life, people might think that software is the most perfect thing that has happened to mankind since it does many useful thing for us( yes hardware is definitely required, but its the software which drives and controls the hardware). We also might assume that software should never fail. But the truth is contrast to that belief. Software is prone to failure and the fact that there is 10000s of lines of code makes it more difficult to test thoroughly. Lets take a very simple example, how many time do you have to restart your computer or cellphone? Ideally that should not happen but it does happen.
I tried to search some of the biggest project failures due to software errors and came across the one which failed the mission to Mars (yes planet Mars). Obviously it was a human error which lead to the failure of software but it shows that how fail-able software is!

The Mars Climate Orbiter (formerly the Mars Surveyor '98 Orbiter) was one of two spacecraft in the Mars Surveyor '98 program. The two missions were to study the Martian weather, climate, and water and carbon dioxide budget, in order to understand the reservoirs, behavior, and atmospheric role of volatiles and to search for evidence of long-term and episodic climate changes.

The Mars Climate Orbiter was intended to enter orbit at an altitude of 140–150 km above Mars. However, a navigation error caused the spacecraft to reach as low as 57 km. The spacecraft was destroyed by atmospheric stresses and friction at this low altitude. The navigation error arose because a NASA subcontractor (Lockheed Martin) used Imperial units (pound-seconds) instead of the metric system. The software was used to control thrusters on the spacecraft which were intended to control its rate of rotation, but by using the wrong units, the ground station underestimated the effect of the thrusters by a factor of 4.45.This is the difference between a pound force - the imperial unit - and a newton, the metric unit. The software was working in pounds force, while the spacecraft expected figures in newtons - and 1 pound force equals approximately 4.45 newtons.The problem arose partly because the software had been adapted from use on the earlier Mars Climate Orbiter, without proper testing before launch, and partly because the navigation data provided by this software was not cross-checked while in flight.The Mars Climate Orbiter thus drifted off course during its voyage and entered a much lower orbit than planned, and was destroyed by atmospheric friction.

The total cost of the mission was $327.6 million ONLY.
Well there can be other argument as well, why do we have two different units of measurement? But I will not go into that side as it unrelated to software and related to HUMANS.

Source: http://en.wikipedia.org/wiki/Mars_Climate_Orbiter

Monday, October 20, 2008

Cisco's ideas sharing concept- I-Prize


Cisco's innovation contest is one of at least a dozen corporate-sponsored competitions that have cropped up in recent years, all aimed at developing and rewarding innovation. Microsoft (MSFT), for instance, annually awards its $25,000 Imagine Cup to a student team that best uses technology to solve a real-world problem. Cisco tries to extend this concept in which the winning team may have the opportunity to be hired by Cisco to found a new business unit and share a $250,000 signing bonus. Cisco may also invest approximately $10 million over three years to staff, develop, and go to market with a new business based on your idea.
This an interesting way to move forward specially in current market full of competition. This might help Cisco to get a headstart into near future techonolgy,concept etc. Cisco's Telepresence is one of the outcome of this effort. Companies do have such portals which are used internally to the company but issue is that we can only submit the ideas related to the stuff the company works for. e.g If I am working in telecomunication company I cannot submit the idea on to how to improve the efficiency of a four-stroke engine since that would not be relevant to the companies road map. Cisco's i-prize gives that platform to register your idea and if they feel that it is persuable then (and provided that your ideas is voted the best) you have a bright future.

Following is some details on how to participate at Cisco's I-prize.

Register on the Cisco I-Prize Website. Post your idea and comment on other ideas posted by fellow entrepreneurs. Use the Human Network to refine your concept and form an idea team of all-stars that can take your idea to the next level.

Cisco will select up to 100 semifinalist teams that will work with Cisco experts using state-of-the-art collaboration tools to build a business plan and presentation. Next, up to 10 finalist teams will present to a judging panel for the ultimate prize: the opportunity to start a new business unit with access to the resources that Cisco has to offer.

Its definitely not easy task but if you genuinely think that you have the idea which could save the world or avoid next world war I-Prize might just be the place to start at.

Information Sources:

http://www.businessweek.com/technology/content/may2008/tc20080529_968185.htm

http://blogs.cisco.com/innovation/comments/businessweek_magazine_on_the_cisco_i_prize/