FREE hit counter and Internet traffic statistics from freestats.com

Wednesday, June 30, 2004

Stark on Baird

Here's another assessment of the Beltran deal by ESPN's Jayson Stark. Basically the same take. If Teahan hits then all is well.

Tuesday, June 29, 2004

Beta 1 of Visual Studio 2005 Available

Today, Microsoft announced that the beta 1 is available at TechEd Europe. In addition, they announced that they're going to ship Express versions of the tools that include:

  • Visual Web Developer 2005 Express Edition, a lightweight tool for building dynamic Web sites and Web services

  • Visual Basic 2005 Express Edition, a streamlined programming tool for beginning programmers to learn how to build exciting Windows applications

  • Visual C# 2005 Express Edition, Visual C++ 2005 Express Edition, and Visual J# 2005 Express Edition, targeted programming tools for students and enthusiasts who wish to learn the fundamentals of computer science

  • Microsoft also ships SQL Server 2005 Express Edition, an entry-level database for hobbyists, enthusiasts, and students developers

  • Rule 10.18(i)

    The only even mildly interesting thing that happened in last night's 10-1 drubbing of the Royals by Baltimore, a game which I scored for mlb.com, was the application of rule 10.18(i). So the rule doesn't role off your tongue? Let me refresh your memory.

    "(i) When pitchers are changed during an inning, the relief pitcher shall not have the benefit of previous chances for outs not accepted in determining earned runs. NOTE: It is the intent of this rule to charge relief pitchers with earned runs for which they are solely responsible. In some instances, runs charged as earned against the relief pitcher can be charged as unearned against the team"

    And so last night in the 4-run Orioles 7th Matos doubles, Gibbons singles and score Matos, 1 earned run for Darrell May. However, Hairston reaches when Mike Sweeney drops a throw from third baseman Desi Relaford (his second dropped throw of the night but only the first for which he's charged an error). Runners now at first and second. The runners go on to pull off a double steal before Roberts doubles scoring both of them. Clearly Hairston's run is unearned to May. At this point Tony Pena brings in Scott Sullivan and as 10.18(i) indicates Sullivan starts with a clean slate in terms of his earned runs. Sullivan goes on to give up a single to Newhan but Roberts is thrown out at the plate on a nice throw by David DeJesus from centerfield. Tejada then singles and Palmerio pops out on an infield fly to Graffanino. Without the error Palmeiro's popout would be the third out. However, Lopez then singles to left scoring Newhan before Bigbie flies out to left. So Sullivan is charged with an earned run for Newhan's run since Sullivan does not get to take advantage of the fact that there should have been 2 outs when he entered the game. This is then credited as an earned run to the team (TUR in the mlb.com scoring system). As a result, the boxscore for the Royals pitching looks a little strange:


    IP H R ER BB SO HR ERA
    May 6.0 8 7 6 2 2 1 5.90
    Sullivan 2.0 3 1 1 0 2 0 3.47
    Field 1.0 2 2 2 3 1 0 3.60
    9.0 1310 8 5 5 1


    Looking for more interest in the conventional manner when I score tonight's game.


    Other Royals Notes:
    Joe Randa was placed on the DL after last night's game, Allard Baird announced during a mid game press conference. He'll have arthroscopic surgery on his knee, which will then require 3 to 4 weeks recovery time. Hopefully he'll be back before the trade deadline provided the Royals can find a deal he'll approve (he has a no-trade clause). In the meantime it looks like Relaford will play third.

    Mike Wood pitches today, his first appearance this year in the majors. John Buck will do the catching and so two-thirds of the Beltran deal will be on display.

    The Royals also acquired Jose Bautista from Tampa Bay on a rule 5 pick. Bautista is a 23 year old first baseman who played for both the Orioles and Devil Rays this season. He'll be assigned to AAA Omaha.

    Monday, June 28, 2004

    Tie Goes to the Runner?

    Recently, an interesting conversation ensued on the SABR listserv regarding the phrase "a tie goes to the runner". Is this true?

    In the official MLB rules the only phrase I can find (repeated in rule 6.05(j) and 7.08 is "the defense must tag him [the batter] or first base before he touches first base."

    To me this indicates that a tie does indeed go to the runner since the word "before" is used. However, several on the SABR site argued that umpires are taught that there is no such thing as a tie and so there will always be a correct call. Interestingly, one of the contributors to the SABR list noted that the "1875 DeWitt's Umpires Guide was emphatic that ties go to the runner: 'If simultaneously, the base runner is not put out...'". He also noted that when he umpired he was instructed that a close play was an "out that you needed to sell". Is that still the training for MLB umpires? If so, it would appear that umpires are in fact allowing ties to go to the fielder in contradiction to the written rule.

    While training umpires that there are no ties may be necessary, in reality there are limits to both visual and auditory human perception. In fact, another poster noted that if two events occur within 0.05 seconds it is impossible to reliably judge which occurred first. He also notes that auditory reaction times are typically quicker than visual ones. And so in practice there are ties and so it would be nice if the rule book addressed the issue specifically.

    Sunday, June 27, 2004

    Fear and Awe

    This morning the pastor preached on 1 Peter 2:17, "Honor all people, love the brotherhood, fear God, and honor the king" (NASB). He then used this passage to discuss three levels of authority that Christians are under starting with God, continuing with fellow believers, and then including secular rulers.

    While there are all sorts of implications that fall out of the third exhortation ranging from the justification of the American Revolution to honoring leaders like Bill Clinton, I was most interested in his description of the "fear of the Lord" as the Old Testament says and was reminded that Proverbs notes that this "fear" is the beginning of knowledge. But what exactly is the fear and why is it the beginning of knowledge?

    Obviously, our English usage of the word fear is restricted to irrational phobias (as in spiders or heights) or the entirely rational dread of physical pain and suffering. Here, however, fear retains the older connotation of reverence, respect, and awe. At its core I think you can describe this fear as one basic to humanity and that is brushed up against when one can tear ones self away from our blinding self-centeredness long enough to glimpse reality as it is. I think we see it when contemplating the summit of a distant mountain, the expanse of the ocean, or the vastness of the universe. In fact, it was this properly basic fear that gave man and continues to give men an experience of the supernatural, or the Numinous. The Numinous or "Awful" then is the beginning of, or the first stage of, religious feeling that only when connected with a personal and moral God becomes "the Holy".

    The connection between the Numinous and a moral God was described well by C.S. Lewis in The Lion, the Witch, and the Wardrobe when the children Peter, Susan, Lucy, and Edmund are being led by Mr. and Mrs. Beaver to find Aslan.

    "Aslan?" said Mr. Beaver. "Why, don't you know? He's the King. He's the Lord of the whole wood, but not often here, you understand. Never in my time or my father's time. But the word has reached us that he has come back. He is in Narnia at this moment. He'll settle the White Queen all right. It is he, not you, that will save Mr. Tumnus."

    "Is-is he a man?" asked Lucy.

    "Aslan a man!" Mr. Beaver said sternly. "Certainly not. I tell you he is the King of the wood and the son of the great Emperor-Beyond-the-Sea. Don't you know who is the King of Beasts? Aslan is a lion-the Lion, the great Lion."

    "Ooh!" said Susan, "I'd thought he was a man. Is he quite safe? I shall feel rather nervous about meeting a lion."

    "That you will, dearie, and no mistake," said Mrs. Beaver; "if there's anyone who can appear before Aslan without their knees knocking, they're either braver than most or else just silly."

    "Then isn't he safe?" said Lucy.

    "Safe?" said Mr. Beaver. "Don't you hear what Mrs. Beaver tells you? Who said anything about safe? Of course he isn't safe. But he's good. He's the king, I tell you!"


    So then why is the experience of the Numinous the beginning of knowledge? I think its simply because without a reverence, respect, and awe for a creator there is no central Fact from which the rest of reality flows. If the reductionists are correct and our experience of the Numinous is merely brain chemistry run amok, then there is no basis for reason, no basis for morality, no basis for service towards your fellow man, and in the end no basis for belief in a reality outside your own brain.

    Saturday, June 26, 2004

    Kauffman Park Effects Revisited

    Well, after almost half a season I thought it would be good to revisit the park effects at Kauffman stadium I blogged about in January. In that analysis I found that during the period from 1991-1994 when the park was astroturf and the dimensions were as they are now the park factor was 109 (in other words 9% more runs were scored in Kauffman Stadium). During the period from 1995-2003 when grass was installed and the fences moved in the park factor remained 109 although during the period 2001-2003 it was around 127, at or near the top each season.

    This offseason the fences were moved back and according to the ESPN calculation the park factor thus far in 2004 is 84, good for 27th in baseball. In addition, the factor for homeruns is 69, 29th out of 30 only leading the new PETCO park in San Diego where it is 64.

    So it appears that moving the fences has had an effect although it will probably be several years before we know how big the effect is. The other thing I noticed from my previous analysis is that park factors seem to carry a large standard deviation and so yearly weather patterns and other factors may play almost as big a role as park dimensions (.15 for the Kauffman data) for certain ballparks (I would think more so in the midwest). For example, although I don't have any concrete data, this spring in Kansas City has been wetter and cooler than any I can remember since moving to the area in 1995. This idea was born out to some extent in the analysis done about Coors Field I blogged about earlier this month.

    Beltran Joins the Killer B's

    As a Cubs fan I can't say I'm happy about the Royals dealing Carlos Beltran to the Astros. However, as a Royals fan I think that GM Allard Baird did what he had to do given the ridiculous financial world in which Major League Baseball operates.

    As for Houston, they gave up Octavio Dotel now bound for the A's, who had converted 14 of 17 save opportunities and struck out 50 in just 34 and 2/3 innings. They'll be handing the reins over to Brad Lidge who has better numbers than Dotel, although he is more prone to injuries given his mechanics. Beltran will now patrol center field with Biggio moving to left. It'll be interesting to watch Beltran negotiate the hill and flag poll at Minute Maid park. In the long run, since the Astros can't sign Beltran, it's a pretty risk move but an understandable one given that with aging stars like Kent, Biggio, and Bagwell, they need to win this year.

    Of course the A's desperately needed someone to fill out their bullpen having blown 14 of 27 save opportunities to date.

    In the meantime the Royals pick up three prospects:

  • C John Buck, 23. He was hitting .300 at AAA and will now be inserted as the starting catcher. His power numbers were much better in 2001 and he has been hampered by injuries since. He also has little plate discipline. He's a big guy with a slow release behind the plate so it'll be interesting to see if he sticks as a major league catcher or ends up in the Mike Sweeney mold assuming he develops as a hitter.

  • 3B Mark Teahan, 22. By all accounts he was the key to the deal. He'll be assigned to Omaha for the time being until Joe Randa can be traded. He was hitting .275 with 8 doubles in 20 games for Sacramento and earlier hit .335 for AA Midland. At this point he hasn't found his power and whether he develops it will determine whether the deal goes down as a good one for the Royals.

  • P Mike Wood, 24. He was putting together a solid season in Sacramento going 11-3 with a 2.80 ERA. He keeps the ball down and tops out around 90 mph. He'll immediately enter the starting rotation along with Grienke, Reyes, Gobble, and May. His H/IP ratio has never been stellar nor has his K/IP or K/BB ratios. Seems to me like more of a fourth or fifth starter if he sticks at the big league level.


  • Clearly, the strength of this deal for the Royals is the possibility that they've found three major league starters who are all cheap, one of whom may just end up being above average. At the same time it gives playing time to David DeJesus to see if he can develop into a leadoff hitter. While it doesn't get them any closer to contending over the next several years, it does allow them to save some money. It will be interesting to see if the Glass family now cuts the payroll back in the $35 million range next year since they're freed from the $9 million Beltran was earning and will be rid of the salaries of Grimsely, Stairs, Gonzales, and Randa. Given the pendulum swing back to the youth movement I would expect that to be the case.

    On a side note, perhaps the most ridiculous comment I heard this week was on a sports talk radio show where the host was criticizing Beltran as perhaps not a player the Royals wanted anyway since he has never won a batting title, MVP, or led his team to the playoffs. Clearly, this shows a lack of understanding in what it means to be a player that helps his team win. Over the last 3 and half years his OPS has been in the .875 range, he's the best defensive center fielder in baseball, and he's the highest percentage base stealer in history. The fact that he's not won playoff games with the Royals has no correlation to his skills or his contribution to the team. On any team that Beltran goes to next year he will immediately displace the current centerfielder.

    Thursday, June 24, 2004

    Jon Box and INETA

    Here's a nice little video of Jon Box talking about how to start a .NET User's Group. Good stuff Jon.

    Wednesday, June 23, 2004

    CF and Amazon Redux

    For another example of using the Amazon web services from the .NET Compact Framework see mobile guru Michael Yuan's blog. I did something similar several months back.

    Tuesday, June 22, 2004

    Ground Outs Galore No More

    Jason Grimsely is the second player to be moved since GM Allard Baird's announcement that he was selling off the team in parts. Grimsely was traded to the Orioles for minor leaguer Denny Bautista, a hard thrower with lots of potential who is only 23 years old (Baseball Prospectus had him listed as 21 with a birthdate of 10/23/82. I'm told he was another Latin player caught lying about his age). Baseball Prospectus liked him when he was thought to be 21, not so sure now (he's also a good friend or cousin of Pedro for what its worth) although he needs to develop some control - 70 walks in 137 innings last year and 33 in 62 2/3 innings this year. I'd put this trade in the win column for Baird.

    On the down side the Royals handling of the release of Curtis Leskanic seemed a bit strange. Although Baird swore to Leskanic it was a baseball and not a financial decision, it seems clear to most everyone (and Leskanic if the story in last Sunday's KC Star is accurate) that it was purely financially motivated since Leskanic was due to start earning roster bonuses that would eventually equal around $1M. In addition, Leskanic was throwing better and it seems like Baird might have been able to make a deal similar to the Grimsley trade if Leskanic could have been showcased and seen to be healthy again. Certainly Leskanic's age works against him in a trade scenario but it seems other teams already have an interest.

    Finally, my brother alerted me to this unusual statistic related to Grimsely. Here are his ground and fly outs and ratio since the stat started being tracked in 1999.

    
    
    Year Team GO FO GO/FO
    1999 New York Yankees 104 52 2.12
    2000 New York Yankees 145 89 1.74
    2001 Kansas City Royals 128 45 3.18
    2002 Kansas City Royals 107 45 2.53
    2003 Kansas City Royals 125 37 3.57
    2004 Kansas City Royals 55 6 9.83


    Grimsely has always been a ground ball pitcher and is therefore valuable in double play situations. His ratio typically ranges between 2 and 3, which of itself is quite high. However, I've never seen a ratio of 9.83. Although the same size is 26 and 2/3 innings, that's still remarkable.

    Monday, June 21, 2004

    Overheated Dell

    Ok, here's a new one. My Dell Inspiron 5100 has recently been acting a bit flaky. I first noticed that at various times one of the USB ports would stop working causing my mouse to fail or my Pocket PC to stop synchronizing. Over the last 5 days the machine has begun to intermiitantly power off completely. Not thinking I would find much I Googled the problem. Lo and behold I found this post on the Dell support site that led me to this site where the problem is fully documented.

    Turns out it's simply dust building up on the "bottom of the computer heatsink". I downloaded the cool little utilty mentioned on the site to monitor the temperature of the CPU and found that mine was running at 69 or 70 degrees Celsius, too high according to the site. I then followed the directions on the site, got out my little can of Endust Duster (compressed air) and blew it into the fan. A little cloud puffed out and I restarted the machine. The CPU temperature now fluctuates between 54 and 59 degrees most of the time. I noticed that the fan goes on high at 62 degrees. Looks like this will have to be done every couple weeks or so from now on...

    Wednesday, June 16, 2004

    Recent Publications

    Just a note on two recent articles in the Access VB*SQL Magazine. In the May issue my article "Get Set for ADO.NET Whidbey" was published. Unfortunately, it was written before the May Community Technology Preview version was released as well as additional information at TechEd. For a more up to date look see my DevEssentials talk.

    The other article is in the June issue and called "The Four Pillars of Smart Clients". Brielfy, this article looks at what you'll need to consider when building smart client applications. Let me know if you read the articles and what you think. All comments welcome.

    Thin Air and Coors Field

    I read an interesting summary of an academic article titled "atmosphere, Weather, and Baseball: How Much Farther Do Baseballs Really Fly at Denver's Coors Field?" in the November 2003 "By The Numbers" newsletter published by SABR. Interestingly, the authors of the article found that average fly ball distance at Coors Field was only 3% greater in the period from 1995-1998 when you take into account the larger dimensions at Coors and the prevailing winds which typically blow in. This is not even as great an advantage as Mark McGwire enjoyed in 1998 in St. Louis.

    As a result, the greater homerun rate per at bat (.044 at Coors from 1995-2002 versus .029 for other NL parks) is attributed to the impact of thin air on breaking pitches and low humidity making the ball harder and therefore more difficult to grip for pitchers.

    So it seems that perhaps the focus on how the ball carries at Coors has been overblown and the effect on pitchers underestimated. This also explains why Coors seems to affect some pitchers more than others.

    Tuesday, June 15, 2004

    Tools for .NET CF Development

    In our book we mentioned several tools such as Hopper that are now available from Microsoft. Generally, these tools help developers when debugging and dealing with devices. Briefly, the tools are:

    Emulator ActiveSync Connection Tool - Allows Activesync to connect to your Emulator session from Visual Studio .NET 2003.

    ActiveSync Remote Display - Display Pocket PC applications on your desktop or laptop without needing any device side configuration.

    CECopy - Command line tool for copying files to the device currently connected to desktop ActiveSync.

    Convert PPC DAT to SP XML - Command line tool for generating Smartphone CABWizSP XML docs from existing Pocket PC CAB files.

    Hopper - User input stress simulator.

    JShell - UI version of the Platform Builder Target Control Window.

    PPC Command Shell - Command shell for the Pocket PC 2003 device.

    RAPI Debug - Displays detailed information about currently running processes.

    RAPI Start - Command line tool to remotely start an application on your Pocket PC from your desktop.

    TypeIt - Send characters/strings to the Smartphone 2003 Emulator via ActiveSync.

    Thursday, June 10, 2004

    At TechEd 2004

    This year I was only at TechEd in San Diego for a little more than 24 hours. I flew in on Thursday morning and met up with Jon Box and Ron Hostetter. We had our picture snapped with .NET guru Noah Coad which he just posted on his blog. Jon and I then met with various Microsoft and publishing folks before working on our presentation. Immediately after the talk I ran for the bus and made it to the airport in time to fly home to KC. Definitely too short and hectic a trip. I won't schedule like that again.

    Reagan and Leadership

    During this week, we've all been bombarded with reflections of President Reagan. Not surprisingly, most of the remembrances have been fond ones. Watching the footage I’ve been struck by how plain spoken his speeches were. If you’re interested in a written portrait of Reagan that is easy to get through at just 260 pages you should check out the excellent book Ronald Reagan: How an Ordinary Man Became an Extraordinary Leader by Dinesh D’Souza published in 1997. I read it back in 2000 and cracked it open again this week.

    D'Souza is a conservative and author of the book The End of Racism published in 1995, which I would also recommend. He was a member of the administration in Reagan’s second term. From his first negative perception of how the White House was run he gradually grew in respect for Reagan and offers an analysis of Reagan’s leadership style and the important events of this presidency.

    In short, D’Souza concludes that Reagan had the three essential characteristics of a leader.

  • Vision. Although we forget, it was Reagan who had the vision to see that totalitarianism was not sustainable and would be placed "on the ash heap of history" and concentrated his policies to that end. D’Souza does a great job of reflecting the tenor of the times and shows how out of step Reagan was with the western intelligentsia who thought the Soviet economy and system were strong (perhaps more so than the west) and the doves who thought we should appease the Soviets with trade. The author also argues that calling for SDI was also an act of moral vision spurred by Reagan’s conviction that an ongoing nuclear arms race was immoral (and certainly MAD) and that the government was failing by not attempting to protect its people. Reagan’s critics refer to him as a man of few ideas and indeed the author shows him as a man unconcerned with details who delegated much authority, which eventually would come back to haunt him in the Iran/Contra scandal of 1987. But overall, it was his vision that kept the ship on course and that the American people responded to. D’Souza would agree with the critics but points out that they were the right ones and that he never wavered from them.


  • Action. Reagan took action in confronting the Soviets with the famous evil empire speech, the military buildup that brought the Soviets to the bargaining table, his tough approach at the table, and finally his cooperation with Gorbachev that led to historic reductions in nuclear weapons and his call for the dismantling of the Berlin wall. His actions in Grenada (the first rollback of communism since the Truman Doctrine was inaugurated) and Central America also flowed directly from his vision of liberty as the current of history. In addition, his decisive action against the air traffic controllers set the tone for his presidency. Although he can be rightly criticized for increasing the national debt he did so in order to win the cold war, a worthy goal and one he accomplished.


  • Consent of the governed. In the era of Clinton government by opinion pole became increasingly popular. Reagan on the other hand used opinion poles to understand how the public might react to his course of action. He then persuaded people to his views through his plain spoken convictions. D’Souza records how on several occasions (his trip to Bitburg cemetery, the air traffic controller’s strike, his refusal to sign a treaty on sea exploration, his bombing of Lybia, among others) Reagan took action despite the public’s likely negative reaction and then eschewed his speech writers preferring to write his remarks to the American people himself and usually bringing them around to his point of view. As many of those interviewed this week testified, D'Souza grounds this ability to communicate effectively in Reagan’s complete comfort with himself and his ideals and the fact that with Reagan, what you saw is what you got.



  • As I watch the funeral ceremony today I’m proud that Reagan was our president and hope that history’s verdict is that Reagan was a true leader in a time where a leader was required.

    Tuesday, June 08, 2004

    Impersonating Users in .NET

    I'm often asked how you impersonate a user in the .NET Framework. In an ASP.NET application it's as simple as setting the impersonate attribute of the identity element in the web.config file to true. In Windows apps its a little harder as you'll need to login as the user using a Win32 API function and then use the WindowsImpersonationContext object. Here's a class in VB .NET that you can use to get the job done.

    
    
    Imports System.Runtime.InteropServices
    Imports System.Security.Principal
    Imports System.Security

    Namespace Atomic.Security

    Public Class Windows

    Private Sub New()
    End Sub

    'Private Const NetworkLogon As Integer = 3
    'Private Const DefaultLogonProvider As Integer = 0

    _
    Shared Function LogonUser(ByVal userName As String, _
    ByVal userDomain As String, ByVal userPassword As String, _
    ByVal logonType As Integer, ByVal logonProvider As Integer, _
    ByRef token As Integer) As Boolean
    End Function

    Public Shared Function Impersonate(ByVal userDomain As String, _
    ByVal userName As String, ByVal userPassword As String) _
    As WindowsImpersonationContext
    Dim token As Integer
    If LogonUser(userName, userDomain, userPassword, 3, 0, token) Then
    Dim impersonatedToken As New IntPtr(token)
    Dim newIdentity As New WindowsIdentity(impersonatedToken)
    Dim impersonationContext As WindowsImpersonationContext = _
    newIdentity.Impersonate()
    Return impersonationContext
    End If
    Return Nothing
    End Function
    End Class
    End Namespace

    To use this code you could do the following:
    
    
    Dim wc As WindowsImpersonationContext = Windows.Impersonate("FoxAtomic", "dfox", "password")

    'Impersonate the user here to open a file
    File.Create("c:\windows\dan.txt")

    wc.Undo() ' Done

    A Single Instance of a Windows Forms App

    I noticed that on the Smart Client developer site on MSDN that Jonathan Wells answered the question regarding ensuring a single instance of a Windows Forms application. Awhile back I wrote a custom ApplicationContext class using ideas I read in an article I can't now locate. Anyway, here is the C# code for that class that allows you to pass a form and a flag to the Run method to disallow multiples. The default behavior is to disallow. This class uses the Mutex object as Jonathan mentions.

    
    
    using System;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Threading;
    using System.Runtime.InteropServices;

    namespace AppContext
    {

    public class AppCtx : ApplicationContext
    {
    [DllImport("user32")]
    private static extern bool SetForegroundWindow(IntPtr hwnd);

    private AppCtx()
    {}

    private static Mutex s_Mutex;

    public static void Run(Form mainForm)
    {
    run(mainForm,false);
    }

    public static void Run()
    {
    run(null,false);
    }

    public static void Run(Form mainForm, bool allowMultiples)
    {
    run(mainForm,allowMultiples);
    }

    private static void run(Form mainForm, bool allowMultiples)
    {
    if (!allowMultiples)
    {
    s_Mutex = new Mutex(true, Process.GetCurrentProcess().ProcessName);
    if (s_Mutex.WaitOne(0,false))
    {
    if (mainForm == null)
    Application.Run();
    else
    Application.Run(mainForm);
    }
    else
    {
    Process[] ps = Process.GetProcessesByName(
    Process.GetCurrentProcess().ProcessName);
    for (int i=0; i < ps.Length;i++)
    {
    if (ps[i].Id != Process.GetCurrentProcess().Id)
    {
    SetForegroundWindow(ps[i].MainWindowHandle);
    }
    }
    }
    }
    else
    Application.Run(mainForm);
    }


    public static void Exit()
    {
    Application.Exit();
    }

    }
    }


    The Main method would then look like so to disallow multiple instances of the app. Another great use of a custom app context would be to populate a custom IPrincipal object.
    
    
    using System;

    namespace AppContext
    {
    public class app
    {
    [STAThread]
    static void Main()
    {
    Form1 f = new Form1();
    AppCtx.Run(f,false);
    }
    }
    }

    .NET Tools

    There was a great article in this month's MSDN Magazine that listed some tools .NET developers should be aware of. In case you're looking for the links to those tools, here they are:

    FxCop (Code Analysis Tool)
    NUnit (Unit Testing Framework)
    Snippet Compiler
    Regulator
    CodeSmith
    .NET Reflector
    NDoc
    NAnt

    Sunday, June 06, 2004

    Historical Baseball Abstract

    This weekend I finally bought a copy of the revised version of the Bill James Historical Baseball Abstract. I bought the first version almost 20 years ago and thoroughly enjoyed it. This one is updated to include a complete section on the 1980s and well as the 1990s with new player rankings largely based on the Wins Shares statistic that James developed.

    Not 10 minutes after cracking open the book I ran into an essay that has immediate relevance to the Kansas City Royals. James notes that one of the most obvious truths of sabermetrics is that young pitchers with low strikeout rates don't have long careers. He goes so far as to say that there are no exceptions to this rule and sets the bar at 4.5 strikeouts per 9 innings historically. Further, the greater the rate above the threshold the more proportionally successful the pitcher is. In other words, a higher strikeout rate at a young age gives a pitcher more wiggle room as they age and loose their stuff. The reason this is the case is largely due to the discussion related to DIPS that I blogged about previously.

    This is relevant to the Royals because of their young pitchers Jimmy Gobble and Zack Grienke. Gobble, in 117 innings in the majors has a strikeout rate of 2.3. Grienke, in just 19 innings has struck out 7 (3.3 K/9 in). Obviously, Grienke's sample size is too small to draw any conclusions. Fortunately, his minor league rates were much better and struck out 23 in 28.2 innings at Omaha this year. Gobble, however, has a pretty decent amount of innings under his belt and doesn't look to be increasing his strike out rate over time. In short, I wouldn't look for Gobble to be a mainstay in the rotation for years to come.

    In another note Calvin Pickering at Omaha now has 18 homeruns in 150 at bats and has drawn 32 walks.

    DevEssentials Conference Material

    I had a great time presenting twice at the DevEssentials conference at Crown Center in Kansas City this weekend. Thanks to John Alexander, who did a great job in organizing the event. It was also good to meet Scott Ambler and Brian Noyes among others.

    The code and powerpoint from my presentation on Whidbey and ADO.NET can be found on our Atomic site here.

    Now I'm off to Kentucky to teach more .NET...

    Friday, June 04, 2004

    Interleague Play Begins Monday

    In 1997 Major League Baseball began interleague play. This year 252 interleague games will be played in three separate time frames in June and early July. While at first I was concerned that it would take away from the mystique of the All-Star game (it has) and World Series (it hasn't) its' success in generating interest in the game has offset any negatives. Average attendance since 1997 at interleague games is 32,676 up 14.3% over regular games. Two different years the Cubs played the Royals here in KC and in one series I remember Sammy Sosa hitting three homeruns in 2 days while Johnny Damon had 5 hits to beat the Cubs in one of the games.

    This year the NL Central will play the AL West and the AL Central plays the NL East. That means that the Expos and Mets will come to Kauffman stadium along with the Cardinals who the Royals always play because of the intrastate rivalry and the Royals will travel to Atlanta and Philadelphia. Meanwhile the Cubs will travel to Anaheim to play the Angels on the next road trip and play the A's at home and then play a home and home series with the White Sox.

    Over the first seven season the NL holds a slight edge 863-833 although the A's have the best record at 75-38. The worst record belongs to the Devil Rays at 38-68. The Royals are 51-70 while the Cubs are 52-51.

    Full Count Pitch Outcomes

    One of the wizards of retrosheet David Smith posted the following interesting items on the SABR list yesterday.

    This first table shows how the outcomes of pitches differ in full count (3-2) situations versus no full count situations for 2004 in games through June 2.


    Not 3-2 3-2 count
    Pitch No. % No. %
    C 38548 17.2 463 4.5
    F 34908 16.6 2875 28.2
    X 41248 19.7 3414 33.5
    B 83681 37.8 2270 22.3
    S 18619 8.7 1157 11.4
    217,004 10,179


    C = called strike
    F = foul ball
    X = hit into play
    B = ball
    S = swinging strike

    You'll notice that not suprisingly batters swing more often with two strikes (F+X+S), 74% at 3-2 and just 45% otherwise fouling off more pitches and swining through more pitches.

    In this table you see the outcomes when the pitch count to a particular batter goes over 6 pitches. I was suprised the averages were so low since it seems like there are more good outcomes when the batter sees lots of pitches. Only on pitches 9 and 11+ do you see significantly better production than normal and at that point the sample sizes are starting to shrink. Of course, the high OA (on base average) is accounted for since in most cases at 6 or more pitches the batter will already have a 3 ball count.

    Pitches Times BA OA SA
    6 4067 .217 .462 .344
    7 1909 .220 .471 .369
    8 809 .212 .443 .336
    9 338 .271 .467 .478
    10 114 .217 .430 .349
    11+ 69 .286 .545 .679
    Total 7306 .220 .462 .358
    All .265 .336 .423

    Thursday, June 03, 2004

    Prospecting in the Smoky Hills Chalk

    As we had done last August my daughter and I took a trip this spring to the Smoky Hills Chalk for a day of fossil hunting with Chuck Bonner owner of the Keystone Gallery. We were in Hays Kansas visiting with my wifeƂ’s sister's family and so we were only 110 miles or so from the gallery. Actually, we were in the westernmost part of the Smoky Hills region, the Niobrara Region, composed of late Cretaceous chalks laid down in inland sea some 70 millions years ago that stretched from the Gulf of Mexico to Canada. The chalk is made up almost entirely of the remains of microscopic marine plants and animals that lived near the surface and later sank to bottom covering the remains of dead and decaying clams, fish, marine reptiles, flying reptiles, birds, and even an occasional dinosaur washed out to sea.

    Laura and I drove from Hays to Scott Lake State Park just a few miles south of the gallery on a Sunday evening so we could camp and get an early start on Monday morning. We were wondering what the lake would look like since the land is very flat and treeless for as far as the eye can see. However, as we rounded a small knoll the road dropped sharply into a canyon at the bottom of which was the lake surrounded by trees and nestled in the beautiful canyon. As soon as we saw the lake we wished we had gotten there earlier so that we could enjoy the lake and take walk through the canyons. However, we quickly pitched our tent as it was getting dark and enjoyed our supper of beef jerky, bananas, pop tarts, and water before settling into our sleeping bags with wrapped in multiple layers of clothing in the hopes of staying warm. Before dozing off I cracked open my copy of Charles Sternberg's The Life of a Fossil Hunter (bought early in the weekend at the natural history museum named for his son George in Hays) written by Sternberg in 1909, who hunted fossils for E.D. Cope in the same area back in the 1870s. After reading Sternberg's tales of trying to find fresh water and encountering Indians I was glad to be cozy and warm and able to fill up our bottles at the water fountain. Of course, along with his hardship he also was able to collect large and fairly complete specimens since he was among the first to prospect in the area.

    We both awoke before the alarm went off at 5:50AM due to the brisk temperature in the 40s and were glad when the appointed hour came. We quickly struck our little camp and headed for the gallery 10 miles or so north of the lake. On the way out of the park we saw six white tail deer through the early morning mist that had come down to the lake to drink.

    By 6:45AM we were pulling into the gallery, greeted as before by their big dog Shiloh. As we stepped out of the Jeep we got a warm welcome from the rooster. Chuck was just getting up and invited us in to the kitchen. He quickly lit the burner on their wood stove and was soon making "cornycakes" (thin pancakes with corn) and a fried egg for each of us. We appreciated the delicious, not to mention warm, food and drink and were shortly outside packing our gear into his 1949 Suburbun affectionately nicknamed "Spiker".

    We were soon headed a mile or so north of the gallery to a pasture that contained what Chuck had named "hidden canyon". We disembarked and headed down into the canyon. It had rained the several days before and so the bottoms of the canyons were somewhat muddy. However, the wet rock allowed the fossils to be more prominent (a point Sternberg makes in his book as well) as the fossils stand out against the chalk. This, in addition to our previous experience made finding fossils much easier than last August.



    It wasn't long before Chuck had spotted a string of fish vertebrae (probably Cimolychtes) eroding out of the surface of the chalk near the bottom of one of the little canyons. The matrix was quite crumbly and it's likely the fossils would have broken apart had we tried to remove them. So we marked the spot and kept searching.



    Laura and I broke off and searched a bit on our own. Laura's eyes were especially keen and she was easily able to pick out small fish vertebrae, ribs, and scales that were abundant and she had a good time filling her collecting pouch with these treasures. As always there were lots of clam shell fragments with their characteristic oysters. And just as last August the canyons were full of swallow's nests. This time we were too early to see them but did run into a variety of small lizards.



    By mid-morning we had made our way through several of the smaller canyons and were examining a gently sloping hill when Laura found more fish vertebrae. Here Chuck and Laura work to see what remains of the creature. Typically, the procedure is remove the rock above where the fossil sits in order to see how far back into the hill the fossil goes and to determine if the head end is still in the rock. In this case the head had already eroded out of the rock and so we collected some of the vertebrae and moved on.



    It wasn't 10 minutes later as were then walking down the slope of the hill that Chuck mentioned that he'd like to find some reptile bones. As he finished his sentence he looked down, pointed, and said "Like those!" Upon further inspection he had found arms bones of a pternandon sticking out of the rock.



    Not wanting to disturb the fossil, he walked back to Spiker to retrieve his shovel and proceeded to remove dirt and rock above the fossil to see if more could be found. He didn't remove what was there the day we were along but noted that he would come back and finish the job later. After scouting the area for a few more minutes we headed back to Spiker for a satisfying lunch of sandwiches, pop, apples, and chips.



    After lunch we set off again into a part of thecanyone we hadn't yet explored. On the very bottom where the canyon led out into the pasture it was grassy and we could see lots of large bones littering the ground. Their bleached appearance made it obvious they were of more recent vintage. In all we found leg, vertebrae, skull, scapula, and other odds and ends of a buffalo that had apparently been killed or scavenged by coyotes as the teeth marks in the bones made apparent. We were able to locate one of the horn cones and took it and a vertebrae home with us.

    After re-entering the canyons and climbing up a small knoll I noticed several large vertebrae weathering right beneath my feet. There were four or five loose vertebrae as well as some other pieces in the loose dirt. I called Chuck over and began to excavate the layer in which the bones sat. After examining some of the loose pieces which included part of the jaw and few small teeth, Chuck noted that it might be a 6 to 8 foot Ichthyodectes ctenodon. The four vertebrae we kept were characteristically spool shaped and measured several inches in diameter.



    We didn't have time dig out the rest but Chuck was going to return and see what else he could find.

    We had plans to pick up the rest of the family in Hays and drive back to Kansas City that evening so by 1:30 we had to head back to the gallery. On the way we stopped along the fenceline to look at the buffalo herd in the next pasture. There were about 200 head altogether and many of the females were pregnant. Several of the animals also wallowed in the dirt for us but were uninterested in the Doritos we tried to coax them with.

    All in all it was a fabulous day with great weather and good company. Although we didn't find that elusive mosasaur (like the one in the picture below) our spirits weren't dampened and we're ready to try again someday.







    Wednesday, June 02, 2004

    Windows XP Service Pack 2 and the Windows Firewall

    At TechEd (DEV370) Jon Box and I discussed programmatically manipulating the Windows Firewall so that you could write code to prompt the user at install time to add the application or its ports to the application permissions list. This is important on boxes with SP2 since the firewall will be on by default. As a result any application that accepts inbound connections (without first making an outbound connection to the host) will have their communications blocked.

    Unfortunately, in the RC1 version the type libray that you'll need for creating objects to manipulate the firewall are not created for you. This means that you either have to create a factory class to handle it or create your own type library using the MIDL compiler over the NetFw.h file in the SDK.

    In the talk we showed a factory class that Jon wrote that creates the INetFwMgr object that is the entry point into managing the firewall, the INetFwProfile object used to manipulate profiles, the INetFwAuthorizedApplication object to handle adding applications to the permissions list, and the INetFwOpenPort object used to add a port to the permissions list. The sealed class looks as follows.

    
    
    Public NotInheritable Class XPSP2Wrapper

    Private Sub New()
    End Sub

    Public Shared Function GetFwMgr() As NetFwTypeLib.INetFwMgr
    Dim oINetFwMgr As NetFwTypeLib.INetFwMgr
    Dim NetFwMgrObject As Object
    Dim NetFwMgrType As Type

    ' Here's how you use the COM CLSID to get the associated .NET System.Type
    NetFwMgrType = Type.GetTypeFromCLSID(New Guid("{304CE942-6E39-40D8-943A-B913C40C9CD4}"))

    ' Create an instance of the object
    NetFwMgrObject = Activator.CreateInstance(NetFwMgrType)
    oINetFwMgr = NetFwMgrObject

    Return oINetFwMgr
    End Function

    Public Shared Function GetProfile() As NetFwTypeLib.INetFwProfile
    Dim oINetPolicy As NetFwTypeLib.INetFwPolicy
    Dim oINetFwMgr As NetFwTypeLib.INetFwMgr

    'Get FwMgr COM object
    oINetFwMgr = GetFwMgr()

    'Create object representing Local Policy
    oINetPolicy = oINetFwMgr.LocalPolicy
    Return oINetPolicy.CurrentProfile
    End Function

    Public Shared Function CreateAuthorizedApplication() As NetFwTypeLib.INetFwAuthorizedApplication
    Dim oComObject As Object
    Dim oType As Type
    Dim oIAuthApp As NetFwTypeLib.INetFwAuthorizedApplication

    'Here's how you use the COM CLSID to get the associated .NET System.Type
    oType = Type.GetTypeFromCLSID(New Guid( _
    "{EC9846B3-2762-4A6B-A214-6ACB603462D2}"))

    ' Create an instance of the object
    oComObject = Activator.CreateInstance(oType)

    'cast to proper interface
    oIAuthApp = oComObject

    Return oIAuthApp
    End Function

    Public Shared Function CreateOpenPort() As NetFwTypeLib.INetFwOpenPort
    Dim oComObject As Object
    Dim oType As Type
    Dim oIOpenPort As NetFwTypeLib.INetFwOpenPort

    'Here's how you use the COM CLSID to get the associated .NET System.Type
    oType = Type.GetTypeFromCLSID(New Guid( _
    "{0CA545C6-37AD-4A6C-BF92-9F7610067EF5}"))

    ' Create an instance of the object
    oComObject = Activator.CreateInstance(oType)

    'cast to proper interface
    oIOpenPort = oComObject

    Return oIOpenPort
    End Function

    Public Shared Function GetStatusDesc( _
    ByVal status As NETCONLib.tagNETCON_STATUS) As String

    Select Case status
    Case NETCONLib.tagNETCON_STATUS.NCS_AUTHENTICATING
    Return "Authenticating"
    Case NETCONLib.tagNETCON_STATUS.NCS_AUTHENTICATION_FAILED
    Return "Auth Failed"
    Case NETCONLib.tagNETCON_STATUS.NCS_AUTHENTICATION_SUCCEEDED
    Return "Auth Succeeded"
    Case NETCONLib.tagNETCON_STATUS.NCS_CONNECTED
    Return "Connected"
    Case NETCONLib.tagNETCON_STATUS.NCS_CONNECTING
    Return "Connecting"
    Case NETCONLib.tagNETCON_STATUS.NCS_CREDENTIALS_REQUIRED
    Return "CredReq"
    Case NETCONLib.tagNETCON_STATUS.NCS_DISCONNECTED
    Return "Disconnected"
    Case NETCONLib.tagNETCON_STATUS.NCS_DISCONNECTING
    Return "Disconnecting"
    Case NETCONLib.tagNETCON_STATUS.NCS_HARDWARE_DISABLED
    Return "Hardware disabled"
    Case NETCONLib.tagNETCON_STATUS.NCS_HARDWARE_MALFUNCTION
    Return "Hardware malfunctioned"
    Case NETCONLib.tagNETCON_STATUS.NCS_HARDWARE_NOT_PRESENT
    Return "Hardware not present"
    Case NETCONLib.tagNETCON_STATUS.NCS_INVALID_ADDRESS
    Return "Invalid Address"
    Case NETCONLib.tagNETCON_STATUS.NCS_MEDIA_DISCONNECTED
    Return "Media Disonnected"
    End Select

    End Function

    End Class

    We then use the factory methods in private methods within a Windows Installer class (inherited from Installer) that adds and removes an application from the permissions list.
    
    
    Private Sub AddToPermissionsList(ByVal name As String, ByVal imageName As String, _
    ByVal enabled As Boolean, ByVal profile As INetFwProfile)
    ' Add the application to the Windows Firewall Permissions List

    Dim app As INetFwAuthorizedApplication = XPSP2Wrapper.CreateAuthorizedApplication

    app.Enabled = enabled
    app.Scope = scope
    app.Name = name
    app.ProcessImageFileName = imageName
    profile.AuthorizedApplications.Add(app)
    End Sub

    Private Sub RemoveFromPermissionsList(ByVal imageName As String, ByVal profile As INetFwProfile)
    ' Remove the application from the Windows Firewall Permissions List
    profile.AuthorizedApplications.Remove(imageName)
    End Sub

    These methods are called from the overridden Uinstall and Install methods. For example, the Install method of the installer class calls a private GetArgs method that collects the arguments passed in through the CustomActionData property and then uses the arguments to add the application to the permissions list. The arguments are collected from custom dialogs in the setup application that ask the user if the application can be added to the permissions list.
    
    
    Public Overrides Sub Install(ByVal state As IDictionary)
    GetArgs()
    MyBase.Install(state)

    Dim objV4Mgr As INetFwMgr

    Try
    objV4Mgr = XPSP2Wrapper.GetFwMgr
    Catch ex As Exception
    ' Could not instantiate so perhaps not running XPSP2
    Context.LogMessage("Could not instantiate NetFwV4Mgrclass [" & ex.Message & "]")
    Return
    End Try

    Try
    ' Add the application to the permissions list
    AddToPermissionsList(name, image, appEnabled, _
    objV4Mgr.LocalPolicy.CurrentProfile)
    Catch e As Exception
    Context.LogMessage(e.Message)
    Throw New InstallException(e.Message)
    End Try
    End Sub

    Of course the user running the installation application must be logged on as an Administator on the box.

    Infield Fly Redux

    Ok, after posting this play to the SABR list I received several clarifications that helped me to understand the situation.

    1. Sweeney does not get a sacrifice fly since under normal circumstances under rule 10.09 a sac fly is only awarded if in the scorer's judgement the runner could have scored without the error or misplay. Normally, I would agree that on an infield fly you're not going to score. However, the play was more difficult than most infield flys and the fielder had his back turned to the infield. In any case, a sac fly would typically not be awarded.

    2. See #1

    3. Mientkiewicz did end up getting credited with an error which allowed the run to score.

    4. No, Sweeney does not get an RBI since the run scored on the error. The run is now also unearned since the third out was made on the play.

    5. No, the Twins don't get a double play since according to rule 10.12 "an error or misplay intervenes between putouts"

    6. No, Beltran did not have to return to first. The rule is a bit confusing on this point since it does say that runners have to retouch after the ball is touched. Apparently, the touching here refers to bobbling the ball and the phrase "the same as on any fly ball" means that the runners are free to advance as long as the ball is not caught or tag up after the ball is caught. It should probably be amended to say "or retouch and advance after the ball is touched and ultimately ruled caught" since simply touching the ball does not require them to return and retouch. The phrase "the same as on any fly ball" doesn't really get across the fact that it must be caught in order for the preceding clause to apply.

    Hoping for smoother sailing this weekend when Boston comes to town.

    Tuesday, June 01, 2004

    More on the Infield Fly

    I was alerted to this story on mlb.com regarding the play I blogged about. My understanding and from talking with folks in the press box is that the story is incorrect. Beltran did have to go back to first since the ball was touched per the infield fly rule ("or retouch and advance after the ball is touched, the same as on any fly ball"). That means that Jones did not have to tag Beltran but merely step on first. The double play is not awarded since the ball was dropped which constitutes a "misplay" per the rules ("unless an error or misplay intervenes between putouts").

    I also see that Sweeney's RBI was taken away and that Mientkiewicz was charged with an error to account for Relaford scoring on the play.

    I did like the comment by Mientkiewicz though.

    "I think I'm mentally dumber now than I was before the game. I know less about the game now than I did before this game started."