cheatsheet

XCOPY Reminder

I can never remember the exact args for XCOPY and I use this in VS POST-BUILD events more than you would think.  Here’s my reminder so I never have to Google for this or read the XCOPY usage again. <PostBuildEvent>XCOPY "$(ProjectDir)\Foo\Bar.config" "$(ProjectDir)..\..\Bin\$(ConfigurationName)" /Y</PostBuildEvent>

posted @ Wednesday, January 04, 2012 7:59 AM | Feedback (0)

System.IO.Path Cheatsheet

I spent a great deal of time last week wrestling with the .NET System.IO.Path API.  I frequently struggle to remember what some of these methods do.  Here’s a cryptic cheatsheet for future reference. public void Test() { string[] strings = new string[] { @"\", @".", @"C:\Temp", @"C:\Temp\foo\bar.txt", @"C:\Temp\foo.txt", @"\foo\bar.txt", @"\foo\bar\baz.txt", @"\foo\bar\", @"foo\bar\", @"\\\\\\" }; DoGetDirectory(strings); ...

posted @ Wednesday, December 08, 2010 9:27 PM | Feedback (0)

Reflector

Not to be confused with .NET Reflector, this is another class I use all the time for doing pseudo-strongly-typed reflection of property names.  Putting it up here for easy reference later: public static class Reflector { public static string GetPropertyName<TProperty>(Expression<Func<TProperty>> property) { LambdaExpression lambda = property; MemberExpression memberExpression; ...

posted @ Monday, October 18, 2010 10:34 AM | Feedback (0)

Check

Years and years ago I wrote a little utility class called Check.cs.  I don’t remember the inspiration exactly, but I think I’ve used it verbatim in nearly every piece of software I’ve developed since.  It’s one of those things that’s best suited for copy/paste reuse vs. a lib reference. Maybe someone else out there might find it useful, but the very least I want to be able to find this easily for quick copy/pasting in the future… public class Check { public static T...

posted @ Thursday, October 14, 2010 12:57 PM | Feedback (0)

Serialization Cheatsheet

This post is intended to be a quick and dirty cheatsheet outlining how to turn an object into a string and back using the four serializers I use most:  DataContractSerializer, XmlSerializer, BinaryFormatter, and DataContractJsonSerializer.  There’s absolutely nothing special about this information as it’s all freely available on the web in a million different forms – I simply wanted this all in one place as I can easily find it the next time I need it. Ugly WCF Xml (DataContractSerializer): This is the default serializer used by WCF.  If you have a WCF service and you haven’t went out of...

posted @ Tuesday, October 05, 2010 10:57 AM | Feedback (0)

Backing up with T-SQL

I never remember this syntax, so here it is for future reference: To back with a SQL Server database with T-SQL, this is the command: BACKUP DATABASE [YourDb] TO DISK = N'C:\YourDb.bak' WITH STATS = 1   Be careful with using WITH STATS = 1 on very large databases

posted @ Friday, July 09, 2010 9:03 AM | Feedback (0)

Using XPath to select nodes with a missing attribute

The only thing worse than my XPath skills are my RegEx skills.  I don’t use XPath all that much these days, but today I needed to.  It took me a while to find a code sample that does this.  After a playing a bit with SnippetCompiler, I found the solution:   StringBuilder builder = new StringBuilder(); builder.AppendLine("<foo>"); builder.AppendLine("<bar baz=\"a\">1</bar>"); builder.AppendLine("<bar>2</bar>"); builder.AppendLine("<bar baz=\"b\">3</bar>"); builder.AppendLine("<bar>4</bar>"); builder.AppendLine("<bar baz=\"c\">5</bar>"); builder.AppendLine("</foo>"); XmlDocument doc = new XmlDocument(); doc.LoadXml(builder.ToString()); XmlNodeList nodes = doc.SelectNodes("//foo/bar[not(@baz)]"); if ( nodes == null ) { WL("nodes was null"); } else { foreach ( XmlNode node in nodes ) { ...

posted @ Thursday, January 14, 2010 8:05 PM | Feedback (1)

Windows 7 Paving – New Base Image Software List

It’s here… good bye Vista – won’t be missing you.  Hello beauty I just paved my machine with the new RTM of Windows 7 Ultimate.  Below is my base image – now it’s time to back everything up to my home server. Windows Live Mesh I had to cut Mesh out of my life.... it was hogging too many system resources - especially disk reads.  I...

posted @ Saturday, August 08, 2009 10:23 AM | Feedback (0)

Important SQL Server Database Properties and JumpstartTV

JumpstartTV is another one of these sites that are popping up that offer short and sweet tech screen casting.  They offer 5-10 minutes videos covering the basics of a narrow technical topic.  JumpstartTV focuses primarily on SQL Server topics, but they do have other material from time to time.  I like this because I’m not really a database guy.  I’ve designed a built a lot of applications, and therefore I fully appreciate the role the RDBMS plays in an system architecture, but my mind thinks in objects – not relational schema. Today’s topic was SQL Server Properties to Avoid...

posted @ Friday, January 23, 2009 10:22 AM | Feedback (0)

ASP.NET States DropDownList

I've had to build one of these a few times over the years. If you want a very quick and dirty dropdown of US states in an ASP.NET app, here is the code 1: <asp:DropDownList runat="server" ID="StatesList"> 2: <asp:ListItem Value="AL" Text="Alabama"></asp:ListItem> 3: <asp:ListItem Value="AK" Text="Alaska"></asp:ListItem> 4: <asp:ListItem Value="AZ" Text="Arizona"></asp:ListItem> 5: <asp:ListItem Value="AR" Text="Arkansas"></asp:ListItem> 6: <asp:ListItem Value="CA" Text="California"></asp:ListItem> 7: <asp:ListItem Value="CO" Text="Colorado"></asp:ListItem> ...

posted @ Tuesday, September 02, 2008 12:00 AM | Feedback (0)

Full cheatsheet Archive