1. Microsoft's devs and testers write great little specialized utilities but far too often they never see the light of day. They write it for their team, and sometimes have time to post it internally, but all too often they're too busy to publish it outside the company.

    This is one of those gems, and fortunately it is public.

    My Scenario

    I had a NY to FL file copy operation that was taking about 10 minutes with xcopy and pre-Win7 robocopy. The files weren't that big, but lots of small files, and one-at-a-time file copy performed horribly. Win7 introduced the /MT argument to allow 'multiple threads' to copy file simultaneously, which is exactly what I needed. But I'm not using Win7 (yet). Even better, the Win7 robocopy.exe won't run on older versions of Windows (both properly licensed). Nice. RichCopy to the rescue.

    RichCopy is a graphical application for Windows and will run on Windows XP and Windows Server 2003. It also has (cryptic) command-line options for all of the various copy options like filter by name, filter by date, and copy file attribute. RichCopy really shines when copying huge files, but if you seriously raise the threading you can also get a boost when copying lots of small files (like source code files or in this case PowerShell scripts).

    I've used robocopy a lot over the years, so while its options are cryptic I found RichCopy's options even worse. To save myself time I wanted to document the options I'm using.

    RichCopy.exe source destination /TD 64 /TS 32 /SC 64 /FEF *.7z

    Get it here. http://blogs.technet.com/ken/

    Gotchas / Caveats

    1. I was looking for a command-line tool, and this is a windows application. You can wait on the windows application (which does exit properly when given correct command-line options) using PowerShell's 'Start-Process -Wait RichCopy.exe' or in cmd.exe 'start /wait "" RichCopy.exe'.
    2. I wasn't getting any command-line output when passing bad command-line arguments, and while it has logging options I didn't get them to work after a couple of tries.
    3. RichCopy comes with a chm (compiled help) which explains all the options. But I get the feeling the author's first spoken language isn't English because the wording is clumsy. (Not that my blog writing is any good, ahem.)

    Sample PowerShell

    I was using RichCopy to copy my PowerShell profile to my DEV servers. It includes code to call robocopy (if found via Get-Command) and if not found fall back to RichCopy (XP / Server 2003 only). If planning to compare the tools a good addition would be to make this a script parameter instead. The code is available at PoshCode: PoshCode 2468

    1

    View comments

  2. After 9 months of use, SB Studio left 670MB of temporary files.  Thanks StreamBase!  In all fairness this might have something to do with SB Studio being built in/with Eclipse.  They all start with .sb, which makes me feel better about casting blame.


    Friendly poking aside, SB is critical to my current role.  It's been a fun ride learning event-based programming, time-window aggregates, and getting back into Java.  Eclipse perspectives need to be brought to Visual Studio.

    Also an old but good article which makes the case for CEP.  
    0

    Add a comment

  3. I'm a cross-platform developer in the financial services sector. If any .NET or Java developer interested in reaching a 'new level' of performance on commodity hardware should watch this video about LMAX, hosted on InfoQ. Great refresher on HW, good example of pulling back a couple of layers of abstraction to find the worst and best in modern parallel processing. They achieve high throughput with low latency.

    LMAX and TradeFair (think of BetFair)
    http://www.infoq.com/presentations/LMAX

    Interested in pause-less GC on Java? Not afraid of running custom everything? (Custom HW, Custom OS, leveraging power of HW virtualization to maximize JVM.) Take a look.

    Azul and Zing
    http://www.infoq.com/interviews/gil-tene-azul-zing
    0

    Add a comment

  4. I've been playing with TopShelf service host.  Its goal is to remove the repetitive code from Windows Services written in .NET.  My production servers aren't Win 2008, so App Fabric service hosting isn't an option.

    TopShelf 2.1 is still a bit of a moving target. I thought to myself: Self, if you want to update your 3-4 services that use this OSS library, and want to do it really easily, you'll create yourself a NuGet package for TopShelf.

    For those who haven't heard, NuGet packages are to .NET what gems are to Ruby. The package is a zip with DLL and small bit of metadata.  The package goes on a share*, add a line to Visual Studio, and now VS can find and add the package to your service host projects.

    * - You could also drop some service code into IIS to host an internal gallery, but I only need a file share.

    Here is the nuspec file (package description) and PowerShell script (prepare the folder and create the package).

    TopShelfYZ.nuspec


    <?xml version="1.0" encoding="utf-8"?>
    <package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
        <id>TopShelfCT</id>
        <version>2.1.1</version>
        <authors>Chris Patterson (phatboyg), Travis Smith (legomaster)</authors>
        <owners>Chris Patterson (phatboyg), Travis Smith (legomaster), Chris Tracy (yzorgsoft)</owners>
        <licenseUrl> https://github.com/Topshelf/Topshelf/blob/master/LICENSE </licenseUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>A Windows Service hosting library for .NET, for those unfortunate enough to no be able to use AppFabric to host .NET services. Package created by Chris Tracy (yzorgsoft) until real owners can publish the package on NuGet gallery.</description>
        <language>en-US</language>
        <projectUrl> http://topshelf-project.com/ </projectUrl>
        <dependencies>
          <dependency id="log4net" version="1.2.10" />
        </dependencies>
      </metadata>
    </package>
    

    CreateTopshelfPackage.ps1

    Write-Host "START [$($MyInvocation.MyCommand.Name)] $(get-date -f yyyyMMdd.HHmmss)"
    try {
        $packDir = 'pkg\lib\3.0'
        rd -Recurse $packDir -Force
        md $packDir -Verbose -EA SilentlyContinue
        copy .\Topshelf.dll,.\Topshelf.pdb $packDir -Verbose -Force
       
        nuget.exe pack .\TopShelfYZ.nuspec -b pkg
        # should output:
        # Successfully created package '...\TopShelfYZ.2.1.1.nupkg'.
    }
    catch { throw; }
    Write-Host "END   [$($MyInvocation.MyCommand.Name)] $(get-date -f yyyyMMdd.HHmmss)"

    Gotchas

    If you're like me then when creating your first package you might expect NuGet.exe (package creation utility) to be downloaded with the NuGet VisualStudio extension.  This is not the case.  You have to get it from the CodePlex project (under "Other Available Downloads").

    When creating your package you must start with a 'lib' folder.  I thought the lib folder in the examples was like 'foo' and 'bar' (a placeholder for real name), but no, it must be 'lib' to act like one would expect a .NET assembly package to work (to contain .NET DLLs).  And it won't warn you if you don't have a lib folder, or even notify you in any way, it just creates a package that isn't what you were probably expecting.

    Nit-Pick Corner

    I like all my command-line tools on Windows to show help when I give them /?.  It has been thus since my early days before DOS 5.0.  But NuGet.exe doesn't, it shows an error if you give it /? but does show "good help" when not given any arguments.  Is it just me or is this bad form?

    Summary: tools help gather the right Lego pieces

    The ruby community has been running circles around .NET the last few years. That time is passing and I expect .NET to make up lots of ground with NuGet and the growing .NET OSS community. NuGet is a great tool that has been sorely needed.

    One more time for the SEO crowd: NuGet rocks!

    0

    Add a comment

  5. I've been playing with NuGet recently.  @GTsiokos pointed out the package service seems to be the same code that hosts the Orchard CMS gallery at http://orchardproject.net/gallery .

    The Gallery Service project has good example of code _to read_ for anyone building a production OData service (a.k.a. Astoria, WCF Data Services).  Also looks like a good example for the 'shape' of a public OData service.  Some very useful service conventions, like ServiceBase.ExecuteAction that wraps .NET exceptions in ServiceFault, so not even try/catch code is duplicated across service operations (methods).

    I've spent a fair amount of time with WCF and back-end service code this year, and it's cathartic to see a small, lightweight example of .NET service code that is well-factored with (AFAICT) no duplicate code in the codebase.

    http://galleryserver.codeplex.com/SourceControl/changeset/view/571cbbf82836#GalleryServer%2fsrc%2fGallery.Server%2fPackageService.cs
    0

    Add a comment

  6. For a while I've been trying to find a way to switch from a many-monitor setup to a single monitor setup.  Why? I'm using GoToMyPC with it's desktop composition when remoting into my developer workstation from my laptop, and sometimes I don't want all those desktops composed together.

    I couldn't find anything with WMI or PowerShell to automate switching between these two configurations.

    SuperUser question

    I found a solution - GUI automation of the "Display Settings" control panel dialog via Sikuli.

    I'm attaching a zip with Enable, Disable (simpler scripts) and optimized versions of both that run a bit faster.  These are GUI automation and driven by screenshot, so they won't work for anyone else "out of the box" but should be a good starting point for others trying to accomplish a similar task.

    SikuliMonitors.zip

    0

    Add a comment

Blog Archive
Contributors
Contributors
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.