Archives / 2010 / April
  • Government Mandates and Programming Languages

    A recent SEC proposal (which, at over 600 pages, I haven’t read in any detail) includes the following: “We are proposing to require the filing of a computer program (the “waterfall computer program,” as defined in the proposed rule) of the contractual cash flow provisions of the securities in the form of downloadable source code in Python, a commonly used computer programming language that is open source and interpretive. The computer program would be tagged in XML and required to be filed with the Commission as an exhibit. Under our proposal, the filed source code for the computer program, when downloaded and run (by loading it into an open “Python” session on the investor’s computer), … more

  • Detect Unicode Usage in SQL Column

    One optimization you can make to a SQL table that is overly large is to change from nvarchar (or nchar) to varchar (or char).  Doing so will cut the size used by the data in half, from 2 bytes per character (+ 2 bytes of overhead for varchar) to only 1 byte per character.  However, you will lose the ability to store Unicode characters, such as those used by many non-English alphabets.  If the tables are storing user-input, and your application is or might one day be used internationally, it’s likely that using Unicode for your characters is a good thing.  However, if instead the data is being generated by your application itself or your development team (such as lookup … more

  • Sql Table Refactoring Challenge

    I’ve been working a bit on cleaning up a large table to make it more efficient.  I pretty much know what I need to do at this point, but I figured I’d offer up a challenge for my readers, to see if they can catch everything I have as well as to see if I’ve missed anything.  So to that end, I give you my table: CREATE TABLE [dbo].[lq_ActivityLog]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [PlacementID] [int] NOT NULL, [CreativeID] [int] NOT NULL, [PublisherID] [int] NOT NULL, [CountryCode] [nvarchar](10) NOT NULL, [RequestedZoneID] [int] NOT NULL, [AboveFold] [int] NOT NULL, [Period] [datetime] NOT NULL, [Clicks] [int] NOT NULL, [Impressions] [int] NOT … more

  • Determine All SQL Server Table Sizes

    I’m doing some work to migrate and optimize a large-ish (40GB) SQL Server database at the moment.  Moving such a database between data centers over the Internet is not without its challenges.  In my case, virtually all of the size of the database is the result of one table, which has over 200M rows of data.  To determine the size of this table on disk, you can run the sp_TableSize stored procedure, like so: EXEC sp_spaceused lq_ActivityLog This results in the following: Of course this is only showing one table – if you have a lot of tables and need to know which ones are taking up the most space, it would be nice if you could run a query to list all of the … more

  • Sql Server Prevent Saving Changes That Require Table to be Re-created

    When working with SQL Server Management studio, if you use the Design view of a table and attempt to make a change that will require the table to be dropped and re-added, you may receive an error message like this one: Saving changes is not permitted.  The changes you have made require the following tables to be dropped and re-created.  You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created. In truth, it’s quite likely that you didn’t enable such an option, despite the error dialog’s accusations, as it is enabled by default when you install SQL Management Studio.  You can … more

  • PowerShell Control over Nikon D3000 Camera

    My wife got me a Nikon D3000 camera for Christmas last year, and I’m loving it but still trying to wrap my head around some of its features.  For instance, when you plug it into a computer via USB, it doesn’t show up as a drive like most cameras I’ve used to, but rather it shows up as Computer\D3000.  After a bit of research, I’ve learned that this is because it implements the MTP/PTP protocol, and thus doesn’t actually let Windows mount the camera’s storage as a drive letter.  Nikon describes the use of the MTP and PTP protocols in their cameras here. What I’m really trying to do is gain access to the camera’s file system via PowerShell.  I’ve been using a very handy … more

  • Clone a VirtualBox Machine

    I just installed VirtualBox, which I want to try out based on recommendations from peers for running a server from within my Windows 7 x64 OS.  I’ve never used VirtualBox, so I’m certainly no expert at it, but I did want to share my experience with it thus far.  Specifically, my intention is to create a couple of virtual machines.  One I intend to use as a build server, for which a virtual machine makes sense because I can easily move it around as needed if there are hardware issues (it’s worth noting my need for setting up a build server at the moment is a result of a disk failure on the old build server).  The other VM I want to set up will act as a proxy server for the … more

  • Stir Trek 2: Iron Man Edition

    Next month (7 May 2010) I’ll be presenting at the second annual Stir Trek event in Columbus, Ohio. Stir Trek (so named because last year its themes mixed MIX and the opening of the Star Trek movie) is a very cool local event.  It’s a lot of fun to present at and to attend, because of its unique venue: a movie theater.  And what’s more, the cost of admission includes a private showing of a new movie (this year: Iron Man 2).  The sessions cover a variety of topics (not just Microsoft), similar to CodeMash.  The event recently sold out, so I’m not telling you all of this so that you can go and sign up (though I believe you can get on the waitlist … more

  • Run MSTest Without Breaking on Exceptions in VS2010

    Quick tip I just figured out (no R# installed yet) when using VS2010’s test runner.  If you want to just use the keyboard, then you can use ctrl-R T to Run Tests in Current Context.  But if like me you tend to just leave ctrl held down when you hit the T, your test run will stop at any/every exception.  Why?  Because ctrl-R T is not the same as ctrl-R ctrl-T which is the shortcut for Debug Tests in Current Context. Note to self, don’t be lazy and pick up your finger from the ctrl key when running tests… more

  • VS2010 Launch Presentations

    Last week I was in Vegas to present at the DevConnections / VS2010 Launch event.  The show was well-attended and everybody I spoke to agreed it was educational and enjoyable.  My three talks were all on Wednesday, 14 April 2010, including one at 8am for which I was impressed to see a large turnout in attendance.     Pragmatic ASP.NET Tips, Tricks, and Tools My first session was on tips, tricks, and tools for ASP.NET developers.  This is a talk I’ve given in past years, but which I refine every time.  I usually like to have a full session to devote to tools, and a separate talk just for Tips and Tricks, but for this show I was only given the one 75-minute … more

  • Adding Attributes to Generated Classes

    ASP.NET MVC 2 adds support for data annotations, implemented via attributes on your model classes.  Depending on your design, you may be using an OR/M tool like Entity Framework or LINQ-to-SQL to generate your entity classes, and you may further be using these entities directly as your Model.  This is fairly common, and alleviates the need to do mapping between POCO domain objects and such entities (though there are certainly pros and cons to using such entities directly). As an example, the current version of the NerdDinner application (available on CodePlex at uses Entity Framework for its model.  Thus, there is a NerdDinner.edmx file in the … more

  • How To Move or Rename a File using MSBuild

    MSBuild is a very powerful tool, and it’s relatively easy to get started using it.  You can run a “hello world” example of MSBuild in no time, and it’s easy to build up the files incrementally as your needs (and knowledge of the tool) increase.  Here’s a handy list of the tasks that are built into MSBuild. Move File Task or Rename File Task One thing that is missing from the built-in list of tasks is a file rename (or move) task.  Fortunately, this is pretty easy to accomplish using a combination of the Copy and Delete tasks.  Here’s a real-world example that renames a file from _web.config to web.config as part of a deployment script written in msbuild: … more