Skip to content
Archive of posts filed under the .NET category.

A Script to Find All Aliases for a Cmdlet

I’ve mentioned before that I love PowerShell, but I’m still trying to commit enough Cmdlets and aliases to memory that I can be immediately productive from a Powershell prompt without having to have a browser window open to the Powershell documentation on another monitor. Several of the Cmdlets may also be referenced through one or more aliases, and it’s rather cumbersome to discover what aliases are defined for a given Cmdlet.

I stumbled onto a bit of code that will find all aliases for a given Cmdlet which I put it into a script named Find-Alias. That will let me type the following:

PS C:\>Find-Alias Get-ChildItem

CommandType     Name                     Definition
-----------     ----                     ----------
Alias           dir                      Get-ChildItem
Alias           gci                      Get-ChildItem
Alias           ls                       Get-ChildItem

Here is the script code:

param(
    [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipeLineByPropertyName=$true)]
    [string]$Command)

Process
{
  get-alias | where-object {$_.Definition -match $Command}
}
Share

A Keyword I’d Like To See in C#

Although I use C# more and more these days, I still consider myself primarily a C++ developer. C# has a few really neat language features that are just now being added to C++ (like lambdas), but I still find C++ to be more expressive, with terser syntax, than C#.

One example of this is deterministic disposal in C#. For classes that implement IDispose this is accomplished with the using statement. One example from MSDN follows:

using (Font font1 = new Font("Arial", 10.0f))
{
    byte charset = font1.GdiCharSet;
}

Seems simple enough, right? What could I possibly have to complain about in that code?

Continue reading ‘A Keyword I’d Like To See in C#’ »

Share

The pbrain Programming Language

>I’ve been working really hard lately – 70 or more hours a week. Consequently, I haven’t had many opportunities for diversion. After staring at the same application all day, every day, though, it’s important to step away and give my brain another puzzle to solve now and then. One such late-night/early-morning excursion produced The pbrain Programming Language. This language is an extension of an extremely tiny Turing-complete language called Brainf**k (yes, the name contains a really, really bad word).

Update: A pbrain Compiler for .NET

Since I was halfway home with the interpreter, I decided to go ahead and write a compiler for .NET platforms.

Share

.NET Linked List

>(Note: This is a really old entry that I’m keeping around for historical purposes. Recent releases of the .NET Framework now include a generic linked-list class, as well as other generic containers.)

The .NET framework does not have a generic linked list class among the collection classes in System.Collections. This article describes a linked list class that I wrote that implements System.Collections.IList as well as a new linked-list interface and a bi-directional iterator.

Share

Updated 99 Bottles

>A couple of weeks ago I posted a C# class that outputs the song, “99 Bottles of Beer.” I’ve since made a small revision. I originally used a delegate where an event would have made more sense: handling the “out of beer” event. Go see the new version.

Share