I hate all the junk that gets added when serializing object to XML, so here is a quick way to do it cleanly.
Here is the dirty way:
public static string Serialize(this object obj)
{
string XmlString = String.Empty;
using (var memStream = new MemoryStream())
{
[...]
Selecting 5 random rows in SQL is easy
select top 5 * from users order by newid()
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: [...]
I am always looking for this one, so I am blogging it for future reference and for everyone to use.
^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$
There is more information on Ivan’s blog.
Related PostsFailed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.I had to [...]
I previously wrote about shortening URLs with TinyURL’s API but my new favorite URL shortener is http://bit.ly and it also has a great API that you can use from within your .net code. I just recently used in my twitter contest website – tweetastica.
The code is also very simple. I didn’t add all the extra [...]
I wanted to easily add theme support to yonkly, so that others can install it and modify its look and feel as they please. I also wanted it to be as easy as installing a theme in wordpress.
I created a themes folder under the content folder
Then I referenced my css file in the master [...]
Tuesday, February 23, 2010
Comments