A cmd.exe sleep command?

SleepIt’s always a surprise when a batch file scripter realizes cmd.exe lacks a sleep command.  But fear not!  The choice command can be used as a substitute.  It lists a set of choices and waits a specified amount of time for the user to choose one.  Choice can be used to sleep for 0 to 9999 seconds (or over 2.7 hours).

Just create the following file and save it as sleep.cmd:


@echo off
set /a SleepTime = %1
CHOICE /N /D y /T %SleepTime% /M "Sleeping for %SleepTime% seconds . . ."

 

Place it in your aliases bin and you’re all set to sleep from the command line!

Advertisements

Leave a Comment

PWD for cmd.exe?

For years I’ve mourned the loss of my favorite unix shell command, pwd.  I can’t count the number of times I had typed those three  simple letters into my xterm window.  After moving to a Windows environment over 10 years ago I started anew with commands like dir instead of ls, type instead of more (wait! more works!), findstr instead of grep, etc…

But no replacement for pwd.  No worries, the prompt for cmd is the current working directory by default.  But what if you change the prompt to the date and time, like I often do (prompt $D$S$T$G), to have a history of when you types which command. That leaves you with no way to tell the current directory.

But today, I learned about the cd env variable. Echo’ing %cd% prints the current directory.  Excited by this, I created the simple batch file:

@echo off
echo.
echo %cd%\

I named it pwd.cmd and placed it in my aliases directory.

pwd

Leave a Comment

This About Sums it Up…

Leave a Comment

UW 1991 Football: Best Team in Pac-10 History?

The Arizona Daily Star is writing about the end of the Pac-10. The conference stayed unchanged for over 30 years (1978-2010) and during that time produced roughly 7,000 sports teams across all ten schools.  Which team was voted best overall?  The 1991 Washington Football team:

The league’s standard for championship football had been John McKay’s unbeaten USC teams of 1962, 1969 and 1972. But when the ’91 Huskies stomped Michigan 34-14 in the 1992 Rose Bowl, commissioner Tom Hansen said, "This is as good a team as I’ve ever seen, and that goes back to all of those USC teams."
 
Don James’ team, 12-0, was so dominant that it averaged 41.9 points, the most in the league since 1973, and allowed a bare 9.2 points per game, the league’s lowest figure since 1967.
 
The Huskies beat Arizona 54-0, the UA’s worst loss in more than 30 years, its first shutout in 210 regular-season games.
 
"This Washington defense is more suffocating than those USC defenses of Junior Seau," said UA coach Dick Tomey. "It doesn’t give you a chance to breathe."
 
The ’91 Huskies shared the national championship with Miami; eight Huskies were first-team All-Pac-10, including nose guard Steve Emtman, who finished fourth in the Heisman Award balloting, the highest finish ever for a Pac-10 defensive player.

Read more: http://azstarnet.com/sports/article_535f2f48-b238-5026-b1d0-c8a7e618bd26.html#ixzz1Qe0HooAX

Ted Miller of ESPN also realizes the Huskies as the best team since 1978:

1. 1991 Washington: The Huskies finished 12-0 and split the national title with Miami.
Best player: Defensive tackle Steve Emtman won the Outland Trophy and Lombardi Award.
Point differential: Washington outscored its foes 495-115.
Best win: Whipped Michigan 34-14 in Rose Bowl. Wolverines finished ranked sixth.
Comment: Four wins over teams that finished ranked in the final top-25, including road victories at No. 15 Nebraska and at No. 8 California. Featured one of the great defenses in college football history, yielding just 9.2 points and 67.1 rushing yards per game. Eight Huskies earned first-team All-Pac-10 honors.

ESPN also calls the ‘91 team one of the most underrated teams in history:

The Huskies shared the national title with Miami, clouding their legacy as one of the best teams in college football history. Nothing against the ’91 ‘Canes, who were a great team, but this Washington team — led by future No. 1 overall pick Steve Emtman, WR Mario Bailey (17 TD catches and future NFL QBs Billy Joe Hobert and Mark Brunell — outscored its opponents 495-115 (Miami outscored a much easier slate of opponents 386-100, and beat Florida State only due to FSU’s infamous "Wide Right"). The Huskies also won their toughest games on the road (at No. 9 Nebraska, at No. 7 California) and then dominated No. 4 Michigan, 34-14, in the Rose Bowl.

Don’t forget that Greg Hansen calls Don James the best football coach of the Pac-10 era:

Don James, Washington, football. James has coached Pac-10 teams in more Rose Bowl games, six, than any other man. His 97 conference victories (including three years in the old Pac-8) trail only UCLA’s Terry Donahue, 98, who coached three more seasons. James had two superb bursts at the UW: His teams went 58-14 over six years from 1979 to 1984, and he finished on top, retiring in 1993 after going 31-5 in his final three UW seasons.

To add to that, here is a clip from the last time UW and Oregon met:

1991 Huskies. Best sports team in Pac-10 History?

Comments (1)

History of Husky Stadium

I just saw this short video about the history of Husky Stadium posted on King5.com.  It’s short but does have some interesting information and images-including a quick tour into the first tunnel!

History of Husky Stadium

Leave a Comment

Husky 2011 Spring Football Game

Washington-Huskies-HelmetThe weather cooperated today so I headed to the 2011 spring football game at Husky Stadium.  This will be the final spring game hosted in the 91 year old bowl.  Afterwards, I got up close with Keith Price, ASJ, Nick Montana, Nick Holt, and Chris Polk.  Despite scouring the field after the game, I could not locate Sark. Get a load of the lost fan from Eugene:

 

2011 Spring Game

 

And a nice panoramic of the final spring game in Husky Stadium:

Husky Stadium spring game 2011

Leave a Comment

Reversing A String With C

The most common interview question I hear about is the problem involving reversing a string. There are countless methods to do so, many of which are so creative it makes you wonder how anyone came up with a solution. One aspect of the problem I’ve never heard discussed concerns the method used to declare the string. The answer can vary depending on if the string the function is reversing is a char* or a char array[]. Char arrays can be manipulated character by character whereas strings, char* in this case, are immutable.

Let’s begin with a solution that always works, regardless how the string is declared.

The function below, reverse1, takes a char* as input and returns a new pointer to a block of memory it will allocate with malloc. The function simply “reverse copies” the input string into the new string.

char* reverse1(char* myStr)
{
    int i, len;
    len = strlen(myStr);
    char* newStr = (char*)malloc((len+1)*sizeof(char));
    
    for (i=0; i<len; ++i)
    {
        newStr[len-1-i] = myStr[i];
    }
    newStr[len] = ‘\0’;

    return newStr;
}

The wonderful aspect of the above code is it will work on both char* strings and arrays of chars. All of the following strings can be passed as input:

// Arrays
char str1[] = “Hello”;
char str2[6] = “Hello”;
char str3[10];
printf(“Enter string> ”);
scanf(“%s”, str3);
char str4[] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘’};

// strings
char* str5 = “Hello”;

However, one may want to perform the same reverse task without allocating new memory, or may infact wish to reverse the block of memory passed into the funtion instead of receiving back a pointer to a new block of memory. Here is another solution that accomplishes this.

If one attempts to pass in all the strings declared above, they will run into a problem.     This function attempts to get down and dirty with the string and rearrange the elements swapping the first element with the last and so on. The application will crash when passing in a pointer to a string (char*). Strings are immutable while arrays can be manipulated.

void reverse2(char* myStr)
{
    int i, len;
    char temp;
    len = strlen(myStr);
   
    for (i=0; i<len/2; ++i)
    {
        temp = myStr[i];
        myStr[i] = myStr[len-1-i];
        myStr[len-1-i] = temp;
    }
    myStr[len] = ‘’;
    return;
}

Leave a Comment

Older Posts »