Tuesday, March 23, 2010

How to configure SQL Server for ASP.NET SQL Server Session State <sessionState mode="SQLServer" ../>

On your prompt (doesn’t matter if you’re on the SQL server machine or not), run the below command:
”system root”\Microsoft.NET\Framework\”version number”>aspnet_regsql.exe –S “server” -U sa -P “Password” -ssadd -sstype p
for eg:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
OR
C:\WINNT\Microsoft.NET\Framework\v4.0.21006>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
Now you have ASPState database on your servers with the tables, stored procedures, jobs needed to handle SQL server mode session state.

Saturday, March 06, 2010

My mentor profile on #ImagineCup updated!

Mohamed Samy has been tweeting a lot lately about ImagineCup, asking people to sign up as mentors & support the Egyptian teams. So, I’m posting this to let you know that I’ve just updated my profile there. So if you’re looking for a mentor (I guess I won’t be useful except in software design competition) look for my profile under the name “Shady M. Najib”.

Along the way, I’m inviting you too, to join ImagineCup both as mentors and competitor, it was & will be a great experience, that one thing you should be sure of.

One last thing I should says here, is that I realized while updating my profile that I set my “Notify me of new private messages” status to “No” which kept a couple of messages off my radar. So please guys & gals, pardon me, that wasn’t intended! :$ I’ll be more attentive next time :)

PS.: remember to check Egypt Local website: http://imaginecupegypt.com/

Friday, January 22, 2010

Quote of the Moment

“So many times, it happens too fast:
You trade your passion for glory.
Don't lose your grip on the dreams of the past,
You must fight just to keep them alive;
It's the eye of the tiger,
it's the thrill of the fight,
Rising up to the challenge of our rival,
And the last known survivor,
stalks his prey in the night,
And he's watching us all with the eye of the tiger..” – Survivor, “Eye Of The Tiger”

Friday, January 15, 2010

Why would you need a Gender table in your DB??

A friend of mine was tweeting about how he found a drop down control in some application he’s working on that binds on a (“lookup”) table with only the 2 rows for male & female.. Check the short conversation on twitter.

In my humble opinion -as weird it may sound-  this approach (for similar, small lookups) might makes sense, in some way. Not exactly as is, may be it will make sense more if it’s within a lookup module (a single table for all lookups where every entry has a lookup type).

Other “regular” approaches (& their expected problems) :

People usually tackle such small lookups using enums, or just using an “agreed on” key/value pairs convention (not stores anywhere in code or DB, may be only a code comment here or there) which usually tend to get forgotten & you have to  trace code to know which key stands for each lookup value..

Even worse, is using a boolean for such

Benefits of a DB Table approach:

Other than the benefits of avoiding the above, using DB to explicitly state lookup values, is that they are more dynamic, ie: you can always edit them without touching much code, that would be handy in cases like:

  • Clients constantly changing small stuff like spelling, etc
  • Adding other functionalities/features, like multilingual support for eg..

Thus, I find avoiding enums, etc & using tables even for small stuff like that gender much more convenient..

Let me know what you think about it, & (hopefully) suggest a better approach..

Saturday, January 09, 2010

TekPub/CodeThinked Challenge

 

Justin Etheredge posted this challenge on CodeThinked so I thought I should give it a try though I’ve just had my TekPub subscription (Looking forward to use it, heavily!! :D)

So here’s my solution:

var myPrimes =
                Enumerable.Range(1, SomePositiveValue)
                    .Where(x => x != 1 &&
                        !Enumerable.Range(2, (int)Math.Ceiling(Math.Sqrt(x)))
                            .Any(y =>   x % y == 0 &&
                                        x != y));

You might want to remove the “x != 1” depending on you consider 1 as a prime or not :)

Disclaimer

All the opinions expressed on this blog are my own and don't necessarily represent my employer's positions, strategies or opinions.