burn-console Part III: The Most Efficient MSH Script

Now that we have our script profiler up and running, we instrument our script a little to mark regions we are concerned about. You can download that starting script here: [burn-console-1.profiler.msh] After running the script profiler, we get the performance breakdown: Breakdown by line: ---------------------------- 15%: Line 123 - if($colour -lt 20) { $colour -= 1 } 14%: Line 122 - if($colour -le 70) { $colour -= 3 } 11%: Line 124 - if($colour -lt 0) { $colour = 0 } 10%: Line 128 - $tempWorkingBuffer[$baseOffset - 8%: Line 117 - $colour /= 4.

burn-console Digression: An MSH Script Profiler Part 2

In the last article, we talked about the theory behind a sampling profiler. Let’s go over the code to implement one. We’ll use this to guide our future optimizations. You can also download the script here: profile-transcript.msh. ################################################################################ ## ## profile-transcript.msh ## ## Computes the performance characteristics of a script, based on the transcript ## of it running at trace level 1. ## ## To profile a script: ## 1) Turn on MSH script tracing in the window that will run the script: ## set-mshdebug –trace 1 ## 2) Turn on the transcript for the window that will run the script: ## start-transcript ## (Note the filename that Monad provides as the logging destination.

A Legal Take on the JC Penny Price Gouging

AKA: Welcome Don McGowan to the Party :) Don works in the Law and Corporate Affairs organization at Microsoft, and has always been a bright and illuminating voice in our internal discussions. Case in point – a bunch of people internally are pretty upset that JC Penny is gouging customers by charging $800 for a vanilla Xbox Premium system. Where most people speculate, Don lays down this awesome summary of the situation:

burn-console digression: an MSH script profiler

We now have implemented a working fire effect in a form that’s extremely easy to read. The intention of the code is clear, our functions are nice and modular, and the algorithms are clear. However, we need to deal with some performance issues. For that, we’ll take a small digression. At this point, if performance is of utmost importance, we might consider simply porting our script to a compiled C# cmdlet.

burn-console.msh Part II - A working implementation

Now that we’ve generated the palette, the most complex part of the algorithm is actually behind us. The remaining code implements the fire algorithm, and is fairly simple: Generate fire on the bottom row of the screen. Move the already existing fire upwards on the screen. Rather than just move every cell of fire upwards, though, we take into account the fact that heat is always affected by nearby heat.

Cracking Safes With Thermal Imaging

This came up on SecurityFocus a few days ago, and it’s extremely cool: cracking safes with thermal imaging. The idea behind the attack is that your fingers transfer enough heat to the keypad to be visible for a significant amount of time afterwards. The equipment costs around $10,000 – but that may be a pittance compared to how much the safe has inside. http://lcamtuf.coredump.cx/tsafe/

Burn-Console: A Fire-Effect Demo in MSH

As a deeper example of interfacing with the MshHostRawUserInterface class, the next few articles will deal with implementing the classic “Fire Effect” seen in many of the demos that I so fondly remember. As part of the journey, we’ll also explore some of the ways in which you can improve the performance of time-sensitive portions of your script. [This GIF is animated. Some Ad blocking software restricts animation] What is the fire effect?

First Monad Book Soon on Sale

For those of you looking to slake your thirst for Monad on something other than Blogs and Newsgroups, Andy Oakley’s book will soon be available from Amazon: http://www.amazon.com/gp/product/0596100094 It’s called “Monad – Introducing the MSH Command Shell and Language.” I read it (several times) as one of the technical editors, and it’s a good piece of work. [Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.

Experimenting with Monad’s MshHostRawUserInterface Class

As your scripts become more complex, it’s possible that you will have to interact with the user in a manner more complex than write- and read-host. For example, you might decide to implement a text-based menu system, or even a game of Aliens. To support this low-level access to the console buffer, hosts (for example, ours,) extend the MshHostRawUserInterface class. This class provides most of the common operations required by a console-mode raw user interface, including window management, blitting, scrolling, and colour control.

parse-textObject – AWK with a vengeance.

Hopefully you’ve been following along with Eric’s regular expression exercises, because we’re about to add another cool tool to your Monad toolbox. If your regex-fu is strong, you will soon dice text streams with ease. As you well know, one of the strongest features of Monad is that the pipeline is object-based. You don’t waste your energy creating, destroying, and recreating the object representation of your data. In past shells, you destroy the full- fidelity representation of data when the pipeline converts it to pure text.