cheatsheet
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>
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);
...
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;
...
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...
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...
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
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 )
{
...
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...
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...
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>
...
Full cheatsheet Archive