Tuesday, September 16, 2008

Meghan McCain: Cajones, Chutzpah, and Sisu

Sept 15, 2008
Larry King Live Interview with Meghan McCain
CNN News Network

Today Meghan McCain appeared on the Larry King Live show to do something that our presidential nominee could not... be interviewed by old man Larry King. Chutzpah! Cajones! Sisu! That upstaging little.... The story goes that after a tough interview from CNN's Campbell Brown
of McCain spokesperson Tucker Bounds, the McCain camp decided to punish the liberal media by pulling their scheduled interview with, of all people, Larry King. (see the transcript of the Bounds-Campbell interview). I thought this was silly, but no big deal until I checked to see who was on Larry King, and it was someone named McCain, but not John! I would have normally flipped to analysis of Monday Night Football instead of watching some politician's book peddling daughter on Larry King, but NO. McCain had to dodge Mr. King thrusting untold and unwarranted relevance upon this crummy interview. In all honesty, I think that this single moment of sheer pain, even dare I say ... cruel and unusual punishment, at the expense of McCain's transference of all balls to his daughter is enough to make me reconsider my original view on John McCain. This is the man who would not leave the Hanoi Hilton before it was his turn; a man that volunteered to serve his country and nearly gave his life on several occasions in facing an unrelenting, vicious enemy. This is the man that can't face Larry King? The man whose daughter had no problem whatsoever facing Mr. King?

Senator McCain, this is a farce. I expect my president to face down any man, woman, or alien bent on destroying the earth... whomever! Can you not face the left via one of their major outlets, and at least attempt to convince the liberals that you can save our country? In all reality, what did you have to lose by appearing on Larry King senator? The independent vote?

*sigh* I feel better ... now, it's a bit unfair to say that McCain fears Larry King; in fact, the senator from Arizona has appeared on Larry King several times in the past. His latest interview was even as the presumptive nominee only 2 months ago (7/28/08). So, was that interview really tough? Did Mr King bring the tough questions about the economy and the Keating Five? No, he actually asked about a melanoma McCain had removed recently, and followed up with questions in McCain's strong suit of foreign policy. King's questions on Iraq/Afganistan lasted a brief two minutes; after that, King gets into the really really hard questions: "Who's your VP?, Will you tell us before the Olympics?" etc.... which brings us to an interesting exchange:

Larry King: "How close are you? [to selecting a VP]"
John McCain: "well I wanna say that that vice presidential candidate will be on your show, I will not risk the wrath of Larry King I assure you."

This was said with a laugh, but when looking at this from the context of the question, "why not take a Larry King interview?" begs the analysis: either they're friendly and both think King is a relatively soft interview, or we have the real reason Senator McCain dodged the interview. Now, let's not be silly, McCain has been on the show many times, and he obviously doesn't fear Mr. King or the content and voracity of his average interview. The only plausible excuse is that McCain really did want to punish CNN. If this is in fact true, then senator, you are acting like George Bush and I beg that you stop now! The "we're not going to talk to them because they're too mean," thing hasn't worked out very well for us recently. If you're out there somewhere listening to the regular guy senator, hear this loud and clear: "DO THE KING INTERVIEW OR ELSE YOUR DAUGHTER IS MORE FIT TO BE PRESIDENT!"

Wednesday, September 10, 2008

Shame on you Blogger.com

You have failed to provide the tools necessary to blogger/developers trying to publish readable formatted source code to their blogs! There is, of course, nothing in the help about it and very little information elsewhere. If you saw my last blog, then you know I figured it out... so of course I will share with you :).

The key to getting code looking good on your blog is in editing your Layout html. There are various tools for generating nicely formatted HTML out of source code, but they typically require you to add the CSS to your layout manually. Here is a step-by-step of how I did it.

  1. Go here and generate your HTML. Make sure to check the "embed stylesheet" option.
  2. In the outputted HTML, grab everything between the <style type="text/css"> and </style> tags. This is your CSS.
  3. Click the 'Layout' tab here on Blogger.com
  4. Click the 'Edit HTML' tab that comes up under 'Layout'
  5. Paste your CSS (from manoli.net) inside of the <head></head> tags
  6. Save you customized layout
  7. You're almost done! Take the rest of the information from your generated html and paste it directly into your blog.
  8. Finally, in order to protect the text inside of the code from stange formatting and cutting, place these tags around your source code in the blog:
    1. <pre style="background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>
    2. YOUR FORMATTED CODE GOES HERE
    3. </code></pre>

That should do it for ya! Follow this example for other sites that use custom CSS. just insert their (or your) CSS into the layout and it's available for use in your blog! Thanks are owed to:

http://formatmysourcecode.blogspot.com/
http://mygreenpaste.blogspot.com/

Win32 SendInput API With C#

In a recent project, I came across the task of simulating user input using C#. There are several way of doing what I was attempting, but nothing seemed reliable when interacting with another thread. Enter: my old friend SendInput, part of the user32 library. I searched high and low for a wrapper class that would save me the several hours of implementation and testing I saw rising in my future, but to no avail! You mean to tell me no one has been kind enough to write a wrapper and share it with the "special needs" programmers of the world?

*sigh* alright, well here it is.

I wrote my wrapper around the idea of a virtual keyboard and mouse. Though it's by no means complete and comprehensive, it does work. If there is obvious interest in it, I'll spend a day making it all pretty and robust. Let me know. ;).

File: VirtualInput.cs
File: VirtualInputExample.cs

Below is the source for VirtualInputExample.cs to illustrate how much more fun it is to work with a wrapper class instead of the unmanaged SendInput directly.

Please note that I've left out the include statements here, in the example .cs file the includes are actually there. Just note if you are copy/pasting this, you need to include System.Diagnostics and VirtualInput. Also, you will need a reference to System.Drawing in your project in order to use VirtualInput.cs (datatype Point).

// create a virtual mouse and keyboard
VirtualKeyboard vk = new VirtualKeyboard();
VirtualMouse vm = new VirtualMouse();

// find the Notepad process(s)
Process[] pNotepad = Process.GetProcessesByName("notepad");

// no notepads?
if (pNotepad.Length <= 0)
throw new Exception("Could not find Notepad.exe");

// grab window handle off of the notepad process
IntPtr hNotepad = pNotepad[0].MainWindowHandle;

Console.WriteLine("Press enter to test.");
Console.Read();

// click the notepad, bring it to front, you can also do this by:
// VirtualInput.UnmanagedCode.SetForegroundWindow(hWnd)
vm.ClickClient(hNotepad, VirtualMouse.MOUSE_CLICK_TYPE.LBUTTON);

/* take note, we send in uppercase characters, but they get typed as lowercase
* because all VirtualKeys (VKs) are lowercase! */
vk.Keystroke("THIS IS ALL LOWERCASE!");
vk.Keystroke(Constants.VK.RETURN);

/* note, this is how you would type in uppercase ... makes sense no?
* as an aside: one might extend the VirtualInput class to have a method
* UppercaseKeystroke that would send Shift down, keystroke, shift up,
* as I do here */
vk.KeyDown(Constants.VK.SHIFT);
vk.Keystroke("this is all uppercase!");
vk.KeyUp(Constants.VK.SHIFT);

/* think outside of the box, and you can really do quite a bit combining these
* objects. here I'll right-click the client bringing up the context menu, then
* press Down 5 times to end up highlighting the "Select All" menu item before
* pressing enter. This is like pressing CNTL-A */
vm.ClickClient(hNotepad, VirtualMouse.MOUSE_CLICK_TYPE.RBUTTON);
for (int i = 0; i<6; i++)
vk.Keystroke(Constants.VK.DOWN);
vk.Keystroke(Constants.VK.RETURN);

/* speaking of hotkeys (CNTL-A), how about an example of that?
* here I'll send CNTL-X which is Cut. Try pasting (CNTL-V) after the cut is done
* if you want to confirm everything was typed, selected, then cut */
vk.KeyDown(Constants.VK.CONTROL);
vk.Keystroke('x');
vk.KeyUp(Constants.VK.CONTROL);

Tuesday, September 9, 2008

Barrack Obama Faces Bill O'Reilly and the Educated Right

Sept 4, 2008
Bill O'Reilly's Impact Segment with Barrack Obama
The O'Reilly Factor, Fox New Network

Last Thursday, Bill O'Reilly finally got his chance at Democratic Presidential Nominee Barrack Obama. On Saturday, Jan. 5th, O'Reilly "famously" scuffled with an Obama staffer and got a few words in with the Senator from Illinois. Both O'Reilly and Obama were congenial, and a handshake agreement was formed between the two. Obama would appear on "The Factor,:" or be mercilessly skewered by the media. In all fairness, had Obama dodged this interview he would have deserved every attack (they had actually already started). So, still to my amazement, Obama appeared on a hostile network and confronted their most pronounced champion.

First, why the surprise? Some people claim most dubiously that Fox is not slanted one way or the other. Some even claim it's "fair and balanced," so I will go ahead and preemptively write about why in this particular case Obama went out on a limb. To begin, I have to explain my current view of the mainstream media. There is a sort of "spectrum of truth," that exists in the media. I believe this is a sociological issue, and not a money issue, but nonetheless it's an issue. There are three distinct categories as I see them: Left, Educated, Right. Being on the left or the right forces one to really polarize to that side. Over time a network has to defend the networks stances albeit as "independently" as possible. In the case of the educated, I believe there is a large segment of the population that has received higher education which leads to exposure and liberalism. That's a discussion for another day, but the point is that I think this "educated" class really flows towards whatever ideologically makes sense for the country. One possible supporting fact is the rise of Ron Paul who seems almost libertarian in his views in a modern political context. Ideologically, Paul's stance is decent, but in reality it's comparable to a literal interpretation of the Bible... It's just not practical. In the end, the idea is that the "educated" class can swing either direction. Right now, "educated" equates to "liberal," and the polarizing affect of the lean itself coupled with the ultra polarized "Bush Zone" has caused the middle segment to be clearly left. Here's a quick summary of what I just wrote:

  • In the current climate, there will always be media outlets with interests leaning left or right: there are outlets on the left and on the right.
  • These networks compete on an open market, so they reasonably normalize on the left and right.
  • The lean is therefore determined in a large part by the networks that try to remain truly independent. I call this group the "educated" group.
  • Currently (and for decades now) the "educated" group has been on the left, therefore, the media is somewhat overall liberally biased.

The liberal media: MSNBC(Left), CNN(Left), CSPAN(educated), Fox(Right), ABC(Right)
(watch Rupert Murdoch, Head of Fox discuss this topic here)


So, Obama ventured away from the safe havens of CNN and NBC and boldly walked into the lion's den. He promised an interview "after the primaries," and he has delivered. Now on to the meat!

Interview on Foreign Policy : Summary / Analysis

O'Reilly does the right thing in congratulating Obama on being a man of his word at the onset of the interview. It seemed genuine, and I believe O'Reilly knows he pulled a big one for his one career and integrity. The niceties were short lived though, as O'Reilly went straight to the point: his concern over Obama's national security qualifications and views.

"Do you believe we are in the middle of a war on terror?"
"Who is the enemy?"

These were the warm up questions which Obama easily handled with a contrite, "Absolutely" and a short but distinctive description of radical terrorists. Obama conspicuously left Iran and North Korea off of his list of enemies in the war on terror. I personally believe this was the right move. America has enough problems now dealing with the Iranians, we don't need to sabotage future relations in the case that Obama does get elected. Obama certainly alludes to this sort of affect when O'Reilly later challenged him on whether he would "prepare to attack Iran." Obama smoothly noted that it would be somewhat ill advised to discuss specifics of an attack on Iran/Pakistan/whomever at this point for anyone especially a presidential candidate. Still, the right continues to look at North Korea much differently then they do Iran, and it is worth noting. The discussion stayed on the middle east, and reached a boiling point where liberals and conservatives typically cross swords on this topic: terrorism links.

What Obama said was basically that Iran is clearly a threat, but obviously not the same threat that produced 9/11. He partially based his argument on the differences between Sunni and Shia Muslims. (note: Sunni countries/militants responsible for 9/11) Simply stated, most Muslims are Sunni, and believe that their leaders should be elected, while the minority Shia believe in a monarchistic system. with 85% of the Muslim population claiming Sunni. This was (at least the initial) impetus for the divide within the Muslim faith, but is now totally moot. What matters is that Al Qaeda is Sunni, while the Iranians are mostly Shia. Their hatred for each other, whether politically or religiously founded, means that they are certainly not cooperating to beat up on America. Iran is taking advantage of the situation in Iraq to try and ensure Shia control in one the of last viable battlegrounds for the Shia. According to the CIA Factbook, Iraq is 65% Shia. Only Iran, Azerbaijan, Iraq, and
Lebanon (in that order) have a Shia majority. What does this mean for us? It means Iran's stake in Iraq revolves around their need to establish another Shia nation in the middle east.
(source: CIA Factbook estimates circa 2005 via wikipedia)

Obama's insights into the middle east and the religious forces in play there were a direct contrast to the past administration's obvious bungling of Iraq, and was a definite win for him during his interview. In the end it came down to the nuke question, and Obama said what he's always said, that nukes change the game and must be respected accordingly. This is the idea that highlighted the importance of the "prepare to attack Iran" scenario, and the silent promise is that preparations will be (if they haven't already been) made. The real question is whom do we trust to decide whether we're too close to "WMD" in Iran or not?

Later, O'Reilly questioned Obama on his stance on the surge after calling him perspicacious regarding the vote to stay out of Iraq. O'Reilly tried to corner Obama into admitting a mistake in not supporting the surge. I think this was a big loss for Obama, not because he was wrong on the issue, but because he failed to communicate how his stance might have been constructive. In other words, Obama, for once, lost points because he wasn't quick enough to formulate a strong response. One such response might have been that opposition is extremely important in politics. One must stand up for their beliefs regardless of the situation. The surge may have been a good idea in practice, but in theory it would have been a flip-flop in relation to Obama's initial position in opposing the war. Obama opposed the war, but we still went. Obama opposed the surge, but it still happened. In both cases he had an obligation to vote based on his ideals, and not on the political consequence. One might argue that in this case, the political and ideological choices overlap and I would agree, but that does not mean the choice was made for political reasons. I would respond that Obama's initial opposition to the war supports the idea that Obama acts based on ideals and nor politics. So why not admit he was wrong on the surge? Because he doesn't think he was ideologically. He very well might have thought the surge was a practical solution, but as part of a legislative body his job is to represent the ideals upon which he was elected. As president, his job would be to do what is best for America, and that might have meant supporting a surge. In any case, dissent plays an important role in democracy, and regardless of the result of the action in practical terms, Obama maintains the right to disagree with the action on an ideological basis.

Finally, O'Reilly tested Obama on Pakistan. The Pakistani situation has, I've thought, always been a strong point for Obama. He stood his ground, but promised more of the same sort of dealings we've had for years. Recently, a US official was attacked in Pakistan, so more of the same there doesn't seem like the greatest idea.

Report Card:

  • Iraq: B-
    • right in the beginning, stuck sticking to his guns on the surge
  • Iran: A-
    • smart, and seemed educated on the pre-reqs for dealing with the middle east
  • Pakistan: C+
    • par performance
  • National Security:
    • Incomplete
  • Debate:A
    • missed A+ for stuttering and missing on Iraq, handled O'Reilly rudeness well
  • Overall: B+
    • good performance with room to improve later