Lights and shades of Scripting Games.

First week of Scripting Games is behind. Well, technically there will be three weeks, but because half of events where revealed, and I’ve completed most of them – I feel almost like at half of ‘active’ part. What comes next is ‘passive’ part – get grades, read contribution from others (can’t wait!), read experts solutions (that should be even better!). At the moment I have mixed feeling about Scripting Games. Today I would like to write more what and why I like so far, and what and why I do not like.

1. Always look on the bright side…

Events so far where just great. I mean they were great last year too, but I really had fun playing with some concepts. And even though I’m always for objects, I managed to get it ‘my-way’ even for events that required me to produce text. This is the brightest part so far.

Another cool thing was the interaction with others – when I competed last year I was not really social. No twitter account, no facebook account. I can’t even recall any interaction on IRC channel (but that I’m not sure – it’s possible I was already common visitor there already). This year it is different story. I still do not have facebook account, but Twitter + IRC is more than enough for me.

Another thing I like about this games is confidence in what I do. I really know how. Judges may disagree (we get to that) but I really see big improvement over last year contributions. I see clearly that there is very little things I can not do. And Scripting Games are also here to help: I see those gaps more clearly and maybe one day I will be able to get rid of those too.

Last but not least: chance to work without being directly influenced by script from others. I really thing it was great idea. I mean if I can not find a way – it always helps to see hot others did it. I did it like that last year for few events. But being forced to ask, and dig, and google, and Technet-things really makes it more… memorable? I forgot some things last year soon after SG was over. I do not expect it to happen this year though. Took me quite some time to find a ways for some tasks assigned by Ed.

2. If life seems jolly rotten…

No to the dark side. Judging. I’m really confused, because of it. I mean I look at list of judges and I really see only smart people, devoted to community and such. But I really can’t resist impression that at least few don’t know rules for the game they are taking part in. We (contestants) were told to read rules if we disagree with notes. But 2nd event, I got 1 star for, is in my opinion proof, that this goes in both directions. Basically 1 star means I submitted script that does not do the job. Is it the case? Let see, my grade:

SG-Fail_1

So what result will you get if you simply run my script? Error? Some bogus info that has nothing to do with assigned task? Take a look:

SG-Fail_2

I was worried that it worked fine because I had my laptop fine-tuned. Than I thought I simply made mistake when I was copying it to PoshCode, so I’ve downloaded it to ‘clean’ machine, saved it, run it from PowerShell.exe –NoProfile –ExecutionPolicy Bypass (had to, cause this computer had default execution policy). And what I see is what I would expect to. So what’s up? And there is more than that. With my script you can query excel, AD, SQL, use local file – we were required to do only one, but with used technology (ADO.NET) I could connect all. I made it as reusable as I could. I wrote this script in a way that insures that I get only servers from AD (+1 design point). I would expect at least 3 points, maybe more (comment based help, parameter sets, error handling). But judge thinks I submitted something that does not work. Great. I would expect at least some comment for such low grade, but it was probably too much work…

3. Just purse your lips and whistle – that’s the thing.

Boe Prox wrote very wise sentence regarding issues like this one on Twitter:

“Remember that as long as you did your best on your script and are happy with what you did, then grading should be secondary.”

Last year I was green and was happy with any grade higher than 2. This year I feel I’m good and everything less than 5 is probably reason to be disappointed. But the grades are not that important. Sure, it probably means I won’t be able to repeat my wonderful score, and be 3rd. But the most important part is fun, learn and improve. If you are upset with grades – do as I did – ignore them! If you feel it’s time to quit and you are forced to by 2* for script that does it all and is just pure PowerShell orgy of parameter sets and well written and pipeline friendly functions – ignore 2*, go on and write next script that will be as good as this one. It’s always in eye of beholder, and just because you feel that judge should give you at least 4 – don’t stop rockin! 😉 I jumped in again and re-written my profile to remind me of time remaining until end of each event. For ISE – it will show me only first one that is not yet done in the title. In PowerShell.exe (where I test it all, because ISE sometimes loads some additional assemblies on-the-fly and script tested there may fail in PowerShell.exe) I do even more – header with all ‘active’ events. Some code at the end of this long post – that’s how I whistle, I whistle Verb-Noun. 🙂

$2011sg = @"
"EventDeadLine","Event","Status"
"11 April 2011 12:15 AM","1","DONE"
"12 April 2011 12:15 AM","2","DONE"
"13 April 2011 12:15 AM","3","DONE"
"14 April 2011 12:15 AM","4","DONE"
"15 April 2011 12:15 AM","5","WAIT"
"@              
            
function Measure-TimeRemaining {            
param (            
    [Parameter(ValueFromPipeLineByPropertyName = $true)]            
    [datetime]$EventDeadLine,            
    [datetime]$Time = $(Get-Date),            
    [Parameter(ValueFromPipeLineByPropertyName = $true)]            
    [int]$Event,            
    [Parameter(ValueFromPipeLineByPropertyName = $true)]            
    [string]$Status            
)            
process {            
    $Span = New-TimeSpan $Time.ToUniversalTime() $EventDeadLine.AddHours(8)            
    if ($Span -gt 0) {            
        "Left: {0} days, {1} hours, {2} minutes to the end of Event {3}! <== {4}" -f             
        $Span.Days, $Span.Hours, $Span.Minutes, $Event, $Status            
    }            
}            
}            

And part of prompt that will always show me info about deadlines at the top of PowerShell.exe window:

function prompt {            
    $FillSpaces = $Host.UI.RawUI.WindowSize.Width -1            
    $OldPosition = $Host.UI.RawUI.CursorPosition            
    if ($OldPosition.Y -le 5) {            
        $OldPosition.Y = 6            
    }            
    $FromTop = $OldPosition.Y - $Host.UI.RawUI.WindowSize.Height + 1            
    $Y = [math]::Max(0,$FromTop)            
    $host.UI.RawUI.CursorPosition = New-Object Management.Automation.Host.Coordinates 0,$Y            
    $2011sg | ConvertFrom-Csv | Measure-TimeRemaining | ForEach-Object -begin {            
        $i = 0            
    } -process {             
        Write-Host $("$_" + " " * $($FillSpaces - $_.Length))            
        $i++            
    } -end {            
        $i..5 | ForEach-Object { Write-Host $(" " * $FillSpaces) }            
    }            
    $host.UI.RawUI.CursorPosition = $OldPosition            
    $host.UI.RawUI.CursorPosition.X = 0            
    <# The rest of profile goes here... #>            
}

And that how it looks like:

SG-WhistleSo – last quote from Monty Python’s song:

You know, you come from nothing – you’re going back to nothing.

What have you lost? Nothing!

And there is really A LOT you can gain from Scripting Games. Even if you disagree by far with number of stars drawn by the judges on the sky of your scripting excellence. 😉

Advertisements

2 thoughts on “Lights and shades of Scripting Games.

  1. Bartek,

    An excellent blog posting. Keep up the good work and positive attitude. The knowledge you gain from completing the events cannot be taken from you. The good thing I see is whichever judge is grading hard is grading everyone hard so there does not appear to be any favoritism going on. Ed has reminded the judges to be sure to add comments but he can not force them to do so.
    Good luck with the remainder of the events.

  2. Thanks for comment. 🙂 Hard grades are fine as long as they have some reason behind it, and how can I know the reason if there is no comment attached to it? 🙂 Anyway, I appreciate Ed’s hard work too much and won’t let anybody (no matter how knowledgeable and PowerShell skilled) to push me away from SG and spoil this Holidays for MS PowerShell scripters by simple 1*/ 2* rating. 😀 Now I need to find a way to get DirectX info. And other stuff too. Adv 5 – here I come. :>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s