12 Problems

You have to keep a dozen of your favorite problems constantly present in your mind, although by and large they will lay in a dormant state. Every time you hear or read a new trick or a new result, test it against each of your twelve problems to see whether it helps.

Every once in a while there will be a hit, and people will say:  “How did he do it? He must be a genius

-Richard Feynman

12 problems:

1. Realtime OS Event monitor.

Not perfmon data, not tracing ETW calls through xperf, not event logs. Process + OS state changes monitor (Procmon on browser on steroids..). Has to be evented (maybe GWMI + WQL)

2. Get Realtime State Change on OS level in a browser(Javascript, publish/subscribe messaging system like pubnub).

3.  Unified alerting framework for the state changes above (Email, Gtalk,Skype + SMS/Phone+ Email + Log)

4. Effective way to implement long-running powershell scripts. Maybe jobs, but something better than jobs which survives a session close / shutdown.

5. Intercept a Shutdown Command

6. Unified Powershell Cross-Cutting Tools. Not just a function or a module, but a background job / service which implements this across different functions.
– Log Writing
– Error Handling.

7. Take a txt file with conditional logic and parse it into ACTION statements which can be executed. Maybe like Bartek Biewalski’s Powershell AST code

8. Simplified multi-threading of powershell code. (Boe Prox, Oisin samples..)

9. Fast compare-object, using SQL instead of .net

10.  Someway to assign resource requirement to a script, before you execute. Idea is to scope the problem before you start executing stuff which will blow your system off.

11. Powershell Chaos Monkey (inspired by Netflix Chaos monkey)

Netflix is going to OpenSource Chaos monkey. We can take some inspiration from that.
http://techblog.netflix.com/2011/07/netflix-simian-army.html

12. Better Get-Random for small ranges (0-1000). Test for randomness of Get-Random.

 

Advertisements

3 thoughts on “12 Problems

  1. I gave a shot for #12 and here is what I came up with:
    Function Get-SmallRandom
    {

    $procArch = $env:PROCESSOR_ARCHITECTURE
    if($env:PROCESSOR_ARCHITECTURE -match “\d{2}$”){$procArch = $Matches[0]}
    if($procArch -eq 64){
    [Int](((Get-Date).Second * (Get-Date).Millisecond * (Get-Date).Ticks) / ([Int64]::MaxValue + 1))
    }elseif($procArch -eq 32){
    [Int]((((Get-Date).Ticks/(Get-Date).Millisecond)/([Int32]::MaxValue + 1.0))/1000)
    }else{
    [Int]((((Get-Date).Ticks/(Get-Date).Millisecond)/([Int32]::MaxValue + 1.0))/1000)
    }
    }

    $a = 1..1000 | %{Get-SmallRandom}
    $b = 1..1000 | %{Get-SmallRandom}
    Compare-Object -ReferenceObject $a -DifferenceObject $b -ExcludeDifferent

  2. After looking at the problem description a little more; I think the problem is that the algorithms used cannot generate 1000 unique numbers because we need ultimately use the modulus operator to bring the value below 1000. So, I attacked the problem a little differently. Given a set of 1000 numbers, how do I shuffle the set in an unbiased way so that it has the appearance of a randomly generated set. Out of all the shuffling algorithms out there, ‘Fisher Yates shuffle’; looks the easiest to implement.

    Runs in under 100ms, and since we already have 1000 unique values we always have a set of 1000 unique values.

    Function Get-OneThouRand
    {
    $source = 1..1000
    $returnable = 1..1000
    for($i=1; $i -le 999; $i++)
    {
    $j = Get-Random -maximum $i
    $returnable[$i] = $returnable[$j]
    $returnable[$j] = $source[$i]
    }
    return $returnable
    }

  3. Shuffle the deck using PowerShell | SqlChow

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