Matthew van Eerde's web log

  • Matthew van Eerde's web log

    The case of the default audio device from the future

    • 3 Comments
    Hover the mouse over each picture (xkcd-style) in turn to get the text that tells the story.

    An amusing behavior of Windows Vista recently came to my attention... sometimes the Sound control panel wants to go back... to the future!



    So far, so good.



    D'oh! Luckily, there's a way to recover...



    Voilà tout.
  • Matthew van Eerde's web log

    xargs start

    • 3 Comments

    Like many programmers, I've messed around in a lot of development environments - including the UNIX/Linux family of operating systems.

    One of the UNIX commands I like is xargs... this is very handy when writing one-off command lines or scripts.

    I like it so much that I miss it terribly when I'm in a Windows OS.  So I wrote an xargs.bat and stuck it in my PATH.  Now instead of writing complicated for loops, I can just pipe to xargs.

    The script is "powered by" the highlighted line:

    C:\Users\MatEer\Desktop\custom-path>type xargs.bat
    @echo off

    setlocal

    if /i (%1)==(/?) goto USAGE

    if /i (%1)==() goto USAGE

    if /i (%1)==(/addquotes) goto ADDQUOTES

    goto NOQUOTES

    :USAGE
    echo usage: something-that-produces-output ^| %0 [/?] [/addquotes] thing-to-run
    echo   xargs.bat by Matthew van Eerde 10/3/2005
    echo.
    echo   something-that-produces-output should write to its STDOUT
    echo   thing-to-run will have each line of the output appended to it,
    echo   then will be run successively
    echo.
    echo   If /addquotes is set, quotes will be added around the line
    echo   before appending the line to thing-to-run
    echo.
    echo   If you call xargs without piping output to it, xargs will wait
    echo   for you to type something in on STDIN.
    echo   Ctrl-Z on its own line to finish.
    goto END


    :ADDQUOTES

    rem eat /addquotes parameter
    shift

    rem Alas, shift doesn't affect %*
    if (%1)==() goto USAGE
    set basecommand=%1
    shift

    :BUILDBASECOMMAND
    if (%1)==() goto DONEBASECOMMAND
    set basecommand=%basecommand% %1
    shift
    goto BUILDBASECOMMAND
    :DONEBASECOMMAND

    rem run the program specified by %*
    rem as many times as there are lines in STDIN
    rem with one extra argument -- defined by each line of STDIN -- in quotes
    rem
    rem all that the find command does is intercept STDIN
    rem
    for /F "usebackq delims=" %%a in (`find /v ""`) do %basecommand% "%%a"

    goto END


    :NOQUOTES

    rem run the program specified by %*
    rem as many times as there are lines in STDIN
    rem with extra arguments defined by each line of STDIN
    rem
    rem all that the find command does is intercept STDIN
    rem
    for /F "usebackq delims=" %%a in (`find /v ""`) do call %* %%a

    goto END


    :END

    endlocal

    This allows wonderfully anaOStic things like findstr /m IFoo * | xargs start

  • Matthew van Eerde's web log

    xkcd finds East and West confusing - what about North and South?

    • 1 Comments

    Stealing from XKCD again:

    Terminology

    I have a similar problem with North and South.  On the globe, there's a clearly marked "North Pole" and a clearly marked "South Pole."

    Fine.

    Magnets also have North and South poles.  These are typically labeled N and S respectively.  Fine.

    But if you consider the Earth as a large magnet (which it is), then you have to stick the N where the penguins live (Antarctica-ish) and the S where the polar bears live (Canada-ish...)

     http://blogs.msdn.com/photos/matthew_van_eerde/images/9064687/original.aspx

    That bugs me.

Page 1 of 1 (3 items)

November, 2008