February 25, 2011

ROBOTS tag

What's ROBOTS tag?
How to use of ROBOTS meta tag?
What's ROBOTS meta tag?

Introduction
We know that search engines handle meta tags and the ROBOTS is a part of META tags[1]. The HTML META ROBOTS Tag help and talk to search engines crawlers. The standard and valid values for the CONTENT attribute are just "INDEX", "NOINDEX", "FOLLOW" and "NOFOLLOW but the valid meta robots content values fo G-BOT are:
NOINDEX: prevents the page from being included in the index.
NOFOLLOW: prevents Googlebot from following any links on the page.
NOARCHIVE: prevents a cached copy of this page from being available in the search results.
NOSNIPPET: prevents a description from appearing below the page in the search results, as well as prevents caching of the page.
NOODP: blocks the Open Directory Project description of the page from being used in the description that appears below the page in the search results.
NONE: equivalent to "NOINDEX, NOFOLLOW".
FOLLOW: a command for crawler to follow the links in that webpage.
INDEX: a command for crawler to index that webpage.
INDEX, FOLLOW: Follow The search engine robots will start crawling your website from the main/index page and then will continue to the rest of the pages.
<meta name="robots" content="index, follow">
I know that "INDEX, FOLLOW" is unecessary content values and by default, Google-BOT will index a page and follow links to it and there's no need to have a tag with content values of INDEX or FOLLOW but i want to sure about G-BOT and other BOTs. You can find list of all BOTs from here.

References
[1] http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html
[2] http://www.robotstxt.org
[3] http://www.siteground.com/metatag_optimization.htm
[4] http://en.wikipedia.org/wiki/Meta_element

February 24, 2011

jQuery and Visual Studio 2010

- How to use of jQuery in Visual Studio?
- How to enable jQuery intellisense in and Visual Studio 2010?
- How to active jQuery intellisense in visual studio?
- How to start develop jQuery code in visual studio like C# !!!

Solution
Come on and follow these steps for active and enjoy jQuery in Microsoft Visual Studio ;-)

1- Download jQuery VSDoc from Visual Studio links in jQuery.com > Download Center
    Download Center: http://docs.jquery.com/Downloading_jQuery
    jQuery for Visual Studio v1.4.1: http://code.jquery.com/jquery-1.4.1-vsdoc.js
    jQuery for Visual Studio v1.7: http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7-vsdoc.js

2- Add this JavaScript to your solution

3- Add this script tag in your page


4- Enjoy!

February 18, 2011

Entity Framework with ASP .NET Web Application and Microsoft SQL Server

This is a fastest tutorial for learning about Entity Framework with ASP .NET Web Application and Microsoft SQL Server. I promise to you that is a simplest and overall.

VIDEO


STEP by STEP
1- Open Microsoft Visual Studio 2010
2- Add New Project from menu with select File > New > Project > ASP .NET Empty Web Application from New Project window

3- Go to Solution Explorer and right-click on WebApplication1 and select Add > New Item > SQL Server Database from Add New Item window
4- Go to Solution Explorer and double-click on Database1.mdf
5- Go to Server Explorer and right-click on Tables (from Database1.sdf) and select Create Table from context menu
6- Save this table as Table1 like below screen shot.

7- Go to Server Explorer and open Tables and right-click on Table1 table and select Show Table Data from context menu and add some data in rows.


8- Go to Solution Explorer and right-click on WebApplication1 and select Add > New Item > ADO.NET Entity Data Model > Generate from database > Next > select Table1 from Tables > Finish
9- Press F6 for Build Solution and TAKE A BREATH :-D
10- Right-click on WebApplication1 from Solution Explorer and go to Add > New Item... > Web > WebForm > Design and select a GridView from Toolbox and drag and drop it to WebForm1
11- Select GridView Tasks from top-right corner of GridView and select Choose Data Source and select Entity > Database1Entities > Table1 and Finish.

12- Compile, Run and ENJOY :-D
PS: Hey folks, if did you have any problem please don't be hesitate to contact me or write comment here ;-)

Entity Framework Tutorials
Entity Framework with Windows Form Application and Microsoft SQL CE
Entity Framework with ASP .NET Web Application and Microsoft SQL Server

Download
Source Codes: link

February 14, 2011

Print Anywhere With Google Cloud Print

With Google Cloud Print you can connect your local printers to Google and go any where and connect to internet and send a print tasks to your printers from Google. It's not magic and it's so simple.
You can go to Google Chrome options and connect your home printer(s) to Google Chrome (with Google Cloud Print Service) and then if you go to any where, and send a print task from Google Applications on PC, Mobile. Google Application Website or anywhere, Google find your Google Chrome in home and send the print tasks to your home printers.

Setup
1- You can see my printers

2- Open your Google Chrome and Select Options


3- Find out Google Cloud Print in Under the Hood and select Sign-In button

4- Add you Google account (or gmail account ...) and give a success message. (i love Print a Test Page and if you love it, test it and enjoy it :-D)


5- By the way you can find Manage Print Settings... button in Google Cloud Print in Chrome Options... and go to Google Cloud Print Management and surprise.
PS: It's a first try of big G about Chrome OS and Internet Base OS and i think that Net-OS will be available and popular before 2020 if the world don't stop after 2012-21-DEC :-))

References
[1] Google Blog: http://googleappsupdates.blogspot.com/2011/01/print-from-your-phone-with-gmail-for.html
[2] Google Cloud Print Help Support: http://www.google.com/support/cloudprint/?hl=en

Entity Framework with Windows Form Application and Microsoft SQL CE

This is a fastest tutorial for learning about working Entity Framework with SQL Server Compact Edition and Windows Form Application. I promise to you that is a simplest and overall :-D

VIDEO


STEP by STEP
1- Open Microsoft Visual Studio 2010
2- Add New Project from menu with select File > New > Project > Windows Form Application from New Project window

3- Go to Solution Explorer and right-click on solution and select Add > New Project > Class Library from New Project window

4- Go to Solution Explorer and right-click on ClassLibrary1 and select Add > New Item > Local Database from Add New Item window (Cancel the Data Source Configuration Wizard window which opend after that)
5- Go to Solution Explorer and double-click on Database1.sdf
6- Go to Server Explorer and right-click on Tables (from Database1.sdf) and select Create Table from context menu
7- Add a table and set TEST for name it like below screen shot.
8- Go to Server Explorer and open Tables and right-click on TEST table and select Show Table Data from context menu and add some data in rows.

9- Go to Solution Explorer and right-click on ClassLibrary1 and select Add > New Item > ADO.NET Entity Data Model > Generate from database > Next > select TEST from Tables > Finish
10- Go to Solution Explorer and right-click on References form WindowsFormApplication1 > Add Reference > Projects > ClassLibrary1


11- Press F6 for Build Solution and TAKE A BREATH :-D
12- Select WindowsFormApplication1 from Solution Explorer and go to menu and Data > Add New Data Sources > Object > ClassLibrary1 > ClassLibarary1 > TEST
13- Double click on Form1.cs from WindowsFormApplication1 in Solution Explorer
14- Go to menu and select Data > Show Data Source and select TEST and drag and drop it to Form1


14.1- If did you have an error about with below title just go to Solution Explorer > WindowsFormApplication1References > Add References > .NET > System.Data.Entity 4.0.0.0 and double-click on it.

Error 1 The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


15- Double click on a empty space of form and go to Form1.cs > Form1_Load method and add below line for fetch data from database
this.tESTsBindingSource.DataSource = new ClassLibrary1.Database1Entities().TESTs;

16- ENJOY :-D

PS: Hey folks, if did you have any problem please don't be hesitate to contact me or write comment here ;-)

Entity Framework Tutorials
Entity Framework with Windows Form Application and SQL CE

Download
Source Codes: link

February 08, 2011

C# Index Search

Csharp Index Search
C# index searching instead of SQL SELECT

Summery
Sometimes, i heard something about slowest searching on some databases.
For example last night, i heard about a famous company have an oracle database with one billion records in one table and their software have a HUGE LATENCY for a simple compare search (WHERE Cluse) and they wait more than 15 minutes for results.
Everybody's know that's ridiculous for a DBMS like Microsoft SQL or Oracle about 15 minutes on a simple query on tiny database and it's absolutely comes from bad configuration and they need to have a DBA (Database Administrator) instead of another DBMS or Software ...

Solution
Anyway, i developed a simple and simple indexing for demonstrate power of indexing in search processes. I was shocked after coming results

Test Machine:
CPU: Intel Core i5 750 @ 2.67GHz 2.73Ghz
RAM: 4.00GB (3GB useable)
OS: Windows 7 32-bit
Database: Microsoft SQL Server Compact 3.5
Application: developed from 11PM till 6AM just for fun :-)

Search Times:
on 100,000 records = 0.24s (SQL) vs <0.01s (Index)
on 200,000 records = 0.49s (SQL) vs <0.01s (Index)
on 500,000 records = 1.92s (SQL) vs <0.01s (Index)
on 1,000,000 records = 2.46s (SQL) vs 0.02s (Index)
on 1,500,000 records = 5.91s (SQL) vs 0.04s (Index)


Conclusion
From results was shown, search on index files, with the simplest algorithm, are more than 100 times faster than simple SQL QUERY, in normal situation, with any normalization and indexing, on Microsoft SQL CE database.

Appendix I: Screen Shots



Appendix II: Source Codes
You can see the process of make a hundered index file base on two charater of start 10 digits phone numbers. for example if the phone number is 3473380789 then it's store in array[34] and then store in index34.inx file as one of index files.
/// loop all data
ArrayList[] Array = new ArrayList[100];
SqlCeConnection cn = new SqlCeConnection(_ConnectionString);
if (cn.State == ConnectionState.Closed) cn.Open();
string query = "SELECT Phone FROM People";
SqlCeCommand command = new SqlCeCommand(query, cn);
command.CommandType = CommandType.Text;
SqlCeResultSet record = command.ExecuteResultSet(ResultSetOptions.Scrollable);
int RowCount = 0;
if (record.HasRows)
{
    record.ReadFirst();
    do{
        string Data = record.GetString(0);
        int Index = Convert.ToInt32(Data.Substring(0, 2));
        if (Array[Index] == null) Array[Index] = new ArrayList();
        Array[Index].Add(Data);
        RowCount++;
    } while (record.Read());
}

/// Create all index files from arrays
XmlSerializer Serializer = new XmlSerializer(typeof(ArrayList));
for (int i = 0; i <= 9; i++)
{
    for (int j = 0; j <= 9; j++)
    {
        int Index = i * 10 + j;
        Serializer.Serialize(new StreamWriter(_IndexFileName + Index + ".inx"), Array[Index]);
    }
}
and the find result is so simple than making index files
/// Read all index files
XmlSerializer Serializer = new XmlSerializer(typeof(ArrayList));
int Index = Convert.ToInt32(SearchItem.Substring(0, 2));
ArrayList array = Serializer.Deserialize(new StreamReader(_IndexFileName + Index + ".inx")) as ArrayList;
String Message = "NOT FOUND !!!";
if (array.BinarySearch(SearchItem) == 0) Message = "*** FOUND ON INDEX ***";
I think that it's clear about SQL WHERE CLUSE search but i put coeds here for compare
/// Read all index files
SqlCeConnection cn = new SqlCeConnection(_ConnectionString);
if (cn.State == ConnectionState.Closed) cn.Open();
string query = String.Format("SELECT * FROM People WHERE Phone = '{0}'", editPhone.Text);
SqlCeCommand command = new SqlCeCommand(query, cn);
command.CommandType = CommandType.Text;
SqlCeResultSet record = command.ExecuteResultSet(ResultSetOptions.Scrollable);
if (record.HasRows) Message = "*** FIND ***";
else Message = "No record found!";


Appendix III: Downloads
SourceCode: Here
Binary: Here

LC.exe Error and Devexpress

- The specified task executable "LC.exe" could not be run. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail
- LC.exe error and conflict between DXperience and .Net Framework 4.0




Solution: 
If did you have any problem with Devexpress v10.1 (and lower) and .Net Framework 4.0 then it's simple. JUST REMOVE licenses.licx file from project.

February 05, 2011

HTTP Error 403.14 - Forbidden

Error:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Internet Information Services 7.5

Cause:
If did you have ASP .NET Application on IIS 7.0 and in your ASP .NET Form/MVC used Routing or any handler for reroute/rewriting you need to have premession for access to files directories.

Solution A:
Add these lines to Web.config

<httpHandlers>
    <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
        <remove name="BlockViewHandler"/>
        <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
    </handlers>
</system.webServer>


Solution B:
The Solution A solved my HTTP Error 403.14 - Forbidden error but give me another error: HTTP Error 404.0 - Not Found. Replaced just this codes instead of Solution A code

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"> 
    <remove name="UrlRoutingModule"/> 
    <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
  </modules> 
</system.webServer>

February 01, 2011

Error: 'google' is undefined

Google Custom Search has "google is undefined" error. Where's problem?
Is there any problem between IE and Google Custom Search?
Why the Google Custom Search has an error with script debugging when i using IE7?


Error
Whenever you go to your pages which s contain of CSE with Internet explorer, you got a script error message.

Solution
It's really so simple. just add bellow script before other Google Custom Search scripts.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>