Skip to content

“Secret Santa” Code Kata in Powershell

25 January 2012

The team at work is doing a Code Kata, the Secret Santa kata from Ruby Quiz. In it, you are given a list of names and emails and need to pair givers with receivers, with the only constraint being that a giver and receiver can’t have the same surname.

I wrote my solution in PowerShell. I wanted to use native PowerShell functionality, so I didn’t import any .NET libraries. I know this post is brief, but I wanted to get my solution posted with a little commentary while it was still fresh in my mind.

When run like this:

PS> .santa.ps1 .names.txt

It gives output like:

Giver                                                Receiver
-----                                               ---------
John Smith <>         Jane Doe <>

Here’s the code:


 function ConvertTo-Array($hashtable) 
     $result = @()
     $hashtable.GetEnumerator() | % {
         $object = New-Object PSObject   
         Add-Member -inputObject $object -memberType NoteProperty -name Giver -value $_.Name 
         Add-Member -inputObject $object -memberType NoteProperty -name Receiver -value $_.Value 
         $result += $object

 $none = "NONE"
 $names = @{}
 gc $file | % { $names.Add($_, $none) }
 $namesToMatch = $names.Keys.Count
 if ($namesToMatch -lt 2) {  throw "Need at least two names to match" }

 while (($names.Keys | ? { $names.$_ -eq $none }).Length -gt 0) 
     $from = $names.Keys | ? { $names.$_ -eq $none } | Get-Random
     $to = $names.Keys | ? { $_ -ne $from -and $names.Values -notcontains $_ } | Get-Random
     #"DEBUG: $from, $to"
     if ($from -ne $null -and $to -ne $null -and $from.split()[1] -ne $to.split()[1]) 
         $names.$from = $to
         $undoMatch = $names.Keys | ? { $names.Values -ne $none `
             -and $from.split()[1] -ne $_.split()[1]} | Get-Random
         #"DEBUG: unset $undoMatch"
         if ($undoMatch -ne $null) 
             $names.$undoMatch = $none
     $percentComplete = 100 * ($names.Values | ? { $names.$_ -ne $none }).Length / $namesToMatch
     Write-Progress -activity "Match in Progress" -status "% Complete:" -percentcomplete $percentComplete
 $results = ConvertTo-Array $names
 $results | ft  

(I apologize in advance for the formatting. I will look into another solution like Pastebin if I do this more often. Please comment if you have recommendations.)

It reads the contents of the file and writes each line to a hashtable, where all the receivers are $none (a special value I created which I used like $null).

As long as there are unmatched people, I go through an algorithm to select a random gift giver who doesn’t have a receiver ($from) and a receiver who doesn’t have a giver ($to). The split(” “)[1] yields a person’s surname.

I used a variant on the “Hill Climbing” algorithm mentioned on the site. If I run into a situation where there are no more matches, I take a random person who could have been a match and throw them back into the pool of candidates. In this way, the algorithm never gets stuck.

At the end, I call my ConvertTo-Array function to beautify the output. Without it, the hashtable columns are labeled “Name” and “Value”, and that didn’t satisfy me. (I couldn’t get Format-Table to help.)

I added a progress bar to see how often this part of the code is invoked, and it gets called once or twice per run on average. However, the script itself has decent performance. It takes a second or so to match 40 names.

Please let me know what you think or ask questions. I’m happy to go into more detail.

Getting off the Ground

23 January 2012

“You don’t need more time, you just need to decide” – Seth Godin

At work, there are a lot of things that I’ve identified for improvement.

Where I work is largely a Java shop, but there are a couple of large applications that are .NET and a growing group of .NET developers. And there are a lot of amazing opportunities here.

The company has a good track record of agile delivery using Scrum. However, I see areas for improvement also. The job of scrum master has become institutionalized as just a meeting facilitator. The responsibility of the scrum master as team coach has been lost in translation from training done there a few years ago.

Our current scrum master wanted the team to attend introductory scrum training. As a certified scrum master, I was anxious to hear what the agile coach on staff would say, and I was gratified to agree with his curriculum. It’s a matter of practice in our group.

Fortunately, I am well-suited to help move the team toward a steady cadence of delivery. We need to get our product owner away from firefighting mode and to get what he and our customers need within the confines a fixed sprint backlog. Having a strong scrum master will help.

And we need to get beyond our large estimates for small projects due to fear of the unknown with this application — turnover has left most of the delivery team new to the code base.

There’s a desire for a .NET community of practice. I’ve started the ball rolling with a book club. The first book we’ll read together is Working Effectively with Legacy Code by Michael Feathers, which is all about getting pre-written systems under unit test. We’re also starting our first code kata this week, an old Ruby Quiz about Secret Santas.

Both the book club and katas are exercises to start talking about software design in a simpler context. These .NET applications grew organically and were written by developers who were more comfortable with SQL than .NET. The application has shortcomings that you might expect: lots of logic in stored procedures, poor separation of concerns between SQL and .NET, and a presentation layer (ASP.NET web forms) that’s highly coupled to the database.

And the application has a lot of room to grow. It is ripe for becoming a data warehouse solution. I have some mixed experience setting up data warehousing from a previous position, but this time, the team is blessed with a talented database developer onboard to guide us through the tough parts. I can’t wait!

The concern I have is being spread too thin. As you can see, there are a number of vectors to pursue. I need to choose one, maybe two of these and drive them to completion before taking on others. I haven’t talked about the nine months of architecture changes that are needed to get the application able to scale to handle the desired demand or some of the expanded features they want for this application this year.

If I have learned anything over the past couple of years, it is that I cannot be all things to all people. I need to pace myself and be ready for some false starts. I also find a way to handing off these projects when (if?) they get off the ground. Here’s where having a good manager will help me, and I am blessed to have one.

I feel energized, and excited about the possibilities!

Parsing large files using PowerShell

17 January 2012

At work, I had the need to parse through a large pipe-delimited file to count the number of records whose 5th column meets and doesn’t meet my criteria.

PS C:temp> gc .items.txt -readcount 1000 | `
  ? { $_ -notlike "HEAD" } | `
  % { foreach ($s in $_) { $s.split("|")[4] } } | `
  group -property {$_ -ge 256} -noelement | `
  ft -autosize

This command does what I want, returning output like this:

  Count Name
  ----- ----
1129339 True
2013703 False

Here’s some explanation in English, for those of you who don’t know PowerShell.

The first command is gc (Get-Content), which reads the file in 1000 (readcount) lines at a time.

The second command is ? (Where-Object), which filters out the HEAD row.

The next command % is an alias for Foreach-Object, where object in this case is a 1000-line chunk. The inner loop is another foreach loop, which is slightly different from Foreach-Object in ways that are unimportant to the matter at hand. Point is, you can’t nest % blocks. The block of the foreach loop splits each line by pipe delimiter and returns just the 5th column (first column is numbered 0).

The next command in the chain is group, an alias for Group-Object, in this case we’re grouping by a calculated property, whether the output of the previous command is greater than or equal to 256. By saying “-noelement”, I’m saying I don’t need an enumerated list of the values, which in this case are unimportant.

Finally, we get to ft (Format-Table). It is necessary because the Count column may be over 99999, in which case the value is truncated. The option “-autosize” causes PowerShell to make it fit instead.

However, for a 500 MB test file, this command takes about 5.5 minutes to run as measured by Measure-Command. A typical file is over 2 GB, where waiting 20+ minutes is undesirably long.

I posted a query to StackOverflow for some ideas.

While I waited, I discovered that 2500 was the optimum value for -ReadCount, getting the command execution time down to about 3.5 minutes.

Within minutes, I got a helpful hint from Gisli to look into using the .NET StreamReader. Here’s what that script looks like:

=== begin Show-SourceCounts.ps1 ===
param($file = $(Read-Host -prompt "File"))
$fullName = (Get-Item "$file").FullName
$sr = New-Object System.IO.StreamReader("$fullName")
$trueCount = 0; 
$falseCount = 0; 
while (($line = $sr.ReadLine()) -ne $null) {
      if ($line -like 'HEAD|') { continue }
      if ($line.split("|")[4] -ge 256) { 
      else {
write "True count:   $trueCount"
write "False count: $falseCount"
=== end file ===

This script yields the same results as the first command, but in about a minute. Quite an improvement!

Savage Worlds Doctor Who setting

4 January 2012

I haven’t looked at this in months, but I’ve decided just to post it as is rather than delete it. Hope it’s in decent condition…

Savage Worlds Doctor Who setting

Adaptation by Chuck Durfee, 17-25 Jan 2011. Doctor Who is © BBC 2011, all rights reserved.

I wrote this adaptation as an exercise in creating a setting. I noticed there didn’t seem to be one on the web already, so I am providing this for your enjoyment. None of these rules have been play-tested. Please tell me about your experience if you choose to try them out! — Chuck



In addition to all the attributes defined in the core rules, each character in a Doctor Who setting has a home timeline. Rules about timelines can be found under New Rules.



Humans are as per the normal rules.

Time Lord

Time Lords hail from the planet Gallifrey.

Time Lord characters frequently have high Smarts and choose the Danger Sense or Arcane Background (Psychic) Edges.

Many Time Lord characters begin play as Seasoned or Veteran characters, although a Novice Time Lord is certainly a viable choice. During character creation, Game Masters should bestow Time Lord characters with one Advance per previous incarnation.

Edge: Improved Physiology (Minor)

Twin hearts mean Time Lords do not need to sleep, and thus the Sleep rules do not apply to them. They can become Fatigued or fall unconscious, however.

Also, they can be Incapacitated but not killed by respiratory attacks like poison gas or choking. The Game Master may rule that this Edge provides additional advantages as the plot dictates.

Edge: Arcane Background: Rassilon Imprimatur (Major)

Characters with this background have an innate understanding of temporal theory. They can pilot TARDISes and other temporal craft. They can sense the ebb and flow of time, allowing them to make Notice rolls to detect impending danger to the universe, changes to history and the like. (For more everyday use, take the Danger Sense Edge.)

This Edge also includes the benefits of the Time Traveller Edge.

Racial Power: Regeneration (Major, 3 points)

Work with your Game Master when applying this Power. For example, some Game Masters may allow the player to choose the Time Lord’s new appearance, while others choose it themselves. Some Game Masters have another player take control of the Time Lord character after regeneration to reflect the character’s change in personality. As always, the Game Master must approve any resulting changes, especially in Edges and Hinderances.

When a Time Lord dies and the body is reasonably intact (say 75%+), this Power is triggered. After a full action, the Time Lord returns to life Shaken but with no Wounds or physical ailments (poison, etc).

However, the Time Lord’s body and mind have changed drastically. All the Time Lord’s attributes reset to d4. As during character creation, the player then gets 5 attribute points to spend, the only restriction being that at least one attribute must change value. A Time Lord is never quite the same after regenerating.

To reflect the changes in the Time Lord’s mind, the player must remove 2 or more skill points and spend them on different skills. In addition, the player may choose to remove all points in one skill — usually a minor skill such as recorder or spoon playing unique to the previous incarnation — and apply those points to a new skill.

Finally, the player may change one Edge and may change one Hindrance, if desired, so long as it results in a legal combination. If this is the Time Lord’s 12th regeneration, however, the player must choose to remove this Regeneration power itself.

The Game Master may also choose to impose roll penalties or a temporary Hinderance to reflect post-regenerative trauma, which normally last the length of the new incarnation’s introductory adventure. Some suggested ones are All Thumbs, minor Delusional, a minor Habit, Mean, Overconfident, minor Phobia, Quirk, Stubborn, minor Vengeful, and Yellow.

Hinderance: Enemy: The Daleks (Major)

The Daleks and Time Lords are old foes, evenly matched, and vie for supremacy at every encounter.

Hinderance: Vow: Laws of Time (Minor)

Time Lord characters will not break the Laws of Time nor allow others to break them. There is simply too much risk that events will spiral out of control into a universe-ending cataclysm or unresolvable paradox! That having been said, it’s a minor Vow because Time Lords will often bend the rules to suit their own purposes.

Game Masters are encourage to build adventures around restoring the natural order of things should characters or villains violate the Laws of Time.

New Edges

Time Traveller (Minor)

Requirements: Seasonsed

Time Travellers get +2 to Vigor rolls to resist disease, and never get sick unless the plot dictates.

They are also experienced at adapting to new eras. A character with Time Traveller has an instinctive understanding of etiquette and does not make social faux pas (see Fitting In in the New Rules section). They are also not penalized for using unfamiliar advanced or primitive technology.

Strong Personal Timeline (Minor)

Requirements: Veteran, Time Traveller

Experienced time travelers become a fixture in the cosmos. They are extraordinarily resistant to changes in the timeline.

If there is a change in the timeline, its impact will be minimized for the character. For example, a companion with this Edge who is a scientist will be a scientist in the new timeline, if at all possible. They will remember all events that happen to them, even if history has later changed and they should not remember what happened.

In addition, a person with Universal Constant can resist being erased from reality by a time paradox. Such people can make Spirit roll once an hour, at a TN of 4 + (the number of hours since the paradox began). They can make similar rolls to remain unaffected by a time loop.

New Hinderances

Precarious Personal Timeline

Even when most people would remember a change in history, this person does not. A character with this Hindrance must make a Smarts roll versus TN 4 just to sense that history has changed. For this person, everything has always been this way.

Worse, circumstances surrounding a person’s past with this Hindrance are improbable. If there’s a change this person would be erased when history is altered, it’ll happen to this person.

This Hinderance cannot be taken with the Time Traveler Edge.

Time Vertigo

Characters with Time Vertigo cannot adapt to time travel. Whenever arriving in a new or alternate timeline, the character is Shaken and gets a -1 penalty to all actions for the first several minutes. They suffer similar effects at the edge of time fissures and other temporal phenomena where multiple times are physically adjacent.

A character cannot have both Time Traveller and Time Vertigo.

New Rules


Each person has a home timeline. Time travel poses some interesting challenges to the unwary.

For game purposes, Time is divided into broad periods, roughly equating to technology levels. It should be noted that even if a story takes place in the future, the technology level may be different. See the Middle Ages for an example.


This era describes the Stone Age, Bronze Age, and Iron Age. It ended on Earth with the rise of ancient civilizations like the Egyptians and Chinese.

A few episodes have taken place in this time, such as the 1st Doctor episode “An Unearthly Child”.

Ancient Times

Ancient civilizations blossomed with technologies that allowed states to expand beyond towns. This period represents a time before gunpowder and inexpensive paper.

The Doctor has visited many places in this time, including Pompeii and the Battle of Hastings in “The Time Meddler”.

The Middle Ages

Events like the Crusades and the translation of Greek and Arabic texts fueled a renaissance in Europe during the 12th century, known as the High Middle Ages. It was remembered fondly for its feudal system, knights and castles.

The Doctor rarely visits, but has seen the Crusades (“the Crusade”, “The King’s Demons”) and Marco Polo. However, the Doctor has visited other planets like Peladon and Ribos, where the technology is at this level.

The Renaissance

The Italian Renaissance saw a similar explosion of social development from translation of literary works and historical accounts, as well as advancements in mechanical engineering.

As these advances were applied to transportation, ships began carrying explorers across the ocean.

The Doctor has visited this period many times, including Italy (“The Masque of Mangragora”, “The Vampires of Venice”), France (“The Girl in the Fireplace”) and Shakespeare.

The Industrial Revolution

Coal-powered steam engines gave rise to automation in several industries: textiles, mining, and transport. Like the previous Age of Exploration, the steam engine powered transportation advances too, in the form of steamships and railways.

The Doctor has been to this era a couple of times (“The Mark of the Rani”, “The Next Doctor”).

Victorian Times

This era of productivity began in the mid-19th Century with the mass production of steel and machine tools. The era saw the telegraph, telephone and internal combustion engine, and culminated with scientists gaining an understanding of thermodynamics and electromagnetism.

The Doctor comes to this era often (“The Unquiet Dead”, “Tooth and Claw”, “The Gunfighters”, “Ghost Light”, “The Unicorn and the Wasp”, “Vincent and the Doctor”)

The 20th Century

Applications of new science and World War I propelled another leap in technology. Product development after the war gave the world crystal radios, vacuum tubes, radar, and microphones. By the end of World War II, early computers and nuclear power were invented. Spaceflight and lasers are among the innovations at the end of this era.

“Human Nature / The Family of Blood”, “Black Orchid”, “Daleks in Manhattan / Evolution of the Daleks”, “The Empty Child / The Doctor Dances”, “The Curse of Fenric”, “Delta and the Bannermen” and “Blink” are just some of the historical adventures that have taken place in the era, not to mention all of the contemporary stories in the classic series (such as “The Invasion”, “Inferno”, “Robot”, “City of Death” and “Logopolis”).

The Information Age (Modern Day)

Advances in fibre optics, the Internet and Earth’s first official contact with aliens in 2006 opened this era, which was marked by an increase in global consciousness. Stories in this era may feature extrapolations of modern technology but include few real advancements.

The McGann TV movie is the first story set in this time. All the contemporary stories of the new series take place in this era. Near future stories also take place in this era: “The Hungry Earth / Cold Blood”, “The Wheel in Space”, “The Waters of Mars”, “The Moonbase”, “Day of the Daleks” and “Warriors of the Deep”.

Interstellar Empire

The era starts after humans begin interstellar travel with ion rockets (circa 2100). It encompasses the Earth Empire period as well, ending roughly in the year 4000. Stories in this era tend to have ‘hard’ science fiction feel.

“The Dalek Invasion of Earth”, “Tomb of the Cybermen”, “Earthshock”, “Midnight”, “The Curse of Peladon”, “42” and “Terror of the Vervoids” are some serials that take place in this era.

Far Future

Humanity’s heyday. Most of the current series’s jaunts to humanity’s future take place in this era. This is the era of Time Agents, vortex manipulators, the Ood, and Weeping Angels.

This era represents the pinnacle of human technology and thus is the last human era. Technology in this era is so far advanced that stories in this era tend to have ‘soft’ science fiction feel.

Episodes include “The Impossible Planet / The Satan Pit”, “Planet of the Ood”, “The Time of Angels / Flesh and Stone”, “Silence in the Library / Forest of the Dead”, “The Doctor’s Daughter”, “New Earth”, “Gridlock” and “Utopia”.

Rassilonian Gallifrey

The Doctor’s people come from this time, and possibly only the Daleks rival the Time Lords in technological achievement.

Fitting Into Another Timeline

If someone suspects another person is from a different time, they may use a Notice roll to detect the traveler, opposed by the subject’s Knowledge (History) skill.

Should a social faux pas occur, the character must make a Persuasion roll to avoid drawing attention. Enough Hostile results could lead to incarceration, an asylum, or worse.

Unfamiliar Technology

People are considered to be proficient with technology of their own timeline. If it is dramatically appropriate, the Game Master should use the following guidelines for extraordinary technology.

A character can develop skill with technology of different eras. A Knowledge skill for a particular technology level makes the character proficient with the technology and etiquette of that time. Players looking for proficiency across all timelines should take the Time Traveller Edge.

Baring proficiency, the following rules apply:

Technology that is uncommon in their home timeline can be used with a -1 penalty. An example might be an old-fashioned ice cream maker for a modern-day human, or likewise a MRI machine.

Old technology that is no longer in use in their home timeline is harder. It requires a Smarts roll to correctly deduce how to operate the device. Then, the device comes with a -2 penalty to use. Medicinal use of leeches falls into this category.

Technology that is from the next future era is treated like old technology: Smarts roll, -2 penalty. However, any technology further advanced than that is unfathomable and seems like magic. A person confronted by such technology is forced to experiment.

Penalties to skill rolls involving technology until a Raise is achieved using the device. After that, the penalty no longer applies — they have gotten the hang of the era’s equipment.

Each time the characters returns to an era, they must overcome the penalty once more.

New Equipment

Most objects in the Doctor Who universe should be assigned powers by the Game Master as needed. The ones listed are common to several episodes. All of the ones listed below are considered far future tech, and thus impose a -2 penalty to most characters per the rules on Timelines above.

Deadlock Seal

A deadlock seal is a lock that cannot be opened by ordinary means. It is impervious to the Sonic Screwdriver, for example.

Psychic Paper

Psychic paper is most often used to forge credentials. It gives +2 to Persuasion attempts. Wild Cards may not be fooled, they can make a Smarts roll at -4 to see it for what it really is. It can also be used to receive a brief message from another mentalist.

Sonic Screwdriver

A Sonic Screwdriver is an all-purpose tool. It gives +2 to Lockpicking, Repair, and Tracking attempts, as well as a +2 bonus to Knowledge skills like Science, Electronics and Computers in situations where obtaining readings is useful.

It has a range of 3, thus allowing the wielder to interact with locks and other objects at a distance. It can also be used like a remote control to trigger the activation of a device.

Its sonic bursts can be used as a weapon in dire circumstances, doing 1-3d4 nonlethal or structural damage per round, though it takes a quarter of that damage (round up) to itself when used this way.

It has a Toughness of 6. The device can repair itself at a rate of 1 point of damage per hour, and even knit itself back together if broken into pieces.


The TARDIS is a vehicle that dematerializes from one place and materializes in another place and time. Travel time is subject to the whim of the Game Master. Some trips can take a long time, and others are instantaneous.

A pilot must have the Arcane Background (Rassilon Imprimatur) Edge to navigate the TARDIS, though an untrained operator can activate a prepared flight path. A Piloting roll is required to achieve something extraordinary, such as land inside a transduction barrier or envelope a spaceship.

A TARDIS is alive in some ways. It has d4 Smarts, d4 Spirit, and d12 Vigor. It can pilot itself out of danger. It can even get sick.

It has the following Powers (see the core rules and Super Powers Companion):

  • Awareness (the TARDIS Scanner)
    • Danger Sense (the Cloister Bell)
  • Chameleon (inanimate objects only)
  • Environmental Protection
  • Fly (8)
    • Pace of 48 (120 mph)
  • Interface
    • Code Breaker
  • Light
  • Speak Language
    • Telepathic Broadcast (worldwide, but passengers only)
  • Telepathy
    • Impressions only, operator only

Due to its transcendental nature, it’s bigger on the inside than the outside. In game terms, the interior of the TARDIS is a gargantuan HQ (see the Super Powers Companion). It is considered futuristic HQ (+5 facility mod). It has the following special rooms, in addition to places like a wardrobe room and swimming pool that don’t effect gameplay:

  • Command Center (aka the Console Room)
  • Generator (aka the Eye of Harmony)
    • The TARDIS is considered to have an infinite power supply, however it has failed from time into time throughout the history of the show. In these cases, the operator can also draw power from another energy source, such as a dying supernova. The Game Master will tell you when such a thing becomes necessary.
  • Kitchen and Dining
  • Library/Computer
  • Medical Center (includes the Zero Room)
  • Personal Quarters (each passenger has an individual room)
  • Specialist Library/Lab (one for each general Knowledge area listed in the core rulebook)
  • Storeroom (akin to Garage)
    • It is considered to have any tool the characters might need. However, the TARDIS is massive. A character may spend an hour to make a Notice roll to find the object in the TARDIS stores.
  • Training Room
  • Workshop

The TARDIS also has the following HQ extras:

  • Camouflaged
  • Defenses
    • Immunity: Nearly Complete Coverage
    • Done via Shields, which can be extended to cover a nearby object like a spaceship. Some species have weapons that can damage a TARDIS, like a Dalekanium bomb.
  • Secure Access (TARDIS key)
  • Perception Filter (similar to Well-Hidden)
    • This filter gives people a -4 to relevant die rolls to detect the TARDIS or its occupants
    • This ability can be imbued into a TARDIS key, allowing the perception filter to be carried

Vortex Manipulator

A vortex manipulator is a primitive time travel device, favored by time agents. It’s hard to use and exposes the operator to the Vortex. Travel by vortex manipulator is uncomfortable. A person traveling with the device is Shaken and gets -1 to actions for the remainder of the encounter (akin to Nausea), unless they have the Time Traveller Edge.


Through his adventures, the Doctor and his friends have encountered a myriad foes. Here are a couple of them.


Cybermen are horrific because they embody some of the worst traits of humanity.

Agility d6

Smarts d6
Spirit d4
Strength d10
Vigor d4
Pace 4

Cybermen are encased in an Infantry Battle Suit (+6).

Some models are equipped with a gun in their helmet (Range 5/10/20, Damage 2d8, RoF 1). More recent models can deliver a shock from their wrists (3d6 electrical, reload: 1 action) instead.

Cybermen add +2 when attempting to recover from being Shaken, do not suffer from Wound modifiers, and are immune to disease or poison.


A Cyber-conversion Chamber can convert a person to a Cyberman in a minute.

In the absence of a chamber, Cybermen can use drugs and perform the process manually. Game masters, use the Disease and Poison rules to simulate the victim succumbing to the process.


Most foes that a Time Lord faces threaten on a planetary scale, but Daleks are the only species that continually challenge the Time Lord on a universal scale.

Agility d4, Shooting d8
Smarts d8
Spirit d6, Intimidate d8
Strength d8
Vigor d4
Pace 4

Daleks also have 6 points of skills to spend depending on their specialty. A Dalek Pilot might also have a d10 Piloting skill, whereas a Technician might have a d10 Repair skill.

A Dalek is encased in Powered Armor (Heavy Suit, +14). Daleks suffer -4 to all Notice rolls. Dalek armor allows a Dalek to Fly for short durations, as per the Power.

A Dalek’s eye stalk is particularly vulnerable. It is only slightly armored (+4), but is a Small target (-4 to hit). When a Dalek is hit in the eyestalk, it is blind and must make a Spirit check or self-destruct.

Most Daleks are equipped with an Improved Laser Rifle, which does 4d6 damage but is otherwise like a Laser Rifle.

PowerShell to the rescue!

14 December 2011

I encountered a situation today at work that lent itself to PowerShell. One of the developers asked for some information about the PowerShell line I wrote to diagnose this problem, and I thought it might make a good blog post.

There was a pipe-delimited file that was failing to import into a database via our program, and the QA person was having trouble figuring out why. The process yielded a stack trace, which pointed to a certain stored procedure and a SQL error:

System.Data.SqlClient.SqlException: Error during [stored procedure]: [stored procedure]; 4;
String or binary data would be truncated. at System.Data.SqlClient.SqlConnection.OnError
(SqlException exception, Boolean breakConnection)

The stack trace clearly suggests that an input is exceeding a field length. Question was which one. As it turned out, there was only one column being inserted by this procedure. I did a quick schema lookup and found out that the column in question allows 50 characters.

So, I wrote:

gc failing_input_file.txt | % {$_.split("|")[4] } `
  | ? { $_.Length -gt 50 } | select –unique | measure –line

The query yielded 255 offending rows, and led to an alteration of the INSERT stored procedure to truncate the value from the flat file.

The rest of this post is copied wholesale from that email.

Let me restate it a command at a time, and expand the aliases.

Most common PowerShell commands have an alias, which you can look at via Get-Alias. In general, if you want to know about a command, you type “Get-Help command-name”. I put a backtick after each line to continue the line, as is the PowerShell custom.

Many cmdlets (read: “command-lets”) do pipeline processing, which if you haven’t seen it means that the previous command’s output is handed to the next piece as input. The special variable $_ is the current whatever — in this case, the current line. With most commands like with select and measure, $_ is inferred.

PowerShell offers full access to .NET. The strings it returns are .NET strings, which is why Split() just works.

Get-Content failing_input_file.txt `      
| ForEach-Object {$_.split("|")[4] } `    
| Where-Object { $_.Length -gt 50 } `     
| Select-Object –unique `                 
| Measure-Object –line                    

The first line with Get-Content reads in the contents of the file.
For each line of the file, the second part with the Foreach-Object splits that line by “|” and grabs the 5th item.
The Select-Object command omits duplicates.
The Measure-Object command counts the number of lines.

If you want the contract names themselves, leave off the Measure-Object call:

gc failing_input_file.txt `
| % {$_.split("|")[4] } ` 
| ? { $_.Length -gt 50 } `                                                       
| select –unique

Ubiquitous Capture

26 October 2011

The idea behind ubiquitous capture is that you can dump things on your mind into a storage medium (notebook, what have you) so that you don’t have to tie up attention re-remembering things to keep them fresh in your mind. I have David Allen and Merlin Mann to thank for convincing me this is a good idea.

Today, after listening to Brett Terpstra on Mac Power Users, I’m trying a new (to me) ubiquitous capture workflow. It’s slightly different than what’s discussed on the show.

The lingua franca is Markdown. The more I use it, the more I like it.


  • nvALT 2.1, Brett Terpstra’s fork of Notational Velocity
  • Byword 1.4, a minimalist and sexy Markdown-friendly text editor ($9.99)
  • Dropbox
  • Nocs for iPhone, a Markdown-friendly editor with Dropbox support


  • Change the note storage location for nvALT to a Dropbox folder
  • Add .md as a text extension in nvALT (see this Skitch)
  • Tell nvALT to store and read notes on disk as Plain Text Files

Let me know what you think.

New Beginnings

8 August 2011

In The World According to Mister Rogers, Fred Rogers said:

Often when you think you’re at the end of something, you’re at the beginning of something else!. My hope for all of us is that “the miles we go before we sleep” will be filled with all the feelings that come from deep caring – delight, sadness, joy, wisdom – and that in all the endings of our life, we will be able to see the new beginnings.

I’ve gone through a lot of changes in the past two years. I’ve separated, divorced, moved twice, found a great relationship, gotten engaged, change jobs three times, lost a niece, rediscovered my spiritual way, and obtained a 2nd degree black belt.

It’s important to look for new beginnings amidst the turmoil of daily life. Not all of them are as far-reaching or obvious as the ones I just mentioned. Every day, new seeds are sown.