Cool Visual Studio 2010 Plugins

Free:

Not Free:

C Pointers Confusing .. Ahh Read the Technique

Given the following C declarations, what does each one mean?
1.) int (*p)[ 5 ];

2.) char *x[ 3 ][ 4 ];

3.) int *(*a[ 10 ])();

4.) int (*t[])();

C declarations can sometimes be quite complex – and interviewers love to test out the ability of candidates to break down and understand those declarations. The way to approach this problem is to use a general method that will help you read any C declaration – otherwise, you can easily find yourself very confused. Here’s a good rule to follow when trying to make sense of a C declaration:

Start at the variable name, also known as the identifier. Without skipping a right parenthesis, look right and say what you see – even if you see nothing continue. Without skipping a left parenthesis look left again and say what you see. If you are currently inside a pair of parentheses, jump outside this level. Look right and say what you see. Look left and say what you see. Keep doing this until you say the variable type or return type.

An important note: you should always remember that functions and arrays are read left-to-right and have precedence over pointers, which are read right-to-left.

Before reading the answers, it is best to use the rule given, and try it out for yourself. For the first example, we start at p. We look right and there is a parenthesis, which we don’t want to skip until we look left. So we look left and get that p is a pointer. Now, we can jump outside the parentheses, and we look right and find an array of size of 5, so now we can add to our statement that p is a pointer to an array of size 5. Now, we look left and find the ‘int’, so we can finish our declaration by saying that p is “a pointer to an array of 5 ints”.

For the second example, we start with x. We look right and find an array composed of 3 arrays of size 4. You may have been tempted to jump back left to the pointer after reading out “array of size 3″, but you must note that arrays take precedence over pointers, so continuing on with the second array is important. So now we see that x is an array composed of 3 arrays of size 4, and the next step is to move left. We see a pointer, so now we can say that “x is an array composed of 3 arrays of 4 pointers to char”.

For the last two examples, we’ll just be giving the answers, since you should be able to figure them out on your own now. In the third example, a is “an array of 10 pointers to functions returning an int pointer”. For the fourth example, t is “an array of pointers to functions returning an int”.

What’s the difference between const char *p, char * const p and const char *
const p?
const char *p -
This is a pointer to a constant char. One cannot change the value
pointed at by p, but can change the pointer p itse
lf.
*p = ‘A’ is illegal.
p = “Hello” is legal.
Note that even char const *p is the same!
const * char p – This is a constant pointer to (nonconst)
char. One cannot change
the pointer p, but can change the value pointed at
by p.
*p = ‘A’ is legal.
p = “Hello” is illegal.
const char * const p -
This is a constant pointer to constant char! One cannot
change the value pointed to by p nor the poin
ter.
153
*p = ‘A’ is illegal.
p = “Hello” is also illegal.
To interpret these declarations, let us first consider the general form of declaration:
[qualifier] [storage-class] type [*[*]..] [qualifier] ident ;
or
[storage-class] [qualifier] type [*[*]..] [qualifier] ident ;
where,
qualifier:
volatile
const
storage-class:
auto extern
static register
type:
void char short
int long float
double signed unsigned
enum-specifier
typedef-name
struct-or-union-specifier
Both the forms are equivalent. Keywords in the brackets are optional. The simplest tip
here is to notice the relative position of the `const’ keyword with respect to the asterisk
(*).
Note the following points:
• If the `const’ keyword is to the left of the asterisk, and is the only such keyword in
the declaration, then object pointed by the pointer is constant, however, the
pointer itself is variable. For example:
const char * pcc;
char const * pcc;
• If the `const’ keyword is to the right of the asterisk, and is the only such keyword
in the declaration, then the object pointed by the pointer is variable, but the
154
pointer is constant; i.e., the pointer, once initialized, will always point to the same
object through out it’s scope. For example:
char * const cpc;
• If the `const’ keyword is on both sides of the asterisk, the both the pointer and the
pointed object are constant. For example:
const char * const cpcc;
char const * const cpcc2;
One can also follow the “nearness” principle; i.e.,
• If the `const’ keyword is nearest to the `type’, then the object is constant. For
example:
char const * pcc;
• If the `const’ keyword is nearest to the identifier, then the pointer is constant. For
example:
char * const cpc;
• If the `const’ keyword is nearest, both to the identifier and the type, then both the
pointer and the object are constant. For example:
const char * const cpcc;
char const * const cpcc2;
However, the first method seems more reliable…

Settings for virtual directory(for database instance creation problem)

Application pools->asp.net 4.0-> Advanced Settings->Process Model->Identity->BuiltInAccount->Network Service

Go to your application->Right click->Manage application ->Advanced settings->Application Pool-> ASP.Net 4

No Intellisense in Visual Studio 2010…. Do this

I recently had problem for no intellisense coming up in Visual Studio 2010.

If you find the same problem do this:

Tools->Options->Under text editor -> Go to C# and then select the options of Auto List Members and Parameter information.

Hope This Helps someone :)

image

Useful javascript to catch the tab event in jquery

//catching the tab event
$(‘.ranktxtbox’).live(‘keydown’, function (e) {
var keyCode = e.keyCode || e.which;

if (keyCode == 9) {
e.preventDefault();
//alert(‘do your processing here’);
}
});

Solutions to Problems Setting up Virtual Directory in IIS 7

Hello Friends,

[Note: I am running Windows7 , Visual Studio 2010 and IIS 7 on my machine].

In order to setup virtual directory on my machine and letting IIS server serve my pages(with extensions .asp, .aspx), I came across certain issues that I will address in the following document.

Running IIS

Windows XP, Vista or Windows 7 do not have IIS installed by default. Inorder to install it, go to Control Panel à Programs and Features -> Turn windows features on or off. In the dialog box find Internet Information Services and check on the checkboxes under it as shown below.

Note: Make sure to check ASP under Application Development Features. Also, make sure to check Static Content(this lets iis serve CSS, IMG and JS files) under Common HTTP Features.

To check if IIS is running. Go to your browser and type http://localhost. It should give you a page with IIS 7 image on it.

Hit OK. This would take some time to install all the features.

Opening IIS Manager
Shortcut: Start -> Run … type inetmgr
Or
Control Panel  System Security  Administrative Tools  IIS Manager.
[After this follow the steps to create a virtual directory. Find the steps on Lecture 2 page].
Note: Make sure to build/compile your project solution before you directly browse your pages from iis. Otherwise the browser throws an error for not being able to find it in Global assembly cache.
Issues with IIS Windows 7
1. On browsing .aspx page , browser gives error HTTP 500.19 and error message for not having sufficient privileges to serve the page.
Solution: Giving access permissions to IIS_IUSRS Group.
1. Right Click on your virtual directory application and click on Edit Permissions.
2. Go to Sharing Tab and click Share.

3.On clicking share will open a dialog box as shown. Write IIS_IUSRS in the textbox and hit Add.

4.Change the permission of IIS_IUSRS group from Read to Read/Write for IIS_IUSRS.

  1. Hit Share for changes to save. Click Done.

Note: You should now be able to open your .asp and .aspx files in your browser.

  1. 1. Pages viewed from Virtual Directory not rendering CSS/ Javascript/Images.

Solution: Firstly make sure that while installing your IIS you had clicked on Static Content option under Common HTTP Features Section.

Sometimes even after that, the browser doesn’t render any css or javascript files.

Problem is with IIS 7 that it needs to be told explicitly for mapping the .css, .image files and javascript files to be run by IIS 7.

To do so, follow the steps:

1. In your IIS Manger, click on your virtual directory and switch to features view (from down bottom button).
2. Double click on Handler Mappings. It opens a dialog page showing all the existing mappings. On right it gives certain links to add managed handler
3. Click on Add Managed Handler. In the dialog, add a mapping for .css files as shown1. Hit OK to save
2. Similarly, do a Add Managed Handler for other extensions like .js,.png,.jpg and gif.
3. Now when you browse your pages from your IIS, they should render css, display images and javascript should work.

Ideas in my mind

Disclaimer: All of these ideas are original and anyone can copy it and make an app out of it. I would be please if you will appreciate me for it :)

Please let me know if they are already implemented.Thanks.

1. 3D Game on Mahabharata or Ramayana:

I feel there should be a game on the Epic Mahabharata which would be similar to Counter Strike like you could play on lan, various Kurukshetra maps etc. The creative part here would be that not every soldier will have the same kind of weapons, for instance Arjuna would be a archer, Duryodhana will have his Gada, Some will have  Sword and so on. Every1 will have some godly weapons like Arjuna will have some Divya-astra and sso on. Even more, we can make it like some participant becoming Krishna will always stay with arjuna and provide cheat codes. Krishna won’t have any weapon but will have cheat codes being exposed as random key strokes from the game program. The way we have in Counter strike as Counter Terrorist vs Terrorist, we will have it as Kaurvas vs Pandvas. So, I believe that even though i haven’t formuated the game perfectly, but the motive behind this is that people will come to know more about mahabharta and based on the cheat codes we can help gamers know stuff like “for killing bhishma you have to bring shikandi in front of hime” and some similar things. This way, I believe it could be formuated well.

A simple game could be built for Ramayana that would have something like different levels of fight against the soldiers of Ravan and then finally Ravan at the last level. We can portray the story of Ramayana in the back like it does in Prince of Persia or Max Payne. The story would be something like Ravana took away Sita, Hanuman burning the lanka and so on.

2. Facebook App for Opinion:

I believe you would some concern in your mind that you would want to know opinion from your friends. For instance if you should join a certain college or not Or would a certain tie suit your particular colored shirt. So what you may do is create such a question whose answer would be boolean(Yes or No). Your friends would answer Yes or No and your answer will be posted anonymous, so it would not be know if anyone gave a positive or a negative opinion. Well getting such a stats like 20 say the tie will suit and 19 say wont suit will help a user to make  a buying decision.

3. Browser Plugin to see relevant ads based on positive or negative opinions:

Well people keep expressing their opinions on their blogs or comment a review at certain place. The idea is that using NLP -Natural Language Processing any one can do a analysis on the text and know that if its a positive opinion or a negative opinion.So, for instance if any one comments on a certain blog or puts a review on  say rottentomatoes.com something like this

“Avatar movies direction was really awesome. Its a must watch”.So by NLP our plug in can know that someone expressed a positive opinion on a movie. Hence, our plug in would now put a link besides the text which if user clicks would redirect him to buy the Avatar movies DVD or a ad of netflix where he could rent the movie.

“It seems scifi movies are boring. I should rather watch a horror movie tonight”. So by using NLP our plugin can know that someone expressed a negative opinion on a movie. You can now put a link on the side of the text which would redirect the user to buy alternative domain movie like a horror or something else. I know that the link wont be put out on the fly in an instant and would be visible to the user who was writing the comment but if any reader of that page (who would have installed this nice plugin of ours which gives relevant ads in the middle of text) would see the link to that.

4. Improving Search Results based on what links have you bookmarked:

I think that  there should be a app which should crawl inside the websites that you have bookmarked and hence any result that is inside the bookmark of the user should get a higher rank. Or atleast the user should be able to see the results that belong within his bookmarked links. So, think that if you have book marked an article of person talking about some solution to a trouble people face in a technology say “Hosting ASP.Net MVC app on server” so the article mentions its steps and you have bookmarked it.

So the next time you are searching on bing or google and if a search result comes up and if its a crawled webpage from your bookmark then it should be highlighted and given a higher rank.

Follow

Get every new post delivered to your Inbox.