Showing posts with label Tricks. Show all posts
Showing posts with label Tricks. Show all posts

Saturday, June 27, 2009

Fiddler : Web Debugging Software

 

Dear Web Developers,

”Really, you need to read this article”

I worked for many web based applications and faced debugging problems after deploying or publish the application to hosting server.

also you can use it for the development environment.

some issues: To trace and debug the following:

- Sessions
- Cookies
- Security
- Authentication
- Request Statistics (count-bytes sent-bytes received) 
- Encrypted Query strings
- Web Site Traffic
- Editing CSS file on fly
- Encoding and decoding with many algorithms
- …etc

fiddler Try to find quick start video at www.fiddler2.com

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

Fiddler is freeware and can debug traffic from virtually any application, including Internet Explorer, Mozilla Firefox, Opera, and thousands more.

For documentation and more information  http://www.fiddler2.com/fiddler2/

For download    http://www.fiddler2.com/fiddler2/version.asp

For Developers   http://www.fiddler2.com/Fiddler/dev/

I hope it is helpful.!

Tuesday, August 26, 2008

Shallow Copy vs Deep Copy in .NET

hi Developers ,

in that post, i am describing the difference between shallow and deep copy by the use of C# language.

shallow and deep copy are used for copying data between objects.

Shallow Copy:

creating a new object, and then copying the nonstatic fields of the current object to the new object.

If a field is a value type --> a bit-by-bit copy of the field is performed

If a field is a reference type --> the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.

in C# and VB.NET, shallow copy is done by the object method MemberwiseClone()

Example:

the following are clsShallow class to be cloned which include value types (like Age) and ref types (like EmpSalary is a class)

public class clsShallow
{
public static string CompanyName = "My Company";
public int Age;
public string EmployeeName;
public clsRefSalary EmpSalary;

public clsShallow CreateShallowCopy(clsShallow inputcls)
{
return (clsShallow)inputcls.MemberwiseClone();
}
}
public class clsRefSalary
{
public clsRefSalary(int _salary)
{
Salary = _salary;
}
public int Salary;
}

now, let us debug and trace the outputs to do the shallow copy by the use of CreateShallowCopy() method

first, use the following code to call the CreateShallowCopy method from other classes

// Creates an instance of clsShallow and assign values to its fields.
clsShallow objshallow = new clsShallow();
objshallow.Age = 25;
objshallow.EmployeeName = "Ahmed Eid";

// add the ref value to the objshallow
clsRefSalary clsref = new clsRefSalary(1000);
objshallow.EmpSalary = clsref;

// Performs a shallow copy of m1 and assign it to m2.
clsShallow m2 = objshallow.CreateShallowCopy(objshallow);

// then modify the clsref salary value to be 2000
clsref.Salary = 2000;

// so the m1 object salary value become 2000
int EmpSalary = objshallow.EmpSalary.Salary;

After assigning the values (value and ref types ones) to the object objShallow and before doing the shallow copy
the values are : (for the current object value)
Age : 25 (value type)
EmpSalry: has salary value of 1000 (ref type)

shal1

then do the shallow copy and modify the value of clsref.salary ,reference field type, then check the values of m2 , new created object. (ref and value fields) again

shal2

the values are : (for the new created object)
Age : 25 (value type) a new copy of the objShallow object
EmpSalry: has salary value of 2000 (ref type) a refernce to objShallow.EmpSalry object, which is also referenced to the clsref object.

Note: values of m2.EmpSalry and clsref are the same after modifying the clsref values. (reference type concept)

Deep Copy:
creating a new object, and then copying the nonstatic fields of the current object to the new object.

If a field is a value type --> a bit-by-bit copy of the field is performed
If a field is a reference type --> a new copy of the referred object is performed.

Note: the classes to be cloned must be flagged as [Serializable]

Example:

the following are clsDeep class to be cloned which include value types (like Age) and ref types (like EmpSalary is a class)

[Serializable]
// serialize the classes in case of deep copy
public class clsDeep
{
public static string CompanyName = "My Company";
public int Age;
public string EmployeeName;
public clsRefSalary EmpSalary;
public clsDeep CreateDeepCopy(clsDeep inputcls)
{
MemoryStream m = new MemoryStream();
BinaryFormatter b = new BinaryFormatter();
b.Serialize(m, inputcls);
m.Position = 0;
return (clsDeep)b.Deserialize(m);
}
}

[Serializable]
public class clsRefSalary
{
public clsRefSalary(int _salary)
{
Salary = _salary;
}
public int Salary;
}

now, let us debug and trace the outputs to do the deep copy by the use of CreateDeepCopy() method

first, use the following code to call the CreateDeepCopy method from other classes

// Creates an instance of clsDeep and assign values to its fields.
clsDeep objdeep = new clsDeep();
objdeep.Age = 25;
objdeep.EmployeeName = "Ahmed Eid";

// add the ref value
clsRefSalary clsref = new clsRefSalary(1000);
objdeep.EmpSalary = clsref;

// Performs a shallow copy of m1 and assign it to m2.
clsDeep m2 = objdeep.CreateDeepCopy(objdeep);

// then modify the clsref salary value to be 2000
clsref.Salary = 2000;

// so the m1 object salary value become 2000
int EmpSalary = objdeep.EmpSalary.Salary;

After assigning the values (value and ref types ones) to the object objDeep and before doing the deep copy

the values are : (for the current object value)
Age : 25 (value type)
EmpSalry: has salary value of 1000 (ref type)

deep1

then do the deep copy and modify the value of clsref.salary ,reference field type, then check the values of m2 , new created object. (ref and value fields) again

deep2

the values are : (for the new created object)
Age : 25 (value type) a new copy of the objDeep object
EmpSalry: has salary value of 1000, a new copy of the objDeep object

Note: values of m2.EmpSalry and objDeep.EmpSalary are not the same as deep copy creates a new object of the reference type (objDeep.EmpSalary) in m2.EmpSalry. but clsref and objDeep.EmpSalary are the same (Refernce type concept)

With the help of Google I found a very smart method for performing deep copy. Its performance is good than the one i used on that post.


/// <summary>
/// Using generics will solve some performance issues
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="item"></param>
/// <returns></returns>
public static T DeepCopy<T>(T item)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, item);
stream.Seek(0, SeekOrigin.Begin);
T result = (T)formatter.Deserialize(stream);
stream.Close();
return result;
}

i hope that post help you to deeply understand the difference b/w shallw and deep copy in .NET

Ahmed Eid

Monday, August 11, 2008

HTML Application (HTA)

if you want to open HTML page or website as an C++ application,Windows Application or any .Exe application, just rename the HTML file from .html to .hta . HTA can be used for prototyping, making wizards, or building full-scale applications.

By the use of HTA, you will focus on the html page or website content and thereby you won't find the browser toolbars, address bar, menus, buttons ...etc.

HTA for internal applications usage:

if you have internal tools, Web-Based applications, like attendance module for all employees, development team portals, collaboration portals, time tracker system ...etc. you need the employees or colleagues to dont care about explorer bars and focus on the core of your application, it will be useful to use the HTA

Example:




How can you do that:



just, you can rename the .html files to be .hta

OR,

you can use the following code:





references:
http://msdn.microsoft.com/en-us/library/ms536496.aspx
http://en.wikipedia.org/wiki/HTML_Application

Friday, February 8, 2008

Windows Vista with Arabic Interface


Windows Vista with Arabic Interface


We can change Vista interface from English to Arabic Interface by the use of Vistalizator Tool.
This tool is so easy in use and language installation.

The applicable Vista editions for the above tool are:

- Basic
- Home
- Home Premium
- Business Starter

How can we do the language installation? (Vista Bit 32)
1- Install one of the above Vista Version
2- Download the Vistalizator Tool download
3- Download the target language

a. Arabic
b. English
c. Spanish
d. Germany
e. French
f. Others

4- Follow up the following steps:
a- Open the Vistalizator Tool



b- Add Language




c- Choose the downloaded language




d- After open, click OK








e- Finally, Restart and enjoy the Arabic Interface




Note: The Visat Arabic Interface is about 70-80% correct.

You can restore the English language by the use of the tool:





Changing Vista English Ultimate to Arabic Interface:

1- Open Control Panel
2- Open Clock, Language, and Region Then Select Change Keyboards
3- Click Install/uninstall languages
4- Browse for the language file with the extension of .cab then click OK
5- Choose the target language
6- Read the conditions and click Next
7- Finally, Click Install

Also, you can do the same function with the use of Windows Update.





ANTIQR26
By: Favoshots
Views: 0
ANTIQR27
By: Favoshots
Views: 0
ANTIQR29
By: Favoshots
Views: 0
ANTIQR31
By: Favoshots
Views: 0
ANTIQR32
By: Favoshots
Views: 0
ANTIQR33
By: Favoshots
Views: 0
ANTIQR34
By: Favoshots
Views: 0
ANTIQR37
By: Favoshots
Views: 1
ANTIQR38
By: Favoshots
Views: 1
ANTIQR40
By: Favoshots
Views: 1
ANTIQR41
By: Favoshots
Views: 1
ANTIQRA
By: Favoshots
Views: 1
ANTIQRA2
By: Favoshots
Views: 1
ANTIQRA3
By: Favoshots
Views: 1
ANTIQRA4
By: Favoshots
Views: 1
ANTIQRA5
By: Favoshots
Views: 1