The advertising above is just a source of revenue. If the ads get offensive enough, I may drop them.
Clayton Cramer's BLOG
Clayton's commentary on news and events of the day. Broadly speaking, I'm a conservative with libertarian sympathies (getting more conservative as my children get older).
My nephew Shippy makes very pretty ceramic items. Click here to visit his online studio. Give someone one of these, and you can be sure that they don't already have one!
Click here to find out why the Amazon.com Honor System paybox is no longer here.
Search only this site: Click here and enter your search string at the beginning of the search field.
Email me at blogmail at claytoncramer dot com. Sorry to be so indirect, but all spambots must die! But they haven't died yet! Include the word spamIamnot in your subject line to make sure that my spam blocker lets you through.
Saturday, September 06, 2008
C#/.NET Question
There has to be an easy way to put up a message window--and then take it down again without waiting for a user input. It is probably a function that you call that returns a handle, and then when you are ready to take the window down, you do something with that handle. I thought that there might be a MessageBox option that does this, but I couldn't find it. Any hints?
I certainly won't claim that I have learned everything that I need to learn about graphics in C#, but I had reached a point with that plotting program when I had resolved all my concerns about event related stuff, and I had at least a rough idea how various display functions work.
I'm now writing a program that is a bit less graphical, but exercises many of the other facilities of C# and .NET. It reads in a web page, determines all the links to other pages (and names within the current page), and verifies that they can be opened. This is the broken link detector--often useful if you link to lots of other pages, and those links break.
In addition, it will be recursive within a particular domain. If I tell it open www.claytoncramer.com/index.html, it will try to open all links to pages at or below www.claytoncramer.com, then repeat the process for each of those pages. It will stay at or below the level of the original web page, otherwise it would take a very long time to complete the process, what with the several billion web pages that are out there! And yes, I have seen the gag page that claims to be the last page on the World Wide Web, and tells you that you may now turn off your computer!
I've reached the point where the program reads in a web page and parses the HTML to find all the HREFs contained therein. (Or at least, I think it finds them all. We'll see when I start trying other pages.)
There are HTML audit programs like this out there already, I know. But writing one of my own forces me to learn a lot of capabilities that I otherwise might not learn. Learn by doing works for me a lot better than reading a tutorial.
UPDATE: Well that's cool! I don't have the recursive part done yet, but I ran it against my home page, and it discovered that one of the links from my recent restructuring is broken!
Republican vice presidential candidate Sarah Palin attended five colleges in six years before graduating from the University of Idaho in 1987.
Federal privacy laws prohibit the schools from disclosing her grades, and none of the schools contacted by The Associated Press could say why she transferred.
There was no indication any of them were contacted as part of the background investigation of Palin by presidential candidate John McCain's campaign.
Oh yes, I'm sure that she transferred from school to school because she was being expelled for Satan worship, human sacrifice, and building WMDs in the chemistry labs.
There are a lot of us that attended several colleges before getting our degrees. I attended UCLA part-time when I was in high school (1973-74). I attended USC full-time for a year (1974-75)--scholarships actually made it less expensive for me than UCLA. Then I ran out of money. I went to UCLA for one quarter while working full-time--and had to drop out from a combination of a staph and strep throat infection (1978). And because UCLA wasn't really set up for working adults, I attended West Coast University in the evenings for a couple of terms in 1979.
I went back to college 1982-83 at Sonoma State University. I moved around the state a lot, working for various electronics companies (I have a "Migrant Software Worker" T-shirt), so I wasn't back in school until 1989, again at Sonoma State University. I received my B.A. in 1994, and my M.A. in 1998.
If liberals had any experience in the real world (instead of growing up in the world of wealth and privilege), they wouldn't find anything startling about Palin attending multiple colleges.
There's a little part of me that sometimes wonders if a real populist movement (and not the faux populism of obscenely rich people like John Edwards, Teddy Kennedy, and George Soros) might be a good thing--at least to put a scare into the billionaire's wing of the Democratic Party. For example: a 2.5% annual tax on net assets above ten million dollars. I wouldn't advocate that myself--but it would be entertaining to watch the liberals making excuses for why only incomes (those who are trying to become wealthy) are subject to taxes, but not assets (those who are already there).
UPDATE: I couldn't satirize the contempt that liberals have for whites that weren't born rich better than the comments over here:
As to your whine about the mean old left and Sarah Palin, don't you ever wonder if she attended so many colleges because she was trying to have sex with as many college men as she possibly could but her Alaska bound boyfriend at the time, Todd Palin, would get wind of it and drive his camaro down, his mullet flapping in the breeze, to kick some ass? So she had to keep changing schools?
I was almost tempted to link to this jerk's blog, where he claims that Palin's infant was obviously drugged at the convention, because he wasn't fussing or crying, but it appears that he is intentionally posting false quotes from Palin in order to increase his number of visitors. Why help him?
UPDATE 2: Here's a news story about her college attendance. No great surprises.
Like a lot of other conservatives, I cringe at kids in daycare. There are a lot of families that don't have much choice on this; they need both incomes to pay the bills--and they aren't living all that well, even with both Mom and Dad working full-time. (Oddly enough, back when most mothers stayed home to raise kids, there were thus about 70% fewer Americans looking for jobs. Individual worker wages were higher, and many fathers were able to raise a family on one income. Odd how that works, isn't it?)
There are other families that do have some choice on this. We used to live in California. One of our neighbors did daycare. She finally stopped doing it because of the situation with one of the kids. Mom had some important job with a bank in San Francisco; she drove a shiny new BMW. Six weeks after giving birth to her son, she was dropping him off at daycare every morning and heading to work. She was gone from 7:00 AM to 6:30 PM.
Dad gave instructors to the daycare provider to not tell Mom about the first time her son rolled over, or took his first steps, or spoke his first words. Dad wanted Mom to think that she was there for these emotionally significant steps. By the time this yuppie puppy was two years old, he would only call the daycare provider "Mom" and would actually hit his biological mother when she arrived in the evening to pick him up. If that doesn't make your want to cry, you might want to skip the rest of this posting.
Some Democrats are criticizing Governor Palin for putting the pursuit of political office above the needs of her family. Now, if conservatives were doing so (and a few, such as Dr. Laura Schlesinger, apparently are), it would be a consistent position, although one that you could still criticize as "old-fashioned." But the Democrats are the party of subsidized daycare and aggressive, sometimes bizarre enforcement of laws against employment discrimination based on sex. And they are complaining that Governor Palin shouldn't be running for office because she has three kids at home, one of whom has Down's Syndrome and thus needs more attention? If Democrats who are making this criticism mean it, I guess that they will be arguing for revising the sex discrimination laws next to allow--no require--employers to discriminate against women with minor age children at home.
Would I like to see more mothers staying home to raise their own kids? Absolutely. Should they be required to do so? No. They should have that choice, free of the continual culture war sniping of the left that any woman who stays home to raise her own kids is somehow beneath contempt--practically a domestic, in the eyes of many feminists.
UPDATE: Karl Lembke makes a very similar argument (great minds think alike) over here:
A third argument has to do with the pregnancy of Palin's daughter. If this had happened in a leftist family, there'd be much less fuss made over it, or expected in the media. The daughter could abort, and it would be a woman exercising her freedom of reproductive choice. Or she could move in with her boyfriend (or girlfriend) (or both) and it would be celebrated as an "alternative lifestyle". But conservatives advocate standards, and any deviation from those standards is always called "hypocrisy", never "being human and failing to live up to high standards". Here, we have the Left assuming the Palin family, and indeed, the entire pro-life movement, acts like the caricatures dreamed up by the Left. Upon hearing of Bristol's pregnancy out of wedlock, they imagine the instant response is to drag her out to the city gates and stone her to death. Well, maybe just kick her out into the street and erase every mention of her from their lives. For a pro-life, conservative Christian to love and support anyone who has strayed from the straight and narrow must be hypocrisy.
Expect to see more of this sort of argument. Expect accusations of double standards to be leveled. Expect critical distinctions to be blurred, in an effort to make this argument more credible.
Some professional C# and Visual Basic developers have been making suggestions that tell me that this isn't as obvious as I had thought. One suggestion that certainly reduces the flicker--as well as teaching me something that I needed to know--was to use a timer to drive the refresh. Instead of hooking up event handlers for just about every possible mouse event, instead:
Timer Clock;
public Form1() { // Set up a two second timer to force refresh. Clock = new Timer(); Clock.Interval = 2000; Clock.Start(); Clock.Tick += new EventHandler(Timer_Tick); }
public void Timer_Tick(object sender, EventArgs eArgs) { if (sender == Clock) { System.Console.WriteLine("tick..."); this.Invalidate(); } }
And then disable the various this.Invalidate() calls for the event handlers for mouse movement, mouse up, and so on. Obviously, if the interval between refreshes is very short, you still get the flicker, but it is at least a consistent flicker. (Is that a virtue? Well, it's less distracting than the random timing flicker that comes when you move the mouse around.) At three seconds, it is slow enough to be annoying, because you can see it taking time to do the refresh. At two seconds, you sometimes notice that the image hasn't refreshed, and sometimes you don't.
But then I pulled back for a second, thought about it, and realized that I was doing this all wrong! The real problem is that when I perform operations that cause, or could cause, a change in the data, that's when I need to call this.Invalidate() to force a refresh. So I've removed all the funny event handlers, and it now is flicker free, and simpler! I'm updating the listing and the code shortly.
It was a screening interview--but went on quite a bit longer than I expected, which I think is a good sign. The interviewer gave me one of those problems that I did very well on--and he commented that I even avoided the mistake that many people make.
He also asked a couple of questions designed to see how much of what I knew was just programming, and how much was computer science. He wanted me to differentiate a queue from a stack--and then explain conceptually how you would implement these in a programming language. I can tell that he was pleased with my answers.
I took advantage of the discussion of stacks to explain how most programming languages use a stack to implement parameter passing and automatic variable using the base pointer and frame pointer registers, and the experience I have had building symbolic debuggers using that information. He was clearly impressed with the level of detailed knowledge in this area--where I gather a younger generation of computer science graduates may have not even studied this in school, or had little actual opportunity to use this knowledge.
There's another set of interviews in a week or two. The good news is that there are positions here in Boise with Microsoft!
I also had a chance to talk to representatives from several other companies, although the ones in Boise wanted current C# and SQL experience--and the one that was interested in my SNMP experience is in Pullman, Washington, which is about a five hour drive from here. posted by Clayton at 6:18 PM permalink
The "Scandal" Involving Palin's Ex-Brother-in-Law
Liberals are threatening to make a big issue about whether Gov. Palin used undue influence to get her ex-brother-in-law fired from the Alaska state police. This article from the July 27, 2008 Anchorage Daily News shows that even if she did, this might be a sign of her reformist tendencies:
Wooten is 35, a state trooper since March 2001 and an Air Force veteran. He's a father of young children who has been married and divorced four times.
The accusations are detailed in two thick binders, the result of a nearly yearlong investigation by troopers. When the investigation appeared to stall, Palin -- more than a year before she was elected governor, and about two months before launching her campaign -- pushed trooper commanders to take action against Wooten. At one point, Palin and her husband, Todd, hired a private investigator.
Wooten recently gave his union permission to release the entire investigative file, all 482 pages and hours of recorded interviews.
"The record clearly indicates a serious and concentrated pattern of unacceptable and at times, illegal activity occurring over a lengthy period, which establishes a course of conduct totally at odds with the ethics of our profession," Col. Julia Grimes, then head of Alaska State Troopers, wrote in March 1, 2006, letter suspending Wooten for 10 days. After the union protested it, the suspension was reduced to five days.
...
As the investigation got under way in 2005, Wooten was in the midst of a bitter divorce from Palin's sister, Molly McCann. The couple was fighting over custody of their two young children. Accusations flew from both sides.
Troopers eventually investigated 13 issues and found four in which Wooten violated policy or broke the law or both:
• Wooten used a Taser on his stepson.
• He illegally shot a moose.
• He drank beer in his patrol car on one occasion.
• He told others his father-in-law would "eat a f'ing lead bullet" if he helped his daughter get an attorney for the divorce.
Beyond the investigation sparked by the family, trooper commanders saw cause to discipline or give written instructions to correct Wooten seven times since he joined the force, according to Grimes' letter to Wooten.
Those incidents included: a reprimand in January 2004 for negligent damage to a state vehicle; a January 2005 instruction after being accused of speeding, unsafe lane changes, following too closely and not using turn signals in his state vehicle; a June 2005 instruction regarding personal cell phone calls; an October 2005 suspension from work after getting a speeding ticket; and a November 2005 memo "to clarify duty hours, tardiness and personal business during duty time."
Yes, I can see why Democrats are holding Wooten up as a hero. He's their sort of state employee!
T. Allen Hoover is running for Idaho State Senate district 17. He won the Republican nomination--but this is a Boise state senate district, so he could use some help. For those of you nearby, he could use some volunteers. For those at a distance: money helps! Hoover is strongly pro-gun, pro-life, and definitely a conservative.
Allen is an interesting character--not Mr. Polished and Hubba-Hubba politician. If it gives you some idea what kind of guy he is, he likes to tell the story of turning in a paper for a college class, and the professor marked him down for citing something to the first printing of Alexis de Tocqueville's Democracy in America--when clearly, he used a later edition. No, Allen was working from a first printing!
For those who helped me with my primary challenge to Senator Corder: thank you. Help put Mr. Hoover in office, and it's almost as wonderful as putting me there!
With Microsoft. They have an office in Boise. posted by Clayton at 12:13 PM permalink
Lunatic Fringe
If you really want to know how deranged the liberal news media have become, read this column that the Philadelphia Daily News published on September 2, 2008. After ranting about the desperate poverty that has swept across our nation, one of their columnists tells us what is going to happen if we don't let Obama win the election:
If McCain wins, look for a full-fledged race and class war, fueled by a deflated and depressed country, soaring crime, homelessness - and hopelessness!
That's certainly a way to get the vast majority of Americans (regardless of color) on your side: insist that you either get your way, or we'll start a race war! And why does Obama and fellow leftists want to disarm law-abiding Americans? To make sure that we can't defend ourselves in case anyone listens to these raving liberals? (Thanks to Snowflakes in Hell for pointing me to this trash.)
It was apparently devastatingly effective. This article from the September 4, 2008 Sun (one of the British tabloids) makes me think I missed something world-changing:
Today she is the most talked-about woman in the world. And with good reason.
Sarah Palin's sensational performance at the Republican Party Convention may turn out to be the tipping point of this rollercoaster American election.
Obama fans hoping she would fluff her big night were in for a nasty shock.
This speech has turned the election upside down. It was simply stunning.
Democrats and their Lefty media backers had been sneering that she was a small town nobody, a hick from the Alaskan sticks put into a job way beyond an inexperienced woman.
Believe me, you will not be hearing that again.
Palin turned out to be an electrifying mix of intelligence, passion, energy, optimism and plain speaking.
Full of self-assurance and aggression, she popped Barack's balloon big-time.
From the moment she walked on stage in this cavernous bear pit, bandbox smart in cream jacket, trim black skirt and black heels, she proved that John McCain knew exactly what he was doing when he picked her as running mate.
Hair piled into a slight beehive – more Sarah White House than Amy Winehouse – she blinked and smiled behind her geeky spectacles as the vast crowd went ballistic.
For an unpopular party divided over Iraq and struggling to compete with Obama's Messianic glamour, the choice of Palin looks absolutely inspired.
Main Street America will have loved her performance.
And it was seen by 30million voters – the greatest number ever to watch a candidate for the much-derided VP post.
She is popular with voters for the very reason America's snooty political establishment despises her: She isn't one of the Washington gang.
She's a moose-hunting mum of five with a sledge-load of problems behind her own front door that workaday Americans can relate to.
A child with special needs. A daughter of 17 pregnant. A constant juggle between family and career.
As she said, her family has had its ups and downs like any other.
Last night her first task was to introduce herself and her family to an American public incredulous that the unknown Alaska governor could within weeks be a heartbeat away from being their commander in chief.
Compared to the journeyman career politicians dominating both parties here she seemed fresh, natural, one of us and not one of them.
And the comments from British readers are just amazing, like this one:
My interest in American politics has been limited; until I saw Palin's speech in the early hours of this morning. She was brilliant, she spoke like she really cares about her 'fellow Americans' and the country, what was best for them and what was not, and answered her critics intelligently and with dignity. Our politicians could learn a hell of a lot from her....
Wow what a woman- What a speech. Our lot look tired and unitersting by comparison. Its about time our leader had the right of veto and use it. Were all sick of the lefty icreasing size of government that is crippliong business and industry through taxation. Its about time like the Americans we returned to our Godly roots.
As an Irish woman living in the USA I am so happy to finally a worthy candidate for vice president. I watched her speech last night and I saw a woman who speaks her mind openly and with great conviction.
Sarah Palin is refreshing. She's a 'normal' person which is going to attract a lot of votes from 'normal' Americans. She may not have all the experience in the areas of foreign policy BUT she is extremely intelligent and will catch up - probably faster than her opponents!
She faces the same everyday problems as everyone else and now they have a voice to speak and act on their behalf. She has already said that parents of 'challenged' children, will, if McCain and her get to the White House, have a friend in the White House. I suspect that this will help many of the 'undecided' decide.
Reporters and media can say what they like - Sarah Palin has guts and is tough. As she said she's not there to please them, she's there to lead. And lead she will.
UPDATE: Here's video of the speech. And yes. This is one of the world-changing political speeches of our generation. She is a powerful, but very natural speaker. Obama has just lost. Palin will be extraordinarily qualified to run for President in 2012.
ALGER, Skagit County — The man arrested in the deaths of six people and the wounding of three others in a shooting and stabbing rampage here is being held for investigation of six counts of murder and two counts of attempted second-degree murder.
The suspect, 28-year-old Isaac Zamora of Alger, made his first court appearance this afternoon in District Court and is being held on $5 million bail.
...
Dennise Zamora, the suspect's mother, said Tuesday that her son is "extremely mentally ill" and had been living in the woods on and off for years. She said Jackson, the slain deputy, was aware of her son's illness and told the Zamora family to call her anytime for help.
After watching Isaac Zamora walk in and out of neighbors' homes, his mother called deputies on Tuesday. She said her son wasn't aware of his mental illness.
Dennise Zamora said she wished she could switch places with the people slain Tuesday.
"When I say I wish it was me and not them, I mean it from the bottom of my heart," she said, sobbing.
Dennise Zamora said her son had struggled with mental illness since their family's house burned down more than a decade ago. She said he was "agreeable" and "placid" Tuesday morning and that she didn't know what made him snap. She also said she didn't know where he got the gun used in the shootings.
The shooting rampage that left six dead Tuesday in Skagit County is the latest tragic incident involving a person with apparent mental illness who didn't get treatment in time to prevent violence.
Six more names to add to an already grim list: Sierra Club worker Shannon Harps, stabbed to death outside her Capitol Hill apartment last New Year's Eve; Jewish Federation employee Pamela Waechter, gunned down at work; Newport High School coach Mike Robb, shot in his car; firefighter Stan Stevenson, stabbed to death in a crosswalk walking back from a Mariners game; pregnant Kari Osterhaug, shot by her husband.
In each case, a person with severe, untreated mental illness has been charged or convicted in the killing.
And in each case, family members or others tried to intervene to get the suspect help before he committed a horrific crime but were stopped by Washington's strict commitment laws and overburdened, ineffective mental health care system.
Now it appears Isaac Zamora, 28, who was arrested after the shooting spree this week, may fit that same profile. His mother, who characterized her son as "increasingly psychotic," said she had tried for years to get him help without success.
"The laws are insane," Dennise Zamora said Wednesday. "He needed to be in a facility."
Her statements echo those of countless other families who say Washington's mental health system fails those who need it most.
A Seattle P-I analysis found the state is spending $1.8 billion on mental illness. But most is spent in courtrooms, squad cars, jail cells, homeless shelters and emergency rooms, not on prevention or long-term treatment. The biggest price taxpayers pay for mental illness in this state is not the cost of treatment -- it's the cost, and consequences, of failure to treat.
Isaac Zamora's lengthy court record contains a sprinkling of references to concerns over his mental health, including a 2003 reference to biting a staff member who was trying to restrain him at North Sound Evaluation and Treatment Center, a mental health clinic in Sedro-Woolley.
Zamora also was ordered by a Skagit County Superior Court judge to undergo a mental health evaluation as part of his court-ordered community supervision, said Department of Corrections spokesman Chad Lewis. Zamora was released Aug. 6, but that evaluation had not taken place before the shootings.
This pattern of not getting help soon enough is endemic to Washington's health care system.
This morning, the job search situation was looking pretty encouraging--enough that some job listings from Texas did not get my immediate attention. But then one employer in Seattle decided that my Java experience wasn't recent enough (and I can't argue the point). A position in Fresno turned out to require Linux kernel experience, which I don't have. A couple of Boise firms decided that they needed people with a closer match to their language requirements.
The only position that seems likely right now is in North Carolina, and my wife is fiercely hostile to me being gone for six months. I'm not keen on it either. It's at least eight hours to fly either direction, which, along with the cost, would strongly discourage seeing my family. The prospect of sitting after work in a hotel room in Raleigh for months on end sounds fiercely unattractive. posted by Clayton at 10:40 PM permalink
The C# Plotting Toy Gets Better And Better
I'm not going to inflict the source on the blog from now on; you can read it, and see the details of how to install the executable here. Recent improvements:
1. I am now using the ClientSize method for getting the inside of various objects when figuring out how much room there is to plot. This is more accurate, and doesn't require as much fudging.
2. When you start the program, instead of using a Panel on which to draw the graphs, it graphs directly into the Form. I had hoped that some of the failure to refresh problems would go away, but they really didn't. It did simplify the code a bit, as did removing Panel from the various popup windows.
3. Instead of a fixed sized Panel, the area used for plotting the graphs expands to fill the available Form--and if you resize the window, everything inside resizes and redraws.
4. I've mentioned the problems with getting refresh to work more consistently. At the moment, the choice is either a bit too much flicker (because every mouse movement event causes refresh), or waiting for you to move the mouse outside of the window, or release the mouse button, or any of several other events, to cause refresh. There has to be a more elegant way to do this.
5. There is a new File, Open Web Page command that lets you grab CSV files in the appropriate format from a web page. There's a default URL as well. The behavior when you give an invalid URL isn't quite as elegant as I would like, but that's for tomorrow.
I alluded to this problem yesterday that I wanted if a user double clicks in a ListBox for it treat this the same as selecting a choice, then hitting the OK. I couldn't figure out how to make it happen. Here's the solution. This line adds the double click event handler:
box.DoubleClick += new EventHandler(this.listBoxDoubleClick);
The configDlg is a Form created from within this class, setting DialogResult controls what gets returned to the ShowDialog() caller. The annoying gotcha of this is that to make configDlg visible in the event handler, I had to store in as a class level variable, rather than simply declare it in the function where I create the dialog window. My guess is that if the event handler was ever invoked while the dialog window didn't exist, this would cause an exception--but heck, I'm writing for fun right now. If someone wants to pay me to write C#, I would put in exception handling for this.
The this.configDlg.Close() method closes down the dialog window. When ShowDialog returns, the DialogResult.OK gets treated as though the user hit the OK button, and the selected values are set up correctly.
if (configDlg.ShowDialog(this) == DialogResult.OK) { System.Console.WriteLine("OK"); // Grab the selection list from the list box. ListBox.SelectedIndexCollection selectedItems = box.SelectedIndices; // Now go through and convert this into a list of ints. listToShow.Clear(); for (int i = 0; i < numbersarraymax =" RecalculateMaxValue();">
I was especially pleased to find out that if I selected one item in the ListBox first, then double clicked on another item, both items came back in the SelectedIndices field.
UPDATE: Oh yes, the plot area also adjusts to the size of the overall window. If you resize the window, the plot area changes and redraws automatically.
I've mentioned before that affirmative action in education doesn't just injure whites and Asians--it also damages the supposed beneficiaries of it as well, because it encourages minorities to attend colleges where they will be in over their heads. A high school senior with a B- average and 60th percentile SAT scores gets recruited into UC Berkeley--and fails, where he might have gone to San Jose State and graduated. A high school senior with a B+ average and 90th percentile SATs gets lured into Harvard--and drops out during the first year--who might have graduated from UC Berkeley. But as long as the liberals that run the universities feel good about themselves for being so open-minded--who cares what happens to the dropouts?
Back in 2004, there was apparently a study of this issue with respect to law schools--and the conclusion was similar--that the elite law schools were using affirmative action programs to get minority students in the door who were simply not adequately prepared to compete with other students (including other minorities) who were admitted under the standard admissions criteria.
There's a new study out discussed in the September 3, 2008 Inside Higher Education that somewhat confirms the mismatch hypothesis--but also argues that without affirmative action, only the very bottom tier of law schools would have as many black students as they do now:
But the new research — using simulations of admissions without affirmative action — finds that race-neutral policies wouldn’t send black students to law schools where they would do better. Rather there would be a huge falloff in black law enrollments — far more than might be counteracted by some black students doing better on bar exams. The elimination of race-based admissions policies, the authors write, would lead to a 63 percent decline in black matriculants at all law schools and a 90 percent decline at elite law schools, the paper says. Even if some positive impact took place in the experience of black students who did enroll, there would be at least a 50 percent reduction in the production of black lawyers, they write.
Why is this? Because even the bottom tier of law schools are actually very difficult to get into--and the number of blacks who can meet the very demanding standards of the LSAT is, relative to the number of blacks entering law school--quite small. A rational person would, at this point, start to ask, "Uh, maybe we need to fix this problem a little farther back then admission to law school? Is there something hopelessly broken in either the schools that American blacks are attending, or in the culture in which American blacks are growing up?" But hey: why bother? It is so much easier to just keep admitting underqualified applicants who can then drop out of law school, or fail to pass the bar exam.
When the goal isn't to fix the problem--but to make liberals feel better about themselves--results don't much matter.
Over at Power and Control is a surprising posting about the Democrats. It starts out with a long quote from Asia Times columnist "Spengler" (who is always a delight to read, even when I don't agree with him) about how McCain's choice of Palin is going to seal the fate of the Democrats in November. I suspect that Spengler is right about this, although I don't have quite that much confidence. But Power and Control points out a couple of aspects of where the Democratic Party is headed that I find fascinating, especially what Power and Control (who is a libertarian) calls the "fetishizing" of abortion:
It is interesting that the Democrats keep nominating successively weaker candidates. First Gore. Then Kerry. And now Obama. I think it is becoming obvious for all to see that the Democrat Party has no soul. As such it has no direction except the will to power. In fact the behavior of his base since Palin was nominated is an expression of that weakness. It would appear from their behavior that strong women frighten them. And they should be frightened.
...
I think it is telling in many ways that the left's caricature of evangelical relations with women is really a projection of their own weakness. In fact Moloch is the god of the weak. You have to be strong to raise children. Not just for a day or a week but for 18 or 20 years. In fact for a whole lifetime. Which is exactly why what the left is going through now with the abortion issue and Sarah Palin and her daughter is so telling. They are attacking the mother and daughter because they are strong. And such strength only illuminates that which they would prefer to remain in darkness. Their weakness.
Does this mean I want abortion made illegal? Don't be silly. Such a law would serve no useful purpose. Botched abortions kill. They can also prevent future births when the woman and man involved find their strength. But that does not mean that we should avoid looking at it square on and seeing it for what it is. The fact that the Democrats and especially Obama have to a great degree fetishized abortion is very telling. Very telling indeed.
I mentioned it yesterday. It has grown a good bit. The Config menu choice now pops up a window where you get to select which rows of data from the CSV file you want to display--and then it autoscales the plot, based on the new data.
I'm learning a lot, and thanks to those who patiently answer questions.
It has been years since I enjoyed myself this much at work.
One area that I am still struggling with is that when I double click on an entry in the ListBox that contains the list of data sets to plot, I want it to select that entry, and be the equivalent of hitting the OK button. The problem is that there's something magic that I need to do from the ListBox event handler that tells the Form that it is time to return DialogReturn.OK--but I can't tell what.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
// Set up a color palette to use for drawing lines. private List colorChoices = new List() {Color.Yellow, Color.Aqua, Color.Red, Color.Blue, Color.Beige, Color.Violet, Color.Coral, Color.CornflowerBlue, Color.Cornsilk, Color.Crimson, Color.Cyan, Color.DarkBlue}; // This is where the numeric data will go. private List numbersArray = new List(); // This is the largest count of numbers in any element of numbersArray int numbersArrayMaxCount = 0; // This is the largest value that we have to plot across all rows. float numbersArrayMax = 0.0F; // The legend information (contained in the first column) goes here. private List legendStrings = new List(); // And this is where the column header information goes (the years going // across, for the first sample. private ColHdr colHdr = new ColHdr(); // This contains a list of all the rows in the CSV file to plot. We'll default this to // every entry when we first load a CSV file. The user can use the Configure command to // be more selective. List listToShow = new List();
private float RecalculateMaxValue() { float maxValue = 0.0F; for (int i = 0; i < numbersArray.Count; i++) { NumbersToPlot numbers = numbersArray[i]; if (listToShow.Contains(i)) for (int j = 1; j < numbers.events.Count; j++) maxValue = Math.Max(maxValue, numbers.max); } return(maxValue); }
// Open the data file and populate legend and numbersArray. private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Data Input File (CSV)"; openFileDialog1.DefaultExt = "*.csv"; openFileDialog1.Filter = "CSV files|*.csv"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { // This is where we specify the CSV file to open. Stream myStream = new FileStream(openFileDialog1.FileName, FileMode.Open); if (myStream != null) { string[] strArray; char[] charArray = new char[] { ',' };
// Dispose of the old data set, if any if (numbersArray.Count > 0) { numbersArray.Clear(); numbersArrayMax = 0.0F; numbersArrayMaxCount = 0; legendStrings.Clear(); }
StreamReader sr = new StreamReader(myStream); string strLine; // Pull in the first line--the column header line. strLine = sr.ReadLine(); if (strLine != null) { strArray = strLine.Split(charArray); colHdr.colHdrStrings = new List(); for (int i = 2; i < strArray.Length; i++) colHdr.colHdrStrings.Add(strArray[i]); } // Now pull in the data that we are going to plot. int dataRowNbr = 0; do { strLine = sr.ReadLine(); if (strLine != null) { System.Console.WriteLine("reading " + strLine); strArray = strLine.Split(charArray); NumbersToPlot numbers = new NumbersToPlot(); // Add the legend (the first column) to this list. legendStrings.Add(strArray[0]); listToShow.Add(dataRowNbr++); numbers.category = strArray[1]; numbers.events = new List(); // We need to keep track of the smallest and largest values we see. numbers.min = numbers.max = 0; int lastNumber; for (int i = 2; i < strArray.Length; i++) { numbers.events.Add(float.Parse(strArray[i])); lastNumber = numbers.events.Count - 1; numbers.min = Math.Min(numbers.min, numbers.events[lastNumber]); numbers.max = Math.Max(numbers.max, numbers.events[lastNumber]); } numbersArray.Add(numbers); numbersArrayMax = Math.Max(numbersArrayMax, numbers.max); numbersArrayMaxCount = Math.Max(numbersArrayMaxCount, numbers.events.Count); } } while (strLine != null); myStream.Close(); } } }
// Configure which lines in the data set to display. private void configureToolStripMenuItem_Click(object sender, EventArgs e) { SizeF sizef;
// This is where we specify which lines to plot. Form dlg = new Form(); dlg.Size = new System.Drawing.Size(500, 400); sizef = dlg.Size; // Create a panel FlowLayoutPanel panel = new FlowLayoutPanel(); panel.Size = new System.Drawing.Size(dlg.Size.Width, dlg.Size.Height); dlg.Controls.Add(panel); // Add a ListBox ListBox box = new ListBox(); box.SelectionMode = SelectionMode.MultiExtended; box.DoubleClick += new EventHandler(this.listBoxDoubleClick); box.Size = new System.Drawing.Size(panel.Size.Width - 50, panel.Size.Height - 100); for (int i = 0; i < legendStrings.Count; i++) { box.Items.Add(legendStrings[i]); box.SetSelected(i, true); } panel.Controls.Add(box); // Add a button to the panel. Button bOk = new System.Windows.Forms.Button(); bOk.Text = "OK"; bOk.DialogResult = DialogResult.OK; panel.Controls.Add(bOk); Button bCancel = new System.Windows.Forms.Button(); bCancel.Text = "Cancel"; bCancel.DialogResult = DialogResult.Cancel; this.AcceptButton = bOk; panel.Controls.Add(bCancel); if (dlg.ShowDialog(this) == DialogResult.OK) { System.Console.WriteLine("OK"); // Grab the selection list from the list box. ListBox.SelectedIndexCollection selectedItems = box.SelectedIndices; // Now go through and convert this into a list of ints. listToShow.Clear(); for (int i = 0; i < selectedItems.Count; i++) listToShow.Add(selectedItems[i]); // Recalculate the maximum value that we have to plot. numbersArrayMax = RecalculateMaxValue(); } }
public SizeF CalcLeftMargin(Graphics g, Font legendFont, List legendStrings) { // Figure out the width of the legends on the left. These are the // first column of information in the CSV file. SizeF maxLegend = new SizeF(); int i; SizeF legendStrSize; for (maxLegend.Width = maxLegend.Height = 0, i = 0; i < numbersArray.Count; i++) { legendStrSize = g.MeasureString(legendStrings[i], legendFont); maxLegend.Width = Math.Max(maxLegend.Width, legendStrSize.Width); maxLegend.Height = Math.Max(maxLegend.Height, legendStrSize.Height); } maxLegend.Width *= 1.10F; return (maxLegend); }
public float CalcTopMargin(Graphics g, Font colHdrFont, ColHdr colHdrStrings) { // Now figure out how much room we need at the bottom for the column headers. // Complicating this is that we need to adjust font size (perhaps) for too many // columns. float maxColHdrWidth = 0.0F; float maxColHdrHeight = 0.0F; SizeF colHdrStrSize; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[i], colHdrFont); maxColHdrWidth = Math.Max(maxColHdrWidth, colHdrStrSize.Width); maxColHdrHeight = Math.Max(maxColHdrHeight, colHdrStrSize.Height); } return (maxColHdrHeight); }
public float CalcRightMargin(Graphics g, Font colHdrFont, ColHdr colHdr) { // We have to leave a little room on the right side of the last column because // we are centering the column headers under the center point for the lines. // So we need to know how much room that will be for the last column header. SizeF colHdrStrSize; colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[colHdr.colHdrStrings.Count-1], colHdrFont); float rightMargin = (colHdrStrSize.Width / 2.0F) * 1.25F; return (rightMargin); }
public void PlotLegends(Graphics g, Font legendsFont, List legendStrings, float maxLegendsHeight, List listToShow) { // Now we know how big it is, we can draw the legend strings down the left side. Brush myBrush; for (int i = 0, legendLineIndex = 0; i < numbersArray.Count; i++) { if (listToShow.Contains(i)) { myBrush = new SolidBrush(colorChoices[legendLineIndex % 10]); g.DrawString(legendStrings[i], legendsFont, myBrush, 0, maxLegendsHeight * legendLineIndex); legendLineIndex++; } } }
public void PlotColHdrs(Graphics g, Font colHdrFont, ColHdr colHdr, float rightMargin, float leftMargin, float xScaling, float plotWidth) { SizeF colHdrStrSize;
Brush myBrush = new SolidBrush(Color.White); float lastColHdrEndsAt = 0.0F; // not correct, but the first header must appear float colHdrStartsAt = 0.0F; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { // Get the size of the string so that we can move it over to be centered. colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[i], colHdrFont); colHdrStartsAt = (i * xScaling) + leftMargin - colHdrStrSize.Width; // We don't want to step on the last column header. if (colHdrStartsAt > lastColHdrEndsAt + 5.0F) { g.DrawString(colHdr.colHdrStrings[i], colHdrFont, myBrush, (i * xScaling) + leftMargin - (colHdrStrSize.Width / 2), 0); lastColHdrEndsAt = (i * xScaling) + leftMargin + (colHdrStrSize.Width / 2); } } }
public void PlotLines(Graphics g, float leftMargin, float topMargin, float bottomMargin, float rightMargin, float xScaling, ColHdr colHdr, float numbersArrayMax, int divisions, float yScaling, Font font) { Pen pen = new Pen(Color.White, 2); // Draw the left, right, top and bottom lines. g.DrawLine(pen, leftMargin, topMargin, leftMargin, bottomMargin); g.DrawLine(pen, rightMargin, topMargin, rightMargin, bottomMargin); g.DrawLine(pen, leftMargin, topMargin, rightMargin, topMargin); g.DrawLine(pen, leftMargin, bottomMargin, rightMargin, bottomMargin); // Draw the vertical grid lines. int xCoord = 0; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { xCoord = (int)((float)i * xScaling + leftMargin); g.DrawLine(pen, xCoord, topMargin, xCoord, bottomMargin); } // The brush for drawing the numbers left of the grid lines. Brush myBrush = new SolidBrush(Color.White); // Draw the horizontal grid lines. float perDivision = (yScaling * numbersArrayMax) / divisions; float perDivisionNumber = 0.0F; for (int i = 0; i < divisions + 1; i++) { g.DrawLine(pen, leftMargin, bottomMargin - (i * perDivision), rightMargin, bottomMargin - (i * perDivision)); perDivisionNumber = i * numbersArrayMax / divisions; // Figure out how much we have to move the string to the left of the vertical grid // line, and how much we have to raise it up to center on the horizontal grid line. SizeF strSize = g.MeasureString(perDivisionNumber.ToString(), font); g.DrawString(perDivisionNumber.ToString(), font, myBrush, leftMargin - strSize.Width, (bottomMargin - (i * perDivision)) - strSize.Height/2); } }
The Heritage Foundation has a job bank for connecting up those of us on the right with jobs. Okay, they admit that they only manage to find about 75 jobs a year out of 5000 submissions, but that's 75 jobs that might not otherwise have happened. Pretty obviously, this is focused on public policy wonks (and I think I qualify as one), but since there are some public policy wonks in training out there reading my blog, I figured that you should know! posted by Clayton at 3:26 PM permalink
To My Surprise And Pleasure
Unlike the last time I had to look for a job, there are lots of jobs outside of Boise for someone like myself. Many of these are high paying contract positions--enough that I could afford to at least fly home on the weekends. The number of phone calls from recruiters has been quite phenomenal.
My incentive to help with getting the 14th Amendment incorporated against the states may be increased if I end up working on a contract in Sunnyvale. posted by Clayton at 2:05 PM permalink
More C# Learning Experiences
I was trying to figure out how to create a modal dialog window in C#. (For those not familiar with the terminology: modal means that the user has to finish with this dialog window before he can go back to functions in the parent window.) I thought that this would be easy to find, but in the fast sea of C# documentation out there, it wasn't easy!
From the function that gets called when you select a menu option:
Form dlg = new Form(); dlg.ShowDialog();
If you specify dlg.Show(), you get a modeless dialog window instead.
A lot of the examples out there for dialog boxes assume that you are using the Visual Studio tools for building the dialog box. If you want a dialog box that is built dynamically from within your program, the examples are a bit harder to find.
// This is where we specify which lines to plot. Form dlg = new Form(); // Create a panel FlowLayoutPanel panel = new FlowLayoutPanel(); dlg.Controls.Add(panel); // Add a button to the panel. Button b = new Button(); b.Text = "OK"; panel.Controls.Add(b); // Add a ListBox ListBox box = new ListBox(); panel.Controls.Add(box); dlg.ShowDialog();
You can't add a Button or ListBox control directly to a Form; you need a Panel object there first (much like Java's UI). A FlowLayoutPanel gives you a fair amount of control--or you can let it do most of the work for you, again, much like the equivalent in Java's UI.
CORRECTION: You can add controls, like Button directly to a Form. But all the controls end up on top of each other in the upper left corner of the Form, unless you tell them where to go.
I'll probably just keep expanding this as I learn things. You add a button click event driver like this:
Yes, I'm disappointed by this--but doubtless not as disappointed as Governor Palin. The left, of course, has decided that this is a sign of hypocrisy. Huh? If Governor Palin had encouraged her daughter to have sex outside of marriage, yes, it would be. But as any parent of teenagers can tell you, you can tell them what's right until you are blue in the face, but they have a free will, they make their own decisions--and often, those are bad decisions.
I grieve with Governor Palin about her daughter's first bad decision to have premarital sex, and second bad decision to fail to use a condom. (Assuming that's the case. There were a couple of college students at our church in San Jose who decided not to wait--and the condom broke, accelerating their marriage plans.) But the daughter's decisions are not an indication of hypocrisy on Governor Palin's part.
Now, if Governor Palin had dragged her daughter off for an abortion, the left would have a valid basis to scream hypocrisy. But then, no one would even know about this, would they? I'm guessing that the louder the left screams about this, the more parents of teenagers will say, "I sympathize with Governor Palin." It doubt it will get any votes for the McCain/Palin ticket--but I can't imagine it turning any votes away.
There is one way that Governor Palin could use this to her advantage: remind everyone that the left promotes sexual promiscuity and premature sexualization of teenagers through their control of the entertainment media. I certainly wouldn't argue that this constant pressure is what caused disappointments like this. Teenagers and young adults have been making mistakes like this for many centuries. I recall reading an analysis of Puritan birth and marriage records that concluded that at least 16% of brides were pregnant when they said, "I do." For exactly that reason, the culture needs to be promoting restraint and mature decision making. The entertainment business is pouring gasoline on a fire when they should really be bringing a fire extinguisher.
UPDATE: Byron York of National Review went around talking to evangelical activists at the Republican National Convention--and received much the same reaction that I had:
“For me personally, it hit my heart this morning,” Sharkey told me, “because I was a 17 year-old girl, just like Sarah Palin’s daughter, and I had — I was in those shoes. And my son is with me, who will be 35 years old next week, and so I know what a difficult road there is for her.”
“I chose to have my son, and from that point I realized that I was a very strong right-to-life advocate,” Sharkey continued, her voice wavering ever so slightly. Roe v. Wade had been passed just the year before, and I already knew girls who were going through abortions. It wasn’t a choice for me; it wasn’t in my heart to do that. So when I heard the news this morning, it struck close to home for me.”
A few feet away, members of the Ohio delegation were finishing up business, and I asked Patricia Murray, a delegate from Cincinnati, what she thought. “I don’t even think this is an issue,” she told me. “It’s a family issue. It’s a personal issue. The only reason it was made public was because of her mother.” Nearby, Ben Rose, a delegate from Lima, said that, “In every case where I heard delegates talk about this, the first thought was to the human nature of it.”
Earlier in the day, just after I heard the news, I called Marlys Popma, the well-known Iowa evangelical leader who is now the head of evangelical outreach for the McCain campaign. Like Sue Sharkey from Colorado, Popma had a story to tell. It turns out she had had a child out of wedlock nearly 30 years ago, and it changed her life. “It was my crisis pregnancy that brought me into the movement,” Popma told me. “My reaction is that this shows that the governor’s family is just like so many families. That’s how my first child came into the world, and I’m just thrilled that [Bristol Palin] is choosing to give this child life.”
I asked Popma what she thought the larger reaction among evangelicals will be. “Their reaction is going to be exactly as mine,” she told me. “There hasn’t been one evangelical family that hasn’t gone through some sort of situation. Many of us are in this movement because of something that has happened in our lives.”
Yup. We live in an imperfect world, one that has been made even worse by the left's obsession with encouraging every 13 year old to be sexually active, regardless of the emotional and medical risks. This is a bad situation for Bristol Palin, and I'm hoping that what happened will be a warning sign to lots of other teenagers across America that it's easy to get carried away in the passion of the moment.
I sometimes wonder if the increasingly leftist leaning of Idaho politics might reflect that there simply is no local organization putting any effort into public policy advocacy with a conservative bent. The State Policy Network, for example, strives to bring together conservative public policy organizations from around the U.S., and they have members in many states--but not Idaho. An endowment of five million dollars would produce about $250,000 a year in interest income, easily--and with that kind of money, an organization could afford to hire several economists, an historian (let me make a suggestion on that), a PR person, a webmaster, and start producing thoughtful and useful public policy analysis materials.
Now, there are certainly business interests here in Idaho that are promoting their agenda--but that's not the same thing as promoting free markets. Business interests are frequently indifferent to free markets, and sometimes quite hostile to them--as the recent farm price support bill demonstrated.
Now, I'm not sure that there are actually any wealthy conservatives. Just about everyone I know who could afford to endow a foundation with five million dollars is liberal to Marxist. (Although not Marxist enough to, you know, actually give away their fortunes to the needy.) But I consider the possibility that there are rich conservatives out there to be at least a real possibility--more likely than the existence of leprechauns. posted by Clayton at 9:43 PM permalink
The Civilian Gun Self-Defense Blog
For almost five years, my co-bloggers and I have been putting a good bit of work into the Civilian Gun Self-Defense Blog. We never did it to get rich. (If that was our motivation, we would have needed our heads examined.) We did it because it was a valuable tool for demonstrating that the anti-gun claim that civilian gun self-defense is actually quite rare is incorrect.
If we were running a similar service to make gun owners look bad, we would almost certainly have received a $20,000 a year grant from the Joyce Foundation or some other non-profit for "contributing to the dialog about the problems of gun ownership in America." We've received a few very small contributions from gun owners over the years, and there are few businesses that have advertised there--for which we are very grateful.
Increasingly I find myself wondering if continuing this effort really makes any sense. We've made some efforts to engage NRA with this--with no success. There must be some wealthy gun owners or people in the gun business who can see the advantage of what we are doing, and would be willing to provide some limited funding to justify the effort. But if not, the temptation is very strong to stop putting the effort out on this, and let it die.
I'm not completely done, but I would like to verify that the publish feature of Microsoft Visual Studio C# actually works. You can run the setup program from here. This should install the first significant C# application that I have written, which loads data from CSV files and plots the data. You can download some files of the correct format here, or or here. This is quite similar to the Java applets that you can select here--except that it looks for a local file.
I still haven't figured out how to get it to fully redraw the data without putting the mouse over the File menu in the upper left.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
// Set up a color palette to use for drawing lines. private List colorChoices = new List() {Color.Yellow, Color.Aqua, Color.Red, Color.Blue, Color.Beige, Color.Violet, Color.Coral, Color.CornflowerBlue, Color.Cornsilk, Color.Crimson, Color.Cyan, Color.DarkBlue}; // This is where the numeric data will go. private List numbersArray = new List(); // This is the largest count of numbers in any element of numbersArray int numbersArrayMaxCount = 0; // This is the largest value that we have to plot across all rows. float numbersArrayMax = 0.0F; // The legend information (contained in the first column) goes here. private List legendStrings = new List(); // And this is where the column header information goes (the years going // across, for the first sample. private ColHdr colHdr = new ColHdr();
// Open the data file and populate legend and numbersArray. private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Data Input File (CSV)"; openFileDialog1.DefaultExt = "*.csv"; openFileDialog1.Filter = "CSV files|*.csv"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { // This is where we specify the CSV file to open. Stream myStream = new FileStream(openFileDialog1.FileName, FileMode.Open); if (myStream != null) { string[] strArray; char[] charArray = new char[] { ',' };
// Dispose of the old data set, if any if (numbersArray.Count > 0) { numbersArray.Clear(); numbersArrayMax = 0.0F; numbersArrayMaxCount = 0; legendStrings.Clear(); }
StreamReader sr = new StreamReader(myStream); string strLine; // Pull in the first line--the column header line. strLine = sr.ReadLine(); if (strLine != null) { strArray = strLine.Split(charArray); colHdr.colHdrStrings = new List(); for (int i = 2; i < strArray.Length; i++) colHdr.colHdrStrings.Add(strArray[i]); } // Now pull in the data that we are going to plot. do { strLine = sr.ReadLine(); if (strLine != null) { System.Console.WriteLine("reading " + strLine); strArray = strLine.Split(charArray); NumbersToPlot numbers = new NumbersToPlot(); // Add the legend (the first column) to this list. legendStrings.Add(strArray[0]); numbers.category = strArray[1]; numbers.events = new List(); // We need to keep track of the smallest and largest values we see. numbers.min = numbers.max = 0; int lastNumber; for (int i = 2; i < strArray.Length; i++) { numbers.events.Add(float.Parse(strArray[i])); lastNumber = numbers.events.Count - 1; numbers.min = Math.Min(numbers.min, numbers.events[lastNumber]); numbers.max = Math.Max(numbers.max, numbers.events[lastNumber]); } numbersArray.Add(numbers); numbersArrayMax = Math.Max(numbersArrayMax, numbers.max); numbersArrayMaxCount = Math.Max(numbersArrayMaxCount, numbers.events.Count); } } while (strLine != null); myStream.Close(); } } }
// Configure which lines in the data set to display. private void configureToolStripMenuItem_Click(object sender, EventArgs e) { // This is where we specify which lines to plot. }
public SizeF CalcLeftMargin(Graphics g, Font legendFont, List legendStrings) { // Figure out the width of the legends on the left. These are the // first column of information in the CSV file. SizeF maxLegend = new SizeF(); int i; SizeF legendStrSize; for (maxLegend.Width = maxLegend.Height = 0, i = 0; i < numbersArray.Count; i++) { legendStrSize = g.MeasureString(legendStrings[i], legendFont); maxLegend.Width = Math.Max(maxLegend.Width, legendStrSize.Width); maxLegend.Height = Math.Max(maxLegend.Height, legendStrSize.Height); } maxLegend.Width *= 1.10F; return (maxLegend); }
public float CalcTopMargin(Graphics g, Font colHdrFont, ColHdr colHdrStrings) { // Now figure out how much room we need at the bottom for the column headers. // Complicating this is that we need to adjust font size (perhaps) for too many // columns. float maxColHdrWidth = 0.0F; float maxColHdrHeight = 0.0F; SizeF colHdrStrSize; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[i], colHdrFont); maxColHdrWidth = Math.Max(maxColHdrWidth, colHdrStrSize.Width); maxColHdrHeight = Math.Max(maxColHdrHeight, colHdrStrSize.Height); } return (maxColHdrHeight); }
public float CalcRightMargin(Graphics g, Font colHdrFont, ColHdr colHdr) { // We have to leave a little room on the right side of the last column because // we are centering the column headers under the center point for the lines. // So we need to know how much room that will be for the last column header. SizeF colHdrStrSize; colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[colHdr.colHdrStrings.Count-1], colHdrFont); float rightMargin = (colHdrStrSize.Width / 2.0F) * 1.25F; return (rightMargin); }
public void PlotLegends(Graphics g, Font legendsFont, List legendStrings, float maxLegendsHeight) { // Now we know how big it is, we can draw the legend strings down the left side. Brush myBrush; for (int i = 0; i < numbersArray.Count; i++) { myBrush = new SolidBrush(colorChoices[i % 10]); g.DrawString(legendStrings[i], legendsFont, myBrush, 0, maxLegendsHeight * i); } }
public void PlotColHdrs(Graphics g, Font colHdrFont, ColHdr colHdr, float rightMargin, float leftMargin, float xScaling, float plotWidth) { SizeF colHdrStrSize;
Brush myBrush = new SolidBrush(Color.White); float lastColHdrEndsAt = 0.0F; // not correct, but the first header must appear float colHdrStartsAt = 0.0F; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { // Get the size of the string so that we can move it over to be centered. colHdrStrSize = g.MeasureString(colHdr.colHdrStrings[i], colHdrFont); colHdrStartsAt = (i * xScaling) + leftMargin - colHdrStrSize.Width; // We don't want to step on the last column header. if (colHdrStartsAt > lastColHdrEndsAt + 5.0F) { g.DrawString(colHdr.colHdrStrings[i], colHdrFont, myBrush, (i * xScaling) + leftMargin - (colHdrStrSize.Width / 2), 0); lastColHdrEndsAt = (i * xScaling) + leftMargin + (colHdrStrSize.Width / 2); } } }
public void PlotLines(Graphics g, float leftMargin, float topMargin, float bottomMargin, float rightMargin, float xScaling, ColHdr colHdr, float numbersArrayMax, int divisions, float yScaling, Font font) { Pen pen = new Pen(Color.White, 2); // Draw the left, right, top and bottom lines. g.DrawLine(pen, leftMargin, topMargin, leftMargin, bottomMargin); g.DrawLine(pen, rightMargin, topMargin, rightMargin, bottomMargin); g.DrawLine(pen, leftMargin, topMargin, rightMargin, topMargin); g.DrawLine(pen, leftMargin, bottomMargin, rightMargin, bottomMargin); // Draw the vertical grid lines. int xCoord = 0; for (int i = 0; i < colHdr.colHdrStrings.Count; i++) { xCoord = (int)((float)i * xScaling + leftMargin); g.DrawLine(pen, xCoord, topMargin, xCoord, bottomMargin); } // The brush for drawing the numbers left of the grid lines. Brush myBrush = new SolidBrush(Color.White); // Draw the horizontal grid lines. float perDivision = yScaling * numbersArrayMax / divisions; float perDivisionNumber = 0.0F; for (int i = 0; i < divisions + 1; i++) { g.DrawLine(pen, leftMargin, bottomMargin - (i * perDivision), rightMargin, bottomMargin - (i * perDivision)); perDivisionNumber = i * numbersArrayMax / divisions; // Figure out how much we have to move the string to the left of the vertical grid // line, and how much we have to raise it up to center on the horizontal grid line. SizeF strSize = g.MeasureString(perDivisionNumber.ToString(), font); g.DrawString(perDivisionNumber.ToString(), font, myBrush, leftMargin - strSize.Width, (bottomMargin - (i * perDivision)) - strSize.Height/2); } }
David Bernstein over at Volokh Conspiracy discusses nineteenth and early twentieth anti-Chinese legislation, and its connection to labor unions and the Lochner decision. Bernstein's William & Mary Law Review article mentions that at the start of the Gold Rush, the severe shortage of laundries meant that clothes were being shipped from California to China to be washed, and then shipped back again.
Bernstein also points out that origins of the "union label"--that little symbol that appears on most movies and printed materials, to show that this was produced by labor union members--was racist. The first "union label" was on cigars, and said "White Labor, White Labor." Along with the logo of the union of white cigar makers was the message:
Buy no cigars except from the box marked with the trade union label thus you help maintain the white as against the Coolie standard of life and work
This was no great surprise to me. My book For the Defense of Themselves and the State (Praeger Press, 1994) goes into some detail about the role that labor unions played in stirring up anti-Chinese feeling during the railroad strikes of 1877, and in promoting a riot that led to the burning out of San Francisco's Chinatown. My reading of California newspapers in the period 1910-25 shows that Democrats were major players in promoting racist laws and attitudes. To the extent that anyone was fighting racism, it was then conservative Republican newspapers like the Los Angeles Times. posted by Clayton at 9:30 AM permalink
Hurricanes As Punishment From God
Is one of those lunatic fringe televangelists saying this? No, a prominent Democrat. From the August 31, 2008 ABC News blog:
Former DNC Chairman Don Fowler apologized on Sunday for joking in a private conversation that the timing of Hurricane Gustav demonstrates that God is on the side of the Democrats.
"If this offended anybody, I personally apologize," Fowler told ABC News. "It was a mistake, and it was a satirical statement made in jest. And one that I clearly don't believe."
Fowler was secretly recorded by the person sitting behind him while flying from Denver, Colo., to Charlotte, N.C., following the Democratic National Convention. His conversation with Rep. John Spratt, D-S.C., was anonymously posted to YouTube and highlighted by RedState.com, a conservative blog.
"One doesn't anticipate that one's private conversation will be surreptitiously taped by some right-wing nutcase," said Fowler. "But that's the nature of what we're dealing with."
Fowler, a superdelegate who endorsed Hillary Clinton in 2007, was caught on tape saying: "The hurricane’s going to hit New Orleans about the time they start. The timing is -- at least it appears now that it’ll be there Monday. That just demonstrates that God’s on our side. [Laughter] Everything’s cool."
He claims that he was satirizing remarks by Rev. Jerry Falwell some years ago. But calling someone a "right-wing nut job" for taping his remarks? How you behave in private tells us a lot about who you really are, and what values you really hold. Look at Senator Larry "Happy Feet" Craig (R-ID). Look at Senator Teddy "Chappaquiddick" Kennedy (D-MA). Or President "What is the meaning of is?" Clinton.
What makes this especially devastating is Obama's excuses for Rev. Jeremiah Wright. I've read some of these quotes from Wright before--where he claims that the U.S. government invented HIV to kill off black people--but watching him yelling "God damn America" to his congregation still grabs me by the gut.
The quote from Obama about "typical white person" really shows how racism runs Obama's mind.
I'm finding that learning C#/.NET is going a lot faster than learning Java and its user interface did, back ten years ago--and I don't think that I am smarter than I was back then. Perhaps it is because then I was learning a new language (Java) and a new concept (Object-Oriented Programming) and the library classes required to support a user interface.
This time, I'm only learning a new language, and while the library classes are different, there are strong parallels between the Java user interface and .NET. Even if the .NET designers didn't look at Java, this would be unsurprising, since they perform similar functions.
One other aspect that may be making this easier is that I believe that the web is a vastly richer source of examples of C# today than was the case for Java in 1998. Back then, you could find examples in Internet newsgroups like comp.lang.java, and lots of good help at the Javasoft website. Today, everyone and his brother has a website up either giving away examples, offering subscriptions services to help you (and sometimes giving enough clues that I don't have to pay), and MSDN provides a bit of useful information also.
The problem may be that I am learning all this stuff just in time for it become obsolete and irrelevant. That doesn't seem possible with C#/.NET--but hey, if an entire sector of the industry has to disappear to keep unemployed, it could happen!
More seriously, I'm putting some time into learning C#/.NET because there are jobs for it--and energy spent polishing up my Java skills is perilously close to trying to remember how the FORMAT command works in Fortran IV. (You laugh: but I first programming a computer in FORTRAN II.) I just hope that someone doesn't end up saying, "Gee, that's nice, but we don't do C#. How's your Java?"
at the ferocious personal attacks that the left uses against conservative blacks or conservative women. All the talk of late is how the hard left end of the Democratic Party is now claiming that Palin's youngest, the one who was born with Down's Syndrome, is actually her daughter's child--and this was all an attempt to cover up the shame! What next? Oh dear, this is about the way the leftist mind works:
I heard the child was born to the daughter, fathered by Satan at midnight under a full moon that converged with the aurora borealis on a fur of a freshly killed and skinned polar bear and witnessed by Inuits that were duly appalled, but sworn to secrecy or their native lands would be drilled for oil and their salmon runs wasted. And later, the mother was seen eating raw Narwhal liver and then dancing naked in the snow and screeching an unearthly howl and seemed to be in a trance or on drugs or something. I read it on a website called "Don't vote for Palin or everybody dies."
I think the problem is that the left projects an awful lot of their own hypocrisy, immorality, and savagery on everyone that doesn't share their point of view. posted by Clayton at 7:03 PM permalink
Reversing a Doubly Linked List In Place
It actually only took me about ten minutes to sketch out--without the pressure of interviewers looking down my neck, and expecting an instant answer--and another ten minutes of actually typing in the code to create the linked list, traverse the list, and do the reverse. And once the compiler reminded me of the messy details of how to set up the struct and typedef statements for the linked list structure, it required no debugging.
int main (int argc, char* argv[]) { tNode* head; tNode* lastNode; tNode* node; tNode* oldPrev; tNode* oldNext;
/* Create the head. */ head = (tNode*)malloc(sizeof(tNode)); if (head) { head->prev = NULL; head->next = NULL; head->data = "George Washington"; /* Now add some more entries. */ lastNode = addNode(head, "John Adams"); lastNode = addNode(lastNode, "Thomas Jefferson"); lastNode = addNode(lastNode, "James Madison"); lastNode = addNode(lastNode, "James Monroe"); printf("From head to tail.\n"); /* Print the doubly linked list. */ for (node = head; node; node = node->next) printf("%s\n", node->data); /* Reverse the list. */ /* Find the end of the list. */ for (node = head; node->next; node = node->next) { } /* The end of the list will be the new head. */ head = node; /* Now start at the end of the list, and work backward. */ do { oldPrev = node->prev; oldNext = node->next; node->prev = oldNext; node->next = oldPrev; node = node->next; } while (node); printf("The list is reversed. From head to tail.\n"); /* Print the doubly linked list. */ for (node = head; node; node = node->next) printf("%s\n", node->data); } }
You know, there might be a place for programming like you are a character in 24, trying to solve technical problems in the next ten minutes as though millions of lives are at stake, but I'm not applying for Chloe O'Brian's job.
UPDATE: The more I think about this, the more I suspect that the test question just threw me for a loop and flustered me. If they had said, "Here's what we want to you write. We'll leave the room, and come back in 10-15 minutes to see how you are doing," I probably would have passed the test. But at that point, I had not been on a job interview with complete strangers in at least ten years. You live and you learn. Now, I just need to scare up some job interviews....
I have decided that the chances of finding a job in Boise are quite slim, because I don't have five years of C# experience. (I don't have any, other than what I have learned on my own time these last couple of weeks.) At this point, I'm looking only at positions in the Western U.S., because this makes it possible for me to at least come home perhaps every other weekend. The time and cost of doing some from other parts of the U.S. suddenly makes that part-time job at Big O Tires as a tire technician start to look like the lesser of two evils. posted by Clayton at 1:50 PM permalink