Blogs on .NET and LAMP Technologies
There's often more than one correct thing.
There's often more than one right thing.
There's often more than one obvious thing.
--Larry Wall
Thursday, December 29, 2005
Performance boost tips for Window XP
http://kadaitcha.cx/performance.html
Wednesday, December 28, 2005
Regular Expression: Multiple replacement in one go
For Example:
// Replace Textboxes
string regex = "\\";
System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace
| System.Text.RegularExpressions.RegexOptions.Multiline)
| System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);
pageContent = reg.Replace(pageContent,new MatchEvaluator(RemoveFormElement));
protected string RemoveFormElement(Match m)
{
if(m.Value.IndexOf("RemoveFeedback") != -1)
{
string feedback = Regex.Replace(txtFeedback.Text,"\\n","
");
return ""+feedback+"";
}
else if (m.Value.IndexOf("RemoveContextHeader") != -1)
{
return ""+ contextHeader +"";
}
else
{
return m.Value;
}
}
Monday, December 05, 2005
Useful Window Tricks
http://www.practicalpc.co.uk/computing/windows/top10tricks1.htm
Binding of DictionaryBase object with Datagrid instead of Collection Object
<asp:Label id="Label1" runat="server" Width="64px">
<%#((DictionaryEntry)Container.DataItem).Key %>
<br>
<%# ((TestApplication.ContactsInfo)((DictionaryEntry)Container.DataItem).Value).age%>
Prometric Test Centers in India
http://www.register.prometric.com/Centers.asp
Following are some of the centers in New Delhi:
SQL
Phone: 24601539 Site Code: IIU1 3RD FLOOR,
ANDHRA ASSOCIATION BULDING
24 & 25,
NOIDA, Uttar Pradesh
Phone: 5320373,2440594 Site Code: IIF94 D-3
SECTOR -10
IACL (
Phone: 55484641 Site Code: IIG66 IACL
H-28,2ND-FLOOR
SOUTH EXTENSION PART-I
Phone: 25572355 Site Code: IIG29 C-58,9TH FLOOR, SHAHPURI TIRATH SINGH TOWER
BEHIND JANAK CINEMA, JANAKPURI
VIVEKANAND INSTITUTE OF COMPUTER EDUCATION(VICE)-
Phone: 55278088 Site Code: IIM83 VIVEKANAND INST. OF COMPUTER EDUCATION-MOBILE
2647
NEAR NORTH CAMPUS
PATEL CHEST
Wednesday, November 30, 2005
PHP script Example
";
mysql_close($dblink);
/* Going a step forward now we will connect to ldap server */
$ldapserver = "xxxx";
$user = "cn=Ashish Srivastava,cn=Users,dc=mydomamin,dc=com";
$passwd = "ashish";
$base = "cn=Users,dc=mydomamin,dc=com";
// Connect to ldap server
$dsCon = ldap_connect($ldapserver);
// Make sure we connected
if (!($dsCon))
{
print("Sorry, cannot contact LDAP server");
exit(2);
}
// Set Active Directory Specific Options
ldap_set_option($dsCon,LDAP_OPT_REFERRALS, 0);
// Bind LDAP
$bindresult = ldap_bind($dsCon,$user,$passwd);
if(!$bindresult){
$errno = ldap_errno($dsCon);
$error = ldap_error($dsCon);
print "LDAP Error ($errno): $error";
exit(3);
}
// Now Perform Search
$attributes = array("cn"); // attributes which you want
$search_filter = "(&(objectclass=user)(objectcategory=user)(sAMAccountName=ashish.srivastava))";
$search_result=ldap_search($dsCon, $base, $search_filter, $attributes);
if(!$search_result){
$errno = ldap_errno($dsCon);
$error = ldap_error($dsCon);
print "LDAP Error ($errno): $error";
exit(4);
}
// Getting Entries
$entry = ldap_get_entries($dsCon,$search_result);
if(!$entry){
$errno = ldap_errno($dsCon);
$error = ldap_error($dsCon);
print "LDAP Error ($errno): $error";
exit(4);
}
$cn = $entry[0]["cn"][0];
//var_dump($entry);
print "Common Name: $cn
";
ldap_close($dsCon);
?>
Tuesday, November 29, 2005
Codus - Code generation tool for .NET
C# Interface Explained
http://dotnet.org.za/brianwilson/archive/2005/04/19/18306.aspx
Custom HTTP Modules
HTTP Modules provides an opportunity to examine each incoming and outgoing request before request processing.
A typical use of HTTP module is URL rewriting on the basis of content of URL string. For example if i want to convert URL like "mywebproject/ashish/default.aspx" into "mywebproject/default.aspx?user=ashish" or vice-versa.
Creating custom HTTP Modules:
- Make a class for implementing your custom module and implement IHttpModule Interface.
- Add event handlers for BeginRequest and EndRequest events
- Register your custom HTTP Module using web.config
public class UrlMapperModule : IHttpModuleRegistering Custom HTTP Module in web.config:
{
private EventHandler onBeginRequest;
public UrlMapperModule()
{
onBeginRequest = new EventHandler(this.HandleBeginRequest);
}
void IHttpModule.Dispose()
{
}
void IHttpModule.Init(HttpApplication context)
{
context.BeginRequest += onBeginRequest;
}
private void HandleBeginRequest( object sender, EventArgs evargs )
{
// Now check every request
string requestUrl = app.Context.Request.Url.PathAndQuery;
}
}