• Interesting, Programming

    Posted on August 12th, 2010

    Written by Emad Ibrahim

    Tags

    , , ,

    Blackjack Simulator

    What’s a better way to get ready for a gambling trip other than write a blackjack simulator?  I am no blackjack expert but one of the strategies I heard off is to double your bet every time you lose.  So, if I start with a $100 bankroll and play $10 hands then I lost the [...]

  • Programming

    Posted on July 30th, 2010

    Written by Emad Ibrahim

    Tags

    , , ,

    Display a Dictionary/KeyValuePair as Grid in WPF

    Every time I work with WPF, I constantly think “I hate this shit” and “why is everything so damn hard”, but once I figure it out, I realize how powerful it really is and what I can really do with it.  I remember starting out with WPF and trying to figure out how to bind [...]

  • Programming

    Posted on February 23rd, 2010

    Written by Emad Ibrahim

    Tags

    , ,

    Serialize Object To Clean XML

    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()) { var serializer = new XmlSerializer(obj.GetType(), string.Empty); using (var xmlText [...]

  • Programming

    Posted on December 16th, 2009

    Written by Emad Ibrahim

    Tags

    , , ,

    Select Random Records Using Nhibernate

    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 [...]

  • Programming

    Posted on July 5th, 2009

    Written by Emad Ibrahim

    Tags

    ,

    Regular Express For Parsing URLs

    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.

  • Older Posts Yeah! There are more posts, check them out.

    Newer Posts Yeah! There are more posts, check them out.