<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sumit Gupta &#187; Concept/algorithm</title>
	<atom:link href="http://www.sumitgupta.net/category/programming/conceptalgorithm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sumitgupta.net</link>
	<description>bookmarking my life</description>
	<lastBuildDate>Wed, 08 Feb 2012 11:23:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Static Object in ASP.NET</title>
		<link>http://www.sumitgupta.net/static-object-in-asp-net/</link>
		<comments>http://www.sumitgupta.net/static-object-in-asp-net/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 12:03:22 +0000</pubDate>
		<dc:creator>Sumit Gupta</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Concept/algorithm]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[VB.NET/VB]]></category>
		<category><![CDATA[SQLConnection]]></category>
		<category><![CDATA[Static Object]]></category>

		<guid isPermaLink="false">http://www.sumitgupta.net/?p=520</guid>
		<description><![CDATA[Recently I found a problem in one of application we developed. Here my colleague use a Static SqlConnection object through a class in his code. He did that to save his effort of writing and Connection everytime. Everything works great during our development and online reviewing. However as soon as we lauch website in beta [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found a problem in one of application we developed. Here my colleague use a Static SqlConnection object through a class in his code. He did that to save his effort of writing and Connection everytime. Everything works great during our development and online reviewing. However as soon as we lauch website in beta mode, it start creating problem which seems bit random in occurance and hence were hard to track. During this time I get involve in the project development and I was not very big fan on Static object and start to think against that code, which looks good to me at first. However for some reason I miss the basic of C# and ASP.NET and hence it took a while to recognize the problem was indeed the static code. So for those who did same mistake here is explanation of why Static object didn&#8217;t work in ASP.NET for connection.</p>
<p>When ASP.NET application is first called the complete code is loaded in Memory, specially the pages in App_Code folder and they act as part of web server and not as standard PHP site where they run and loaded on each request. Hence, once this happens all static object become static in memory for each and every request your server will get. This is indeed good way to share information between all User and all request, if that help your case. But in most general case you never want to share information between user in this dynamic method, which is not permanent. Anyways, for connection it really doesn&#8217;t make a difference if you share the object as you anyways want to open connection and close it as soon as you are done. In most case you have 1 simple insert or fetch query to run. And in a website with several users at a time it hardly make a difference as Sqlconnection are open and close in jiffy and took less than 1 second in most cases. For a shopping cart which has 100 -200 order per month this case will work just fine.</p>
<p>However, since connection is shared, there is every possible chance that if you fire a SQL query for say Reader, it get shared with some user on some other session and this is what you don&#8217;t want. It happens to our project when we have Bulk CSV upload which usually take 30-50 seconds, but if someone during this time fires and open other page of website they start to get random Database related errors. From SqlReader is close to field &#8220;Xyz&#8221; is not available, as they tend to share the connection with other requests.</p>
<p>Hope you avoid those problem. The colleague who did this in our project is not working with us anymore, but hey, where ever you are , please don&#8217;t punish us like this again !!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sumitgupta.net/static-object-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selecting menu item using Javascript</title>
		<link>http://www.sumitgupta.net/selecting-menu-item-using-javascript/</link>
		<comments>http://www.sumitgupta.net/selecting-menu-item-using-javascript/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 19:55:41 +0000</pubDate>
		<dc:creator>Sumit Gupta</dc:creator>
				<category><![CDATA[Concept/algorithm]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.sumitgupta.net/?p=487</guid>
		<description><![CDATA[Okay, I create a pure CSS menu that use UL/LI structure to maintain the child relationship. All was great with this menu except that when you are on any of menu item page it doesn&#8217;t highlight that menu item explicitly. If you consider this it is not a big deal. What you can do is [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, I create a pure CSS menu that use UL/LI structure to maintain the child relationship. All was great with this menu except that when you are on any of menu item page it doesn&#8217;t highlight that menu item explicitly. If you consider this it is not a big deal. What you can do is simply, iterate through the Menu Items which are probably in LI A tags. Once you iterate, find the URL in A tag and match the Page URL with the Menu ITEM link. If they match change the Class of respective LI or A as your liking.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> path <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/User/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>path <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>
        path<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Userhome.aspx&quot;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mainemnu a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> path.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;submenuitem&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//it is sub menu</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;selectedmenu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;selectedmenu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>That was a simple Jquery Driven Javascript function that I call in Document ready function of Jquery.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sumitgupta.net/selecting-menu-item-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC : First Encounter</title>
		<link>http://www.sumitgupta.net/mvc-first-encounter/</link>
		<comments>http://www.sumitgupta.net/mvc-first-encounter/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 08:18:26 +0000</pubDate>
		<dc:creator>Sumit Gupta</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Blog: My thoughts]]></category>
		<category><![CDATA[Concept/algorithm]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Concept]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://www.sumitgupta.net/?p=436</guid>
		<description><![CDATA[I have been reading about upcoming of MVC from quite few years, but I never feel the need of it. It is surprisingly but yes, I never feel of MVC in web development. I have created my own coding pattern which is good for most programming I have seen in my career. But still MVC [...]]]></description>
			<content:encoded><![CDATA[<p>I have been reading about upcoming of MVC from quite few years, but I never feel the need of it. It is surprisingly but yes, I never feel of MVC in web development. I have created my own coding pattern which is good for most programming I have seen in my career. But still MVC always seems to attract me. So finally I decide to give it a try. I remember I try it with CodeIgnitor in PHP previously and was not very impressed with idea of MVC as I see it not quite upto the task as anyother framework it tend to load those load of script that are necessary to run MVC and the framework fine. Sometime you never need that many files. But still I was wondering why people look for something in that line? Well you never learn answer of such question unless you try yourself. So, I try it with .NET 4.0, when I got a chance to make a mobile website. I have to make a really small website and I feel it is best for to learn during this website development. I start it out with video tutorial and thanks to Scott Hanselman&#8217;s webcast I get my mind clear on MVC concepts in .NET and what is MVC in general.</p>
<p>Though MVC looks promising but I feel it is not probably not very mature or maybe not a good idea for big projects. I feel it little complex to make architecture of application with MVC as compare to transition event driven programming or procedural programming of old PHP. But yes it is way to dynamic and based on naming convection and assumption/concepts. Which make it cool. At first it looks good to me, but my second thought came in, if dynamic binding is that good then why we need Strong Data Type in applications? Why .NET or Java strats like that and why PHP is going for OOPS programming which again become strong data type somewhere? Isn&#8217;t it slow to use dynamic binding then to static binding?</p>
<p>MVC is good for Expertise in either programming, designing or database handling. This make it good choice for enterprise software but definiately for a Geek programmer I feel it is not upto the mark. BTW why a geek programmer care about what is buzz in market, he do his job perfect anyways.</p>
<p>I am confused about MVC , I am not sure if I will adopt it in my future programming yet or will wait for something better to come up. Any advice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sumitgupta.net/mvc-first-encounter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PWNAT : Example</title>
		<link>http://www.sumitgupta.net/pwnat-example/</link>
		<comments>http://www.sumitgupta.net/pwnat-example/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 19:12:32 +0000</pubDate>
		<dc:creator>Sumit Gupta</dc:creator>
				<category><![CDATA[Concept/algorithm]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[NAT Traversal]]></category>
		<category><![CDATA[PwNAT]]></category>

		<guid isPermaLink="false">http://www.sumitgupta.net/?p=366</guid>
		<description><![CDATA[I am having trouble to run PwNAT successfully. The problem was created due to sample provided on official site. Here is how you should run it for case Machine A (IP: 192.168.1.3) -&#62; NAT A (IP: 122.x.x.x) -&#62; Internet -&#62; NAT B (IP: 59.x.x.x) -&#62; Machine B (192.168.2.10) Now if Machine A wants to connect [...]]]></description>
			<content:encoded><![CDATA[<p>I am having trouble to run PwNAT successfully. The problem was created due to sample provided on official site. Here is how you should run it for case</p>
<p>Machine A (IP: 192.168.1.3) -&gt; NAT A (IP: 122.x.x.x) -&gt; Internet -&gt; NAT B (IP: 59.x.x.x) -&gt; Machine B (192.168.2.10)</p>
<p>Now if Machine A wants to connect to Machine B and want to access Machine B&#8217;s Webserver. Here is what you do</p>
<p>Machine B is a Server in our case so run server here:</p>
<p>#./pwnat.exe -s 192.168.2.10 2222</p>
<p>Now on Machine A run this</p>
<p>#./pwnat.exe -c 192.168.1.3 2222 59.x.x.x 2222 localhost 80</p>
<p>Let me explain which values came from what.</p>
<p>First for server:</p>
<p>If you do not define the local IP, and define something like 0.0.0.0 which is ANY IP for machine, then PwNAT do not send the correct IP through NAT A and hence NAT A never forward any incoming request to you. So server IP must be your machine main IP or LAN IP that is connected to NAT A router. IF you have multiple IP Only specific the IP that NAT A router can understand, otherwise it will fail for sure.</p>
<p>You can define any port by since pwnat use 2222 as default I use that</p>
<p>Now on client, I again define Local IP that is understand by NAT B, to avoid any confusion, but here it can be anything because it is used for Tunnel and hence it will not interact with NAT. Port is again any random port you want. Later we define the NAT B Server&#8217; IP because we want to make sure we send Packet to that router. hence we use 59.x.x.x IP. Please note that while establishing connection PWNAT do not use any port. Now Proxy Port is 2222 this should be the same port that server is open. Otherwise connection won&#8217;t happen for obvious reason.</p>
<p>Localhost and port 80 is Domain or IP where you want to get connected through NAT traversal Proxy.</p>
<p>I will try to write a code in .NET library but for now. I will use my NMAKE complied copy of pwnat 0.3 beta version. Yes I compile it using NMAKE without Cygwin and it works superb on my windows 7 machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sumitgupta.net/pwnat-example/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Linux User authentication using PHP</title>
		<link>http://www.sumitgupta.net/linux-user-authentication-using-php/</link>
		<comments>http://www.sumitgupta.net/linux-user-authentication-using-php/#comments</comments>
		<pubDate>Mon, 04 Sep 2006 06:46:00 +0000</pubDate>
		<dc:creator>Sumit Gupta</dc:creator>
				<category><![CDATA[Concept/algorithm]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikasumit.wordpress.com/2006/09/04/linux-user-authentication-using-php/</guid>
		<description><![CDATA[Hi, in one of my last post i try to define how linux store its password. Today I will be putting Complete PHP code for it. Just run it on your local server(mind it your Http server must be running as root user in order to use this script ) Its a raw way of [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>in one of my last post i try to define how linux store its password. Today I will be putting Complete PHP code for it.</p>
<p>Just run it on your local server(mind it your Http server must be running as root user in order to use this script )</p>
<p><span style="font-weight:bold;">Its a raw way of doing password matching and shouldn&#8217;t be used for commerical application or servers.</span> its purely Learning script</p>
<p>So here goes the script</p>
<p>6 &amp;&amp; CRYPT_MD5 == 1) {<br />
$salts = explode(&#8220;$&#8221;,&#8221;$userlist[1]&#8220;);<br />
$salt = &#8220;\$1\$&#8221;.$salts[2].&#8221;\$&#8221;;<br />
$gen_password= crypt($password,$salt);<br />
if ($gen_password == $userlist[1]) {<br />
$UserMatch = true;<br />
}<br />
else<br />
{<br />
$UserMatch = false;<br />
}<br />
}<br />
else {<br />
$UserMatch = false;<br />
}<br />
break;<br />
}<br />
}<br />
return $UserMatch ;<br />
}</p>
<p>if (ReadUser(&#8220;sumit&#8221;) == true)<br />
{<br />
if (MatchPassword(&#8220;sumit&#8221;,&#8221;sumit&#8221;) == true )<br />
{<br />
echo &#8220;Login successful&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;Login unsuccessful&#8221;;<br />
}<br />
}<br />
?&gt;</p>
<p>Hope that helps learn understanding linux passwd and shadow usage.</p>
<p>Sumit Gupta</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sumitgupta.net/linux-user-authentication-using-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

