Wednesday, 1 June 2011

.Net Application runs with administrator rights

Sometimes it happens that when we run our C# .Net application on Windows Vista, Windows 7 machine or Windows Server 2008 it do not run properly and throw exceptions related to file or directory access rights. However, when we run that application by right clicking on its exe and selecting Run as Administrator. It runs properly without any access right issues.

We can handle it programmatically in .Net application as following 
  • Add Application Menifest file (if not added previously) in the project. It can be done by right clicking on ProjectàAddàNew Item->Application Menifest File.
  • Change the <requestedExecutionLevel> element to:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />    

The user gets the UAC prompt when he starts the program. Use wisely, his patience can wear out quickly.

Thursday, 19 May 2011

Enigma 
(Without the spiritual world the material world is a disheartening enigma.)

Whether you like or dislike "Puzzle solving", today's IT interviewer will must ask you to solve some of them during your interview. Followings are some tips to solve logical puzzles.

  • Take notes. Write down on sheet.
  • Read and think to establish a plan.
  • Do not over think.
  • Look for patterns, its great if you find one.
  • Do not give up unless interviewer ask you to stop solving it.
  • If you do not come up with the solution at the end then put a wild guess at least(guess within context of problem).
Followings are some most commonly asked puzzles in IT interviews. Happy reading :). 


1. The Camels

Camel Puzzle
Four tasmanian camels traveling on a very narrow ledge encounter four tasmanian camels coming the other way. Tasmanian camels never go backwards, especially when on a precarious ledge. The camels will climb over each other, but only if there is a camel sized space on the other side. The camels didn’t see each other until there was only exactly one camel’s width between the two groups. How can all camels pass, allowing both groups to go on their way, without any camel reversing?



2. The Waiter
Three men in a cafe order a meal the total cost of which is $15. They each contribute $5. The waiter takes the money to the chef who recognizes the three as friends and asks the waiter to return $5 to the men. The waiter is not only poor at mathematics but dishonest and instead of going to the trouble of splitting the $5 between the three he simply gives them $1 each and pockets the remaining $2 for himself. Now, each of the men effectively paid $4, the total paid is therefore $12. Add the $2 in the waiters pocket and this comes to $14…..where has the other $1 gone from the original $15?

Answer


The payments should equal the receipts. It does not make sense to add what was paid by the men ($12) to what was received from that payment by the waiter ($2).

Although the initial bill was $15 dollars, one of the five dollar notes gets changed into five ones. The total the three men ultimately paid is $12, as they get three ones back. So from the $12 the men paid, the owner receives $10 and the waiter receives the $2 difference. $15 – $3 = $10 + $2.



3. The Boxes
There are three boxes. One is labeled “APPLES” another is labeled “ORANGES”. The last one is labeled “APPLES AND ORANGES”. You know that each is labeled incorrectly. You may ask me to pick one fruit from one box which you choose. How can you label the boxes correctly?
Answer

Pick from the one labeled “Apples & Oranges”. This box must contain either only apples or only oranges. if you find an Orange, label the box Orange, then change the Oranges box to Apples, and the Apples box to “Apples & Oranges”.

4. The Cannibals
Three cannibals and three anthropologists have to cross a river. The boat they have is only big enough for two people. The cannibals will do as requested, even if they are on the other side of the river, with one exception. If at any point in time there are more cannibals on one side of the river than anthropologists, the cannibals will eat them. What plan can the anthropologists use for crossing the river so they don’t get eaten? Note: One anthropologist can not control two cannibals on land, nor can one anthropologist on land control two cannibals on the boat if they are all on the same side of the river. This means an anthropologist will not survive being rowed across the river by a cannibal if there is one cannibal on the other side.
Answer
First, two cannibals go across to the other side of the river, then the rower gets called back. Next, the rowing cannibal takes the second across and then gets called back, so now there are two cannibals on the far side. Two anthropologists go over, then one anthropologist accompanies one cannibal back, so now there is one anthropologist and one cannibal on the far side. The last two anthropologists go over to the far side, so now all the anthropologists are across the other side, along with the boat and one cannibal. In two trips, the cannibal on the far side takes the boat and ferries the other two cannibals across the river.

5. The Age Puzzle
A mother is 21 years older than her child. In exactly 6 years from now, the mother will be exactly 5 times as old as the child. Where’s the father?
Answer
With the mother. If you do the math, you find out the child will be born in 9 months.

6. The Double Jeopardy Doors
You are trapped in a room with two doors. One leads to certain death and the other leads to freedom. You don’t know which is which. There are two robots guarding the doors. They will let you choose one door but upon doing so you must go through it. You can, however, ask one robot one question. The problem is one robot always tells the truth ,the other always lies and you don’t know which is which. What is the question you ask?
Answer
Ask one robot what the other robot would say, if it was asked which door was safe. Then go through the other door.
7. The Frog
A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well? Note: Assume after the first leap that his hind legs are exactly three meters up the well. His hind legs must clear the well for him to escape.
Answer
Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out.

8. The Bobber
You can paddle your canoe seven miles per hour through any placid lake. The stream flows at three miles per hour. The moment you start to paddle up stream a fisherman looses one of his bobbers in the water fourteen miles up stream of you. How many hours does it take for you and the bobber to meet?

Answer
2 hours. Ignore the speed of the stream, as the cork will be carried along at three miles per hour as will you. It takes two hours to travel fourteen miles, at a rate of seven miles per hour.

9. The Socks
Cathy has six pairs of black socks and six pairs of white socks in her drawer. In complete darkness, and without looking, how many socks must she take from the drawer in order to be sure to get a pair that match?

Answer
Socks do not come in in left and right, so any black will pair with any other black and any white will pair with any other white. If you have three socks and they are either colored black or white, then you will have at least two socks of the same color, giving you one matching pair.

10. The Fake Coin
You have twelve coins. You know that one is fake. The only thing that distinguishes the fake coin from the real coins is that its weight is imperceptibly different. You have a perfectly balanced scale. The scale only tells you which side weighs more than the other side. What is the smallest number of times you must use the scale in order to always find the fake coin? Use only the twelve coins themselves and no others, no other weights, no cutting coins, no pencil marks on the scale. etc. These are modern coins, so the fake coin is not necessarily lighter. Presume the worst case scenario, and don’t hope that you will pick the right coin on the first attempt.

Answer
3 is the answer.
If you knew the fake coin was lighter, then the solution would have an easy explanation. But you do not. So…. Number the coins 1 through 12.
1. Weigh coins 1,2,3,4 against coins 5,6,7,8.
1.1. If they balance, then weigh coins 9 and 10 against coins 11 and 8 (we know from the first weighing that 8 is a good coin).
1.1.1. If the second weighing also balances, we know coin 12 (the only one not yet weighed) is the counterfeit. The third weighing indicates whether it is heavy or light.
1.1.2. If (at the second weighing) coins 11 and 8 are heavier than coins 9 and 10, either 11 is heavy or 9 is light or 10 is light. Weigh 9 against 10. If they balance, 11 is heavy. If they don’t balance, you know that either 9 or 10 is light, so the top coin is the fake.
1.1.3 If (at the second weighing) coins 11 and 8 are lighter than coins 9 and 10, either 11 is light or 9 is heavy or 10 is heavy. Weigh 9 against 10. If they balance, 11 is light. If they don’t balance, you know that either 9 or 10 is heavy, so the bottom coin is the fake.
1.2. Now if (at first weighing) the side with coins 5,6,7,8 are heavier than the side with coins 1,2,3,4. This means that either 1,2,3,4 is light or 5,6,7,8 is heavy. Weigh 1,2, and 5 against 3,6, and 9.
1.2.1. If (when we weigh 1,2, and 5 against 3,6 and 9) they balance, it means that either 7 or 8 is heavy or 4 is light. By weighing 7 and 8 we obtain the answer, because if they balance, then 4 has to be light. If 7 and 8 do not balance, then the heavier coin is the counterfeit.
1.2.2. If (when we weigh 1,2, and 5 against 3,6 and 9) the right side is heavier, then either 6 is heavy or 1 is light or 2 is light. By weighing 1 against 2 the solution is obtained.
1.2.3. If (when we weigh 1,2, and 5 against 3, 6 and 9) the right side is lighter, then either 3 is light or 5 is heavy. By weighing 3 against a good coin the solution is easily arrived at.
1.3 If (at the first weighing) coins 1,2,3,4 are heavier than coins 5,6,7,8 then repeat the previous steps 1.2 through 1.2.3 but switch the numbers of coins 1,2,3,4 with 5,6,7,8.

11. Birthday Cake Problem

You have a birthday cake and have exactly 3 cuts to cut it into 8 equal pieces. How do you do it?

Answer
The “correct” answer is to cut the cake in quarters (4 pieces) using 2 of the cuts, then stack all 4 of the pieces and then split all four of the stacked pieces with the third cut.














Wednesday, 11 May 2011

Finding Different Objects in the SQL Database 

1. Find All the Tables from the Database 
To select All the tables present in your Database run following query in query window.
-------------------------------------------------------------------------------------------------------------
USE [YourDB]
GO 
SELECT *
FROM sys.Tables
GO
-------------------------------------------------------------------------------------------------------------
This will return all the tables in the database which you have created.



2. Find All the Triggers present on the Database tables
To select All the triggers present on the  tables of your Database run following query in query window.
-------------------------------------------------------------------------------------------------------------
USE [YourDB]
SELECT OBJECT_NAME(parent_id) AS TableName,
name AS TriggerName,
create_date AS CreationDate,
modify_date AS ModifyDate
FROM sys.triggers
-------------------------------------------------------------------------------------------------------------
This will return all triggers present on the tables of your database.

3. Find All the Indexes present on Columns of the Database tables


To select All the Indexes present on the  data columns of tables of your Database run following query in query window.
---------------------------------------------------------------------------------------------------------------------------------------------

SELECTs.name AS  'Schema', t.name AS  'Table', i.name AS  'Index', c.name AS  'Column'
FROM sys.Tables t
inner join sys.schemas s on t.schema_id = s.schema_id
inner join sys.indexeson i.object_id = t.object_id
inner join sys.index_columns ic on ic.object_id = t.object_id
inner join sys.columns c on c.object_id = t.object_id and
ic.column_id = c.column_id
where i.index_id > 0    
and i.type in (1, 2) -- clustered & nonclustered only
and  i.is_primary_key = 0 -- do not include PK indexes
and  i.is_unique_constraint = 0 -- do not include UQ
and  i.is_disabled = 0
and  i.is_hypothetical = 0
and  ic.key_ordinal > 0
order by ic.key_ordinal
---------------------------------------------------------------------------------------------------------------------------------------------
This will return all indexes present on the columns of the tables of your database.
While, list of schema names and table names of the database can be retrieved by following query
-----------------------------------------------------------------------------------------------------------------

Use [YourDB]
SELECT '['+SCHEMA_NAME(schema_id)+'].['+name+']'
AS SchemaTable

-----------------------------------------------------------------------------------------------------------------


Thanks for reading this post, hopefully it would have proved instrumental for you.

Monday, 9 May 2011

PUCIT Job Fair 2011

On May 7, 2011 I went to PU old campus to represent my company Intagleo System PVT (www.intagleo.co.uk) in PUCIT Job Fair 2011.

When entered the premises I saw throng of fresh graduates in veranda with lot of hope and coolness in their faces. I noticed some confident smiles, self-smug attitude and future foretell chirps. Why shouldn't it be; it was a big day for them. Country’s some highly reputed IT companies were there to hire them.

I had conducted general meetings with many graduates and also interviewed most of them. I learnt that there are certain areas which need to be improved by the students in order to get instant attraction of employers.  
  
Resume Making Guidelines:
Please try to follow following tips in order to make you CV worth seeing.

  • Use Titles or Headings That Match The Jobs You Want.
  • Use Design That Grabs Attention, but at expense of simplicity.
  • Don't include a picture of yourself unless you're in an industry that requires a photograph (e.g., TV, theatre, film).
  • The general rule for page length is 1-page for typical entry level college students and 2 pages for everyone else. There can be exceptions to this but the longer the resume, the less likely it will be read. So make sure your document is concise.
  • Use a font size between 10 and 12 for the body text of your resume. Make sure to choose a font that's compatible with applicant tracking systems that many employers use.
  • Make sure your resume is accurate and be honest with what you say. It's OK to present yourself in the best light you can but an outright lie can hurt you later on if the truth comes out. It happens all the time. 

Interview Preparation Guidelines:
Before going for your next job interviews try to follow below guidelines.

  • Arrive at least five minutes early and if – for reasons out of your control – you’re running late, call your interviewer and explain why.
  • Enter into a state of relaxed concentration. Be calm and take it easy.
  • Come with prepared. But if you are then please never tell your interviewer that you are not prepared, you couldn’t revise due to blah blah blah. Oh that’s very depressing.
  • Expect to answer the questions like, "Tell me about yourself."  Or "Why should we hire you?" These are pet questions of prepared and even unprepared interviewers.
  • Wear proper and neat outfit, avoid new clothes. Spend some time to polish your footwear. 
  •  Answer questions with confidence, but never let your confidence become arrogance.
  • Maintain eye contact with the interviewer.
  • Listen to the entire question before you answer and pay attention, if you do not understand question then do not become reluctant to ask it again. 
  • If you do not know the answer straightaway say “I do not have idea about this”
  • After the interview, be sure to send a thank you letter ideally with in two days and no longer than one week.

Selection of Degree Project:
One inadequate thing I learnt during interviews and discussions with student was their “Degree Project” selection. I am not exaggerating to state that more 75% of final projects were “School management System” or “Hospital Management System”. There has been enough automation of schools and hospitals- common students. Remember your employer will have a keen interest in your final project because this is the only thing which can depict your practical experience.

I would take opportunity to request PUCIT Project Management Department that please do not approve such entry level projects. And help student to bring on some innovation in the field of Information Technology.

Thank you for your time. For any query or feedback you can comment to this post or you can email me informqasim@yahoo.com .