Sunday, July 25, 2010

Problem: Slow Internet on Windows 7

I recently bought a Dell 1564 and installed Windows 7 Ultimate (64 bit) on it. Before this laptop I had a Dell Latitude 610 with Windows XP Professional (32 bit). Ever since I satrted using Windows 7 I always got a felling that I was experiencing very slow internet browsing speeds. I tried all the major browsers IE 8 (that came with Windows 7), Mozilla Firefox 3.6.3 (both with and without add ons) and of course my personal favorite Google Chrome.

Before Windows 7 (i.e. on Windows XP Professional) on the same Internet Connection (a Mobilink Infinity Wifi Broadband Connection) I was having a great Internet surfing and downloading experience. So finally after some 2 months of suffering, I finally decided to see if I was the only one suffering from the same issue and thus decided to do a Google Search and found out that I was not the only one with the help of Google Suggest, so instead of writing my own search query I decided to go with Google Suggest and searched for "slow internet windows 7".

So the first article that came up in search at that time was Microsoft's own explanation in the form of an article titled "Why is my Internet connection so slow?", after skimming through the article I found that this was of no use to a tech user as he would have already checked and made all the suggestions provided in the article. Then I found two really helpful articles on "Microsoft Social" which were "Painfully slow internet on Windows 7" and "Slow Internet and Page Timeouts". Although the second article was intended for Windows Vista, but works for Windows 7 as well. Here I will summarize only the key points from the two and will try to make them equally useful for both teach and general user. Please be advised not to make any changes to the Windows Registry without proper backup or supervision and better to try out all the other suggestions leaving registry as the absolute last resort.

Use Selective Startup (Clean Boot)
  • Click Start, click Control Panel, click Administrative Tools, and then double-click System Configuration.
  • Click Continue, or provide Administrator credentials if prompted.
  • Click the General tab, and click Selective startup.
  • Under Selective startup uncheck Load startup items.
  • Click the Services tab, check the Hide all Microsoft services box, and then click Disable all (not necessary to disable all services but a few that take up internet or network resources. On Dell its found that "Advanced Networking Service" by Dell is found to cause the problem).
  • Click the Apply, then OK, and then Restart.


Use Fix it For Me or Fix it Yourself
  • For all the Help please go here.

Disable IP v6

Try uninstalling IPv6 on all interfaces, removing any IPv6 virtual adapters, and resetting the TCP/IP stack. To remove IPv6, go into the properties for each network adapter and either uncheck the box next to the protocol "Internet Protocol version 6 (TCP/IPv6), that will disable it, or select it and click uninstall, which will remove it off the computer. Then go into device manager and remove any 4to6 adapters, WUN miniport adapters, or tunnel adapters.

NOTE: You should do this for each network connection.

Tuesday, June 29, 2010

Installing MongoDB Service on Windows7

The time when SQL was considered to be the Lingua Francia for data storage and retrieval will soon be coming to an end. No SQL databases have shown that they are way faster when it comes to data storage and retrieval. Among the many new Object or Document Databases (for simplicity we will refer to them as No SQL Databases) MongoDB is one which has shown and is still showing a lot of promise. In order to make it easier for people to you can find a comparison fo SQL Server 2008 vs. MongoDB here.

Now lets have a look at how to install MongoDB as a service on Windows7, (below are actual extracts from http://www.michaelckennedy.net/blog/2010/04/29/MongoDBVsSQLServer2008PerformanceShowdown.aspx)

  • Download and extract the MongoDB archive appropriate for your system. http://www.mongodb.org/display/DOCS/Downloads
  • Copy the extracted folder to C:\ and rename it mongo.
  • Create a directory called 'data' inside C:\mongo
  • Click on the Start Menu and enter "cmd" in the search box. Right-click on cmd.exe and select "Run as administrator." This is VERY important because you won't be able to register MongoDB as a service if you run cmd.exe with normal privileges.
  • Type "C:\mongo\bin\mongod --install" to register MongoDB as a Windows service. This will probably output what may look like an error message, but don't worry ... as long as you really did run cmd.exe with administrator privileges, everything is fine.
  • Click on the start menu and enter "regedit" in the search box. Click on regedit.exe, and then browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services. There should be child folder there named MongoDB that has several keys inside it. If not, go back to step 4 and try again.
  • The ImagePath key should read "c:\mongo\bin\mongod --service" right now; change it to "c:\mongo\bin\mongod --service --dbpath c:\mongo\data". This will allow MongoDB to find its data files.
  • Click on the Start Menu and enter "services" in the search box. Click on the "Component Services" option.
  • In the pane on the far left, double-click on "Services (Local)." Locate MongoDB in the list in the center pane, and double click on it to bring up the properties inspector window.
  • Make sure "Startup type" is set to automatic. Then click on the "Start" button.
  • Browse to http://localhost:28017/ to verify that MongoDB is really running.
The purpose sharing the actual extracts from the above mentioned article was to increase the availability and have more and more people switch to MongoDB and to keep it for my own reference as well.

Saturday, February 27, 2010

Computer Science: Getting the Basics Right - Part I

I was having a chat the other day with a really good friend of mine who has done his Bachelors and Masters in Computer Science from the same universities as me, I am his junior and also have had the pleasure of working in the same Software company as him. In this chat he said that using .NET controls, fetching data from tables, formating the fetched data is not really the work of Computer Scientists, the real work for us is Research.

After three years in Software Development and being a Senior Software Engineer (one of the best that I have came across) I have to admit he is right. This chat made me some what rest less as well and began searching and exploring as to what Computer Science really is? And also what should be the mind set of person having a degree in Computer Science?

The whole idea behind this series of articles is the get confusions and mis-conceptions out of not only my mind but the minds of others particularly from the minds of young CS graduates. The matter discussed in this part has been taken from Episode 1: Getting Right the Basics.

What is Computer Science?
  • Its not programming, Programming does have a fair share, but still you can not give it more than its actual worth.
  • Its not Quality Assurance, no offence to QA people we love you and can not live with out you.
  • Computer Science us the study of Algorithms, their formal and Mathematical Properties like: correctness, Cost, Efficiency, Limits, their Hardware Realizations like: Computer Design, their Linguistic Realizations like: Programming Languages Theory, thier Applications like: Network Design, Bio-informatics, Ocean Modeling, etc.
  • The above is the definition of Computer Science as given by two great researchers of Computer Science: Gibbs and Tucker.
  • The above definition is the most clear and concise definition thats presentable and should be understandable to one and all.
  • If you have a degree in Computer Science, the algorithms is the name of the game.
Since now we know what Computer Science REALLY is lets explore it TOGETHER.

Wednesday, September 30, 2009

Coding Tips for ASP .NET

I came across this article that will most certainly help out beginners of ASP .NET programming.


1.Smart navigation

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the tag to the following location within your Web.config file:





Note that smart navigation works on only Internet Explorer 5 and above; however, ASP.NET will automatically detect this and serve up the ?smart? code only if the target browser supports it.

Also, I?d personally advise that you test it against any third-party menu controls or scripts you may have running: it is prone to falling over on particularly advanced pages.

2.Stopping Your User from Right-Clicking

Want to prevent your user from performing any of the other commands available by right-clicking on a Web page in Internet Explorer? It?s not foolproof, but this neat little HTML edit usually does the trick.

Just alter the opening BODY tag of your HTML to the following: oncontextmenu="return false".


When the menu is requested, the oncontextmenu event runs, and we instantly cancel it using JavaScript. This is especially potent as a method for stopping the user from viewing your source, when used in conjunction with a menu-less browser window. Great stuff!

3.Creating Images Dynamically

Ask any ASP developer who has ever tried to dynamically create his own images and he?ll tell you it?s a nightmare. In fact, it?s more than a nightmare. It?s practically hell. The only true solution? Reverting to an expensive, dodgy, third-party control to do the work for you.

With ASP.NET, however, you can develop your own dynamic images with ease. Simply create an image object and use the new GDI+ features to add objects to that image, such as text, rectangles, and ellipses. After that, you can simply stream straight back down to the client.

But covering the graphics features in depth would require at least another two books, and, unfortunately, we don?t have that much room. So, I?m going to share a sample that demonstrates creating a small ?Drawing? button, alongside a little blue-and-yellow bullet point.It?s the sort of personalized graphic you?ll find on sites such as Amazon.com.

Here?s the code:

Bitmap objBitmap = new Bitmap(120, 30);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.LightBlue), 0, 0, 120, 30);
objGraphics.FillEllipse(new SolidBrush(Color.Blue), 3, 9, 10, 10);
objGraphics.FillEllipse(new SolidBrush(Color.Yellow), 4, 10, 8, 8);
objGraphics.DrawString("Drawing", new Font("Tahoma", 8), new SolidBrush(Color.Green), 16, 8);
Response.Clear();
Response.ContentType = "image/jpeg";
objBitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
objGraphics.Dispose();
objBitmap.Dispose();

You can put it inside any event you want.

4.Clear All The Textbox Values (Reset Function)

In Classic ASP, to clear all the textboxes in a form, to start over, we just had to use a simple html 'Reset' button in the form. Sometimes that works in ASP.Net;sometimes it doesn't.

Here are a couple of ways to do this, iterating through the ASP.Net TextBox controls in a form --
Just create a Reset type subroutine - in that routine, use the following code:
in C# - it would be:

Control myForm = Page.FindControl("Form1");
foreach (Control ctl in myForm.Controls)
if(ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
((TextBox)ctl).Text = "";

This will clear EVERYTHING from the textboxes - even if you had them pre-populated with data. A VERY simple way to just reset it to the condition at Page_Load time, just do this in the Reset SubRoutine:

Server.Transfer("YourPageName.aspx")

5.Pressing Enter key

Sometimes, you will notice, that, in an ASP.Net form, depending on the circumstances, pressing the 'Enter' key to submit the form does not work.

To force this to happen for a particular button on your page, just put this in the Page_Load routine:

Page.RegisterHiddenField("__EVENTTARGET", "button1")

Then, change 'button1' to the ID of your particular button. Understand, of course, if your cursor is inside of a MultiLine textbox, the default action of the enter key is to create a new line in the textbox, so, if this basically works anywhere outside of that scenario.

6.ASP.Net Server Controls Not Showing on pages

It's possible that ASP.Net is not registered correctly on your system.Try running aspnet_regiis from the command prompt.

Here's the default location:

C:\WINDOWS\Microsoft.NET\Framework\<>\aspnet_regiis.exe -i

Windows Server 2003, you must use aspnet_regiis -i -enable. This is because of the "Web Service Extensions" feature in IIS 6


I basically copied the stuff from http://www.codersource.net/asp_net_simple_tips.html for my own reference and for others.

Wednesday, July 1, 2009

Visual SourceSafe vs Visual Studio Team Foundation Server

Visual SourceSafe
  • Visual SourceSafe 2005 is a completely self-contained system that requires no other software.
  • Some teams or individuals will only need source code control. Visual SourceSafe 2005 is simple, lightweight, and easy to use, and so it is ideally suited for this type of customer.
  • The desktop-based nature of Visual SourceSafe is suitable for basic file sharing for teams who need occasional collaboration; it is not intended for scenarios where a high degree of parallel development is required.
  • Visual SourceSafe is licensed individually.


Visual Studio Team Foundation Server
  • Visual Studio 2005 Team Foundation Server is a server-based system that leverages several Microsoft technologies: IIS, SharePoint Services and SQL Server 2005.
  • Visual Studio 2005 Team Foundation Server supports the full spectrum of software configuration management functionality for projects that requires a detailed level of requirements management, auditing, and project management.
  • Team Foundation Server picks up where Visual SourceSafe 2005 leaves off in these respects. Its server-based nature is ideal for geographically distributed teams.
  • Team Foundation Server is licensed on a server and CAL (client access license) model. For customers who will be adopting one of the Visual Studio Team System client components, using Team Foundation Server is the obvious choice, from a cost perspective.


The original article can be found at: http://www.neokobe.nl/team-foundation-server-vs-sourcesafe.php

Wednesday, June 24, 2009

MagOnline Theme for Wordpress - Top Commentators Error

In one of our Wordpress projects, we used the MagOnline, from Elegant Wordpress Themes. The theme adds some useful and handy information at the bottom, which includes Tag Cloud, Top Commentators, Partners and Recent Comments. After downlaoding and installing the theme I found that in the Top Commentators section it was giving me the following error message:

Warning: Invalid argument supplied for foreach() in wp-content\themes\magonline\functions.php on line 621
Now first of all I will describe why the error is coming up. This error shows up when there are no comments in the database, since there are no comments hence the system cannot find a top commentator. A scenario that should have been taken care of, as this is the simplest of them all. So now we know why the error was showing up we can get busy with how to fix it. We have the following two solutions:

The Simplest Solution (If you are not tech savvy or are in a hurry)

Just add a comment. This could be any comment on any post and the error will be gone.

The Proper Solution

This solution requires a good understanding of PHP. If you go in to the file mentioned in the error i.e. wp-content\themes\magonline\functions.php, you will find a function top_commentators the following code:
function top_commentators($limit=8){
global $wpdb, $post;
//$top = $wpdb->get_results("SELECT $wpdb->comments.comment_author, comment_author_url, comment_ID, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->comments WHERE comment_approved = '1' LEFT JOIN $wpdb->comments ON $wpdb->comments.comment_author = $wpdb->comments.comment_author WHERE comment_approved = '1' LIMIT 4");
$top = $wpdb->get_results("SELECT * FROM $wpdb->comments");
foreach ($top as $t){
$comm[$t->comment_author][] = $t;
$commlink[$t->comment_author] = $url = $t->comment_author_url=="http://"?"mailto:".$t->comment_author_email:$t->comment_author_url;
}
$x=0;
foreach ($comm as $t2n=>$t2v){
if ($x<=$limit){ $comm2[$t2n] = sizeof($t2v); } $x++; } foreach ($comm2 as $t3n=>$t3v){
echo '' . $t3n . ' (' . $t3v . ')';
}
}

just replace it with the following:
function top_commentators($limit=8){
global $wpdb, $post;
//$top = $wpdb->get_results("SELECT $wpdb->comments.comment_author, comment_author_url, comment_ID, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->comments WHERE comment_approved = '1' LEFT JOIN $wpdb->comments ON $wpdb->comments.comment_author = $wpdb->comments.comment_author WHERE comment_approved = '1' LIMIT 4");
$top = $wpdb->get_results("SELECT * FROM $wpdb->comments");
// Looks like the plug-in writers forgot to handle the scenario when there are no comments in the Wordpress database
if(!empty($top))
{
foreach ($top as $t)
{
$comm[$t->comment_author][] = $t;
$commlink[$t->comment_author] = $url = $t->comment_author_url=="http://"?"mailto:".$t->comment_author_email:$t->comment_author_url;
}
$x=0;
foreach ($comm as $t2n=>$t2v)
{
if ($x<=$limit) { $comm2[$t2n] = sizeof($t2v); } $x++; } foreach ($comm2 as $t3n=>$t3v)
{
echo '' . $t3n . ' (' . $t3v . ')';
}
}// end of if(!empty($top))
}

And you are good to go. The code has not changed simply a check has been added before the the loops, just to make sure that the result set that is being fetched from MySQL is not empty and that does the trick. Hope this helps :)

Saturday, June 13, 2009

Facebook Username

As of today Facebook has added the functionality of users being able to select usernames. The immediate benefits of this are:
  • Users will be able to direct their friends to their profile in:
    • a more direct and easy manner
    • Profile links can now be shared verbally
  • Facebook was nagging behind in this are when compared with other social networking services like LinkedIn and MySpace, which already allow their users to share their profiles in the above manner.
So hurry up and get your username, before its taken up by someone else. To select a username for Facebook visit: http://www.facebook.com/username/

The good thing about Facebook usernames are that they allow you to have  periods (.) in the username and the suggested usernames are also very good.

Now since Orkut is trying to memic Facebook, we may see the username feature being implemented on Orkut as well in some time (just a guess, do not bet on it).