With Great Power Comes Great Responsibility

We have failed society, and society has noticed.  Code now powers injustice around the world....

The New York Times recently published an interactive article titled "The Decade Tech Lost Its Way".  The headline brought to mind a topic I've reflected on often over the past few years.  We have had a decade of headlines exposing aid of government oppression in China by Google, utter disregard for privacy from Facebook, profit-margins above human well-being at Amazon, and many more.

The list is not limited to big tech either.  Praiseworthy investigative journalists brought us stories ranging from massive location data-sets collected by dozens of small, obscure companies, to human rights abuses using facial recognition & cell phone spyware by world powers - specifically China & India. (China has now moved people targeted by this technology into brainwashing camps.)  And, of course, abuses of power by my own government as well.

These stories both sadden & anger me,…

Using Enums to Replace #define's with Strongly-typed Variables

C++ Map With Multiple Keys

I recently had need for a C++ collection which could be accessed with multiple keys.  Specifically, I had an object that I wanted to look up either by name or id (in O(1) time).  One way to do this is to create two unordered_maps – one keyed by id and another by name, but that is error-prone.  I ended up finding a boost class which will do this. It took me a while get it working, so I thought I would share the result.

Selecting Software Tools

After a software tool is in place, it often extremely difficult to swap it out, so choosing a tool is something you should get right the first time.  However, I find that many companies/teams choose tools for all the wrong reasons.  For example:

"This one is free."
When comparing options, you will often find at least one open source offering which can be used free of charge.  To be clear, open source is awesome.  The best option for your needs might be open source, but "free" shouldn't be a criteria in most cases. 

The Joel Test asks, "Do you use the best tools money can buy?".  Joel used hardware examples, but the concept applies to software tooling as well.  Developer time is typically the biggest expense in a dev shop, so selecting software tools that make devs more efficient is paramount.  Typically, the time cost of using the software will easily eclipse the licensing cost.  Heck, not just developers - sales people, testers, etc. are typical…

Building the Perfect Ergo Workstation

Over the last few years, I've been evaluating the ergonomics of my workspace and making improvements.  That is, I've been trying to be proactive about the health problems that come from sitting at a desk full time (sitting is the new smoking, and all that.).

Along the way, I've done way too much research and plenty of tinkering, so I decided to share what I've learned.  I will try not to recycle what has already been written on the topic, but instead point to other resources for additional reading.  The purpose of this post is to share the products I have found and modifications I have made to those products in my quest to improve my workspace ergonomics.

First, a few tidbits...

The single best thing you can do for your health is get regular exercise.  No fancy ergo chair or standing desk will make up for lack of exercise.  Find a way to get your 30 minutes/day (minimum).
Also, take regular breaks during the workday.  I have personally started taking a 5 minute &q…

Multi-line text replacement with Powershell

A number of times recently I have had need of a script to replace a chunk of code or XML in a few dozen files. I've been enjoying Powershell lately; so I decided to use it to write the script. A couple challenges presented. First, the text replacement had to handle line breaks. Second, it had to handle (escape) special characters. It took me a couple hours and tips from a few different blog posts & Stack Overflow questions to get it right. So, I'll post the product here.

$oldCode = @" /// <summary> /// My Old XML Comment /// </summary> public static new string ThingID { get { return "@ $newCode = @" /// <summary> /// My New XML Comment /// </summary> public new const string ThingID = "@ Get-ChildItem .\ -Recurse –Include “*.YourFileExtension” | foreach-object { $text = Get-Content $_.Fullname -Raw $text = $text -repl…

Powershell script to remove Visual Source Safe References

I am migrating a codebase from Visual Source Safe (yes, in 2015, still VSS) to Git. One issue is the pesky way in which VSS embeds references to itself all over the place. Brian Carroll has a nice list of the things that need to be deleted here.

The project I'm working on has dozens of solution & project files spread through a large folder hierarchy, and I really didn't want to edit each file by hand. So, I wrote the following Powershell script. This was tested using Powershell 3.0 and should work for any project.  Only the $rootFolder value would need to be changed or converted into a script parameter.

$rootFolder = "C:\Projects\Workspace\KillVSSTest" Get-ChildItem $rootFolder -Recurse -File | Set-ItemProperty -Name IsReadOnly -value $false Get-ChildItem $rootFolder -include *.scc, *.vssscc, *.vspscc -Recurse | Remove-Item -Force Function RemoveTextInclusive($beginningText, $endingText, $includeFiles) { Get-ChildItem $rootFolder -include $includeFi…