Proposed CodeStock Talks for 2013

§ April 23, 2013 12:33 by beefarino |

CodeStock 2013It’s that time of year again!  One of my favorite conferences has opened early registration, and once you register you get to vote on the sessions you want to see.  I’ve changed the theme of my submissions this year – instead of focusing on PowerShell stuff I’ve submitted several more general talks about developer and independent life.  I’m expounding on them here in case you need a little persuasion to send some votes my way.

An Honest Look at Being Independent

This talk is about the changes that comes with being independent of an employer.  The goal is give you a very clear picture of what changed for me – financially, psychologically, and legally.  Part of the talk will include a near-pornographic look at my cashflow and expenses – where the money comes from and where the money goes, and how this folds into the choices I make around my time and my family.

If you’re considering the move to independence, please vote for this session.

http://www.codestock.org/sessions/an-honest-look-at-being-independent/

Programmer Body Issues

We don’t usually think of the programmer’s career ending because of injury, but it happens more often than you know.  The human body wasn’t designed to sit and type for long periods, and the effects of doing that can have career-ending implications.  This talk is about what your job is doing to your body, how to recognize the warning signs before stress turns into pain and then injury, and how to keep yourself healthy and happy and productive with very little effort.

This isn’t about diet & exercise, nor ergonomics.  It’s about undoing the damage you’ve already done.

http://www.codestock.org/sessions/programmer-body-issues/

Giving it Away: How Publishing OSS Helps the Independent Developer

It may not make sense at face-value, but spending your time on open-source projects can be a huge boon for your business.  This talk is about treating OSS as a business opportunity, and how I’ve managed these give-it-away efforts to generate more income than the “regular” consulting and software sales facets of my business.

http://www.codestock.org/sessions/giving-it-away-how-publishing-oss-helps-the-independent-developer/

Creating Mayhem!

This one is just for fun – Mayhem is an open-source project that allows you to “wire up” events to reactions.  Use your phone to turn on your lights, or your XBox controller to run a PowerPoint presentation.  I’ll show you how easy it is to get started with this framework, and how quickly you can fold in your own creations.

For our summer project this year, my oldest daughter and I will be creating devices for our dog’s kennel that will allow us to dispense treats, sense his movement and barking, etc.  Part of this talk will feature how we’re using Mayhem to read from and drive these arduino-based devices.

http://www.codestock.org/sessions/creating-mayhem/



PowerShell Mini-game: Equality (Answer and Winner)

§ April 17, 2013 19:38 by beefarino |

Many thanks to everyone who contributed answers to this little puzzler!  I was actually a bit surprised at the volume - hopefully you found it fun and educational.

First, let’s get a definitive answer down for this one…

Query

In PowerShell, when is the following statement true? Explain why.

     ( $a -eq $b ) -ne ( $b -eq $a )

Answer

At first glance this may not seem possible.  The trick is in understanding how PowerShell evaluates the equality operation when the types of $a and $b vary. 

There are two general cases to consider here: when $a is scalar, and when $a is an array.

Scalar Equality and Type Conversion

If you’re not familiar with the term scalar, I’m using it to mean a variable containing “a single value” as opposed to an enumerable collection type, such as an array or list.  Yeah, it’s from Perl, so what?  (Note that the string type, while technically an enumerable collection of characters, is considered a scalar value here.) 

Type the following in your PowerShell console (seriously (I SAID DO IT)):

$a = 0;
$b = '';
$a -eq $b

What do you get?  True!  Which makes sense, since 0 and an empty string both sort of mean “nothing” or “no result,” right?  Now type this:

$b –eq $a

Boom goes the dynamite: False.  So what’s happening here?  It may help to replace the variables with their actual values:

0 –eq '' # true case
'' -eq 0 # false case

When PowerShell evaluates this comparison, it begins by taking the left operand at face value.  Since the right operand is of a different type, PowerShell is forced to coerce its type to match the type of the left operand.  The reason for the false case becomes fairly obvious when you spell out the conversion PowerShell is doing on your behalf:

0 –eq [int]'' # true case
'' –eq [string]0 # false case

In the true case, the conversion of an empty string into an integer value of 0 makes sense, and the equality expression is true.  In the false case, the conversion of the number 0 into a string results in a string containing a single character ‘0’, which is different than the empty string and the expression is false.  You can verify these conversions in your console:

[int]''   # 0
[string]0 # 0

This hidden coercion can lead to some fairly interesting results, to put it mildly.  Try this one, it’ll blow your mind:

$a = $null;
$b = [string]$null;
$a -eq $b

Yep, that’s right: ($null) doesn’t equal ($null cast to a string) in PowerShell.  Have you ever passed $null to a .NET method that accepts a string?  No, you haven’t: you’ve passed an empty string without knowing it…

Arrays and –eq

Several puzzlers pointed out that –eq behaves differently when the left operand is an array; while not the answer I was looking for it’s just as correct as the previous one.

The easiest way to describe this is by example; try this in your PowerShell host of choice:

$a = 1,2,3,4,5;
$b = 3;
$a -eq $b
$b -eq $a

When the left operand is an array, –eq returns the members of the array that equal the right operand.  In this case, $a –eq $b returns the integer 3.  Reversing the order of operands naturally changes the expression, and since there is no way to convert an array of numbers to a single integer the comparison is false.

This is an awesome example of PowerShell’s penchant for lists and enumeration, and it applies to many of the binary operators it supports:

'aabb','bbcc','zzaa' -replace 'a','q'

The Takeaway

The lesson here is that while PowerShell isn’t a strongly-typed language like C#, it does have solid roots in the .NET type system and leverages it in many interesting and “helpful” ways.  If you’re not careful, you’ll get burned.

Winner

Ah, I almost forgot!

Choosing the winner on the merit of the answers turned out to be tough – everyone did a really great job.  Some explanations were better than others, but it was difficult to isolate one as the best.  Thankfully I have PowerShell's get-random to turn this into a “business decision.” 

And the author of the winning answer and receiver of a license for the immensely cool SeeShell software module published by the devastatingly handsome folks at Code Owls is….

 

JOSH CARROL

 

Thanks for playing everyone - since this was so much fun let’s say we do it again soon.  For now though, focus on those upcoming Community Scripting Games!

 


PowerShell Mini-game: Equality

§ April 9, 2013 14:06 by beefarino |

In light of the upcoming community Scripting Games, I have a PowerShell brain teaser for you.  

Query: In PowerShell, when is the following statement true? Explain why.

     ( $a -eq $b ) -ne ( $b -eq $a )

Submit your answer as a comment, or post it on your own blog and provide a link in the comments of this post.  The best explanation (as chosen by me) will receive a complimentary single-user license for SeeShell (a $249 value).  You have until April 16, 2013 to submit your answer; the winner will be announced April 17, 2013.



Marking Three Years

§ April 2, 2013 11:19 by beefarino |

Yesterday was a great day – no foolin’. 

First, I have been renewed as a PowerShell MVP for my third year running.  This is a great honor and I hope I live up to it.   

Second, I was reminded that my third anniversary as an independent business owner and software consultant occurred in March.  It feels a lot longer than three years, but I think that speaks to how much I’ve accomplished in that time.  Business is good, communities are growing, my life is my own, and I’m doing what I want to do.  What else could I possibly want?

So what will year four look like?  Here’s what I’d like to accomplish:

  1. More Iron Scripter! competitions.  I have yet to formalize the website that drives these games, I’d like to spend some time doing that so we can start organizing brackets, have coordinated wider competitions, and special events.
  2. More free software.  Code Owls is about ready to push out a beta release of a skunkworks project named “Polaris.”  This is an integration of Windows Explorer and PowerShell that strips down the workflow for extending the windows file explorer to a few lines of script.  It quite literally turns Windows Explorer into a PowerShell-driven dashboard you can use to monitor any data PowerShell can provide.
  3. Licensing Code Owls frameworks.  I’ve dumped a ton of effort into building a base framework for creating PowerShell providers and hosts quickly and without fuss.  While these frameworks are available as open source software, my plan is to fork these projects into commercial libraries that include support and customization services.
  4. Another PowerShell Saturday.  This time I want more help.  Drop me a line if you’re interested.
  5. Maintain speaking engagements.  I still love speaking and want to continue doing so, but this year I’d like to try speaking less about technology and more about career and life management.  We’ll see how that plays out.
  6. Maintain volunteer hours.  I spend a lot of time in the local public schools, helping out with tech issues and lending a hand in the classroom.  I love this time and find it very rewarding, and the staff are immensely appreciative.
  7. Finally, I want to pick up fiction writing again.  I haven’t touched this hobby in a decade or so, but my father was kind enough to enroll me in a 12-month online workshop for hobby writers that should help get the pen moving.  My hope is to participate in the National Novel Writing Month this year.

Yeah, all that.  So this is me, hanging on for the ride….