Sunday, February 24, 2008

Facebook group for EDC ( Egyptian Developer Conference )

Description:
A group to send information and news about the upcoming event " Egyptian Developer Conference " previously known as MDC(Middle East developer conference)

Visit here

Performance and Editor fixes for Microsoft Visual Studio 2008 and Visual Web Developer Express 2008

Download Instructions :

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826

Issues that are fixed:

HTML Source view performance

  • Source editor freezes for a few seconds when typing in a page with a custom control that has more than two levels of sub-properties.
  • “View Code” right-click context menu command takes a long time to appear with web application projects.
  • Visual Studio has very slow behavior when opening large HTML documents.
  • Visual Studio has responsiveness issues when working with big HTML files with certain markup.
  • The Tab/Shift-Tab (Indent/Un-indent) operation is slow with large HTML selections.

Design view performance

  • Slow typing in design view with certain page markup configurations.

HTML editing

  • Quotes are not inserted after Class or CssClass attribute even when the option is enabled.
  • Visual Studio crashes when ServiceReference element points back to the current web page.

JavaScript editing

  • When opening a JavaScript file, colorization of the client script is sometimes delayed several seconds.
  • JavaScript Intellisense does not work if an empty string property is encountered before the current line of editing.

Web Site build performance

  • Build is very slow when Bin folder contains large number of assemblies and .refresh files with web-site projects.

for more information visit (the place which i found this news)

Some useful wmi links

Everything In WMI via C# :

http://www.codeproject.com/KB/cs/EverythingInWmi03.aspx

Get System Info using C# :

http://www.codeproject.com/KB/cs/nitinsysteminfo.aspx

Thursday, February 21, 2008

Regular Expressions Cheat Sheets

This two links to anther sites which includes Regular Expressions Cheat Sheets ....

http://www.ilovejackdaniels.com/cheat-sheets/regular-expressions-cheat-sheet/


http://regexlib.com/CheatSheet.aspx

This will be very useful to all of us ....

Thursday, February 14, 2008

now , i am 21 years

To night , I am 21 years old then new year has came , new year means new mission in this life .

The hardest thing is to calculate the best and worst things in last year , and make the next year better .

Happy birthday for me ....

Thanks for my best friends :
          1. my mother (The first who remembered my birthday)
          2. wahba (second)
          3. wardaya (third)
Good bye 20 and welcome 21 , i hope the new year to be better for me and for my family .

Wednesday, February 6, 2008

Extract Tables from HTML page and store it in data set using Regular Expressions

Some times we need to extract information from HTML pages ,for example extracting table from HTML page
here you will find how to do it using regular expression , this code is written using C# :

private static DataSet ConvertHTMLTablesToDataSet(string HTML)
{
DataTable dt;
DataSet ds = new DataSet();
dt = new DataTable();
string TableExpression = "<table[^>]*>(.*?)</table>";
string HeaderExpression = "<th[^>]*>(.*?)</th>";
string RowExpression = "<tr[^>]*>(.*?)</tr>";
string ColumnExpression = "<td[^>]*>(.*?)</td>";
bool HeadersExist = false;
int iCurrentColumn = 0;
int iCurrentRow = 0;

MatchCollection Tables = Regex.Matches(HTML,
TableExpression,
RegexOptions.Singleline |
RegexOptions.Multiline |
RegexOptions.IgnoreCase);


foreach (Match Table in Tables)
{
iCurrentRow = 0;
HeadersExist = false;
dt = new DataTable();

if (Table.Value.Contains("<th"))
{
HeadersExist = true;

MatchCollection Headers = Regex.Matches(Table.Value,
HeaderExpression,
RegexOptions.Singleline |
RegexOptions.Multiline |
RegexOptions.IgnoreCase);

foreach (Match Header in Headers)
{
dt.Columns.Add(Header.Groups[1].ToString());
}

}
else
{

int myvar2222 = Regex.Matches(
Regex.Matches(
Regex.Matches(
Table.Value,
TableExpression,
RegexOptions.Singleline
| RegexOptions.Multiline |
RegexOptions.IgnoreCase)[0].ToString(),
RowExpression, RegexOptions.Singleline |
RegexOptions.Multiline |
RegexOptions.IgnoreCase)[0].ToString(),
ColumnExpression,
RegexOptions.Singleline |
RegexOptions.Multiline |
RegexOptions.IgnoreCase).Count;

for (int iColumns = 1; iColumns <= myvar2222; iColumns++)
{
dt.Columns.Add("Column " + System.Convert.ToString(iColumns));
}

}

MatchCollection Rows = Regex.Matches(Table.Value,
RowExpression,
RegexOptions.Singleline |
RegexOptions.Multiline | RegexOptions.IgnoreCase);

foreach (Match Row in Rows)
{

if (!((iCurrentRow == 0) & HeadersExist))
{
DataRow dr = dt.NewRow();
iCurrentColumn = 0;

MatchCollection Columns = Regex.Matches(Row.Value,
ColumnExpression,
RegexOptions.Singleline |
RegexOptions.Multiline |
RegexOptions.IgnoreCase);

foreach (Match Column in Columns)
{
dr[iCurrentColumn] = Column.Groups[1].ToString();
iCurrentColumn++;
}

dt.Rows.Add(dr);
}
iCurrentRow++;
}
ds.Tables.Add(dt);

}

return ds;
}

This code i found it through google but i converted it it C# ...
kick it on DotNetKicks.com

Friday, February 1, 2008

EDC 2008

The EDC ( Egypt Developer Conference - previously known as the MDC ) will be on 13-15 April in intercontinental City Stars, Cairo

Validate Input Using Regular Expressions

Problem :
You need to validate that user input or data read from a file has the expected structure and content.
For example, you want to ensure that a user enters a valid IP address, telephone number, or e-mail
address.
Solution :
Use regular expressions to ensure that the input data follows the correct structure and contains only
valid characters for the expected type of information.
How It Works :
When a user inputs data to your application or your application reads data from a file, it’s good
practice to assume that the data is bad until you have verified its accuracy. One common validation
requirement is to ensure that data entries such as e-mail addresses, telephone numbers, and credit
card numbers follow the pattern and content constraints expected of such data. Obviously, you cannot
be sure the actual data entered is valid until you use it, and you cannot compare it against values that are known to be correct. However, ensuring the data has the correct structure and content is
a good first step to determining whether the input is accurate. Regular expressions provide an excellent
mechanism for evaluating strings for the presence of patterns, and you can use this to your
advantage when validating input data.
The first thing you must do is figure out the regular expression syntax that will correctly match
the structure and content of data you are trying to validate. This is by far the most difficult aspect of
using regular expressions. Many resources exist to help you with regular expressions, such as
The Regulator (http://regex.osherove.com/) and RegExDesigner.NET by Chris Sells http://www.sellsbrothers.com/tools/#regexd). The RegExLib.com web site (http://www.regxlib.com/) also provides hundreds of useful prebuilt expressions.
Regular expressions are constructed from two types of elements: literals and metacharacters.
Literals represent specific characters that appear in the pattern you want to match. Metacharacters
provide support for wildcard matching, ranges, grouping, repetition, conditionals, and other control
mechanisms. Table 2-2 describes some of the more commonly used regular expression metacharacter
elements. (Consult the .NET SDK documentation for a full description of regular expressions.)

Input Type Description Regular Expression
Numeric input The input consists of one or more decimal digits; for example,
5 or 5683874674.


^\d+$
Personal identification number (PIN)


The input consists of four decimal ^\d{4}$
Credit card number The input consists of data that matches the pattern of most major
credit card numbers; for example,
4921835221552042 or
4921-8352-2155-2042.


^\d{4}-?\d{4}-?\d{4}-?\d{4}$
Simple password

The input consists of six to eight characters; for example, ghtd6f
or b8c7hogh.

^\w{6,8}$
E-mail address

The input consists of an Internet expression
indicates that each address element
must consist of one or more word
characters or hyphens; for example,
somebody@company.com.

^[\w-]+@([\w-]+\.)+[\w-]+$
HTTP or HTTPS URL The input consists of an HTTP-based or HTTPS-based URL; for example, www.hotmail.com


^https?://([\w-]+\.)+[\w-]+(/[\w-./?%=]*)?$

The Code :
The ValidateInput method shown in the following example tests any input string to see if it
matches a specified regular expression.

using System;
using System.Text.RegularExpressions;

namespace mahmoud_alam
{
class new292
{
public static bool ValidateInput(string regex, string input)
{
// Create a new Regex based on the specified regular expression.
Regex r = new Regex(regex);
// Test if the specified input matches the regular expression.
return r.IsMatch(input);
}

public static void Main(string[] args)
{
// Test the input from the command line. The first argument is the
// regular expression, and the second is the input.
Console.WriteLine("Regular Expression: {0}", args[0]);
Console.WriteLine("Input: {0}", args[1]);
Console.WriteLine("Valid = {0}", ValidateInput(args[0], args[1]));
// Wait to continue.
Console.WriteLine("\nMain method complete. Press Enter");
Console.ReadLine();
}
}
}