Tuesday, June 8, 2010

Javascript date as two digits

Javascript lacks some string manipulation functions that might be handy when trying to output a date as two digits.

I was trying to format a date as "YYYY-MM-DD" and discovered that there is no equivalent of right$ in Javascript. So I did it this way:

var day=new Date();
day>9 ? day.toString() : "0"+day;


If it matters, here is the code to render the date, making sure that days before the 10th and months before October include the leading zero character:

var now = new Date();
var month = now.getMonth()+1;
var day = now.getDate();
document.getElementById('date').value=now.getFullYear()+"-"+
(month > 9 ? month : "0" + month) + "-" +
(day > 9 ? day : "0" + day);

Wednesday, February 3, 2010

Why the Republicans are doomed

Bobo was an unfortunate child, born to unfortunate parents and given an unfortunate nickname. Because his parent's union was brief, and because they had little to contribute intellectually, he was raised mostly by the community. His body was not exactly deformed, but each feature tended towards the ugly side of normal.

What he lacked in brains, he more than made up for with hard work. Bobo lived with a traveling circus, a throwback to bygone days. He was up early, feeding the animals, cleaning up the grounds, and generally helping out wherever there was manual labor to be done.

He loved the elephants. He envied the handlers and their close relationship with the mostly gentle giants. For 50 years, he tended the elephants, carrying water for them to drink, and making sure that there was adequate straw.

One day, the ringmaster fell ill and died. The troupe that Bobo lived with was a close-knit group, and after a few generations had become somewhat inbred. This of course contributed to the posters that said "Bobo for Ringmaster! Vote Bobo!"

It was the accepted wisdom of the group that Bobo would be anointed as Ringmaster. After all, he had spent most of his life carrying water to the elephant. And of course, the common wisdom prevailed, and Bobo became the Ringmaster.

You can guess what happened next. Bobo had no Ringmaster skills. He couldn't schedule performances, he could not reconcile the differences between performers. He could not even make that snapping noise with his inherited whip. Performances suffered, ticket revenue plummeted, and one by one, the various performers packed up their trailers and went looking for another troupe to join.



The Republican party should not be a meritocracy. Leadership skills are not learned by endurance, but by experience. If you show up to every caucus, every convention, every lit drop, and every fund raiser, all that it proves is that you know how to work. Leading is not the same thing - that's why business is divided into management and labor. Each must bloom where they are planted.

I am a Republican, and I want it known that endorsing a candidate based on their ability to carry water to the elephant (a clever euphemism for supporting the party) is simply a dumb, inbred idea. It is group-think run amok.

In 1994, the Republicans stood Washington on it's ear with the Contract with America. Riding the tide of disappointment with "It's the economy, stupid!" President Clinton, Republicans swept the House and held a majority for the first time in 40 years. They then proceeded to balance the budget, at least for a few years. Then, the Freshman class of the 104th Congress set about turning into Democrats.

Power corrupts. Eventually, the Republican majority lost their vision and their memory of what they had come to Washington to do. And then they lost their seats. We need to take back the House in order to save America from rampant progressivism. But we also need to remember that even the best Republicans don't stay conservative for long after they get a taste for opium (OPM, Other People's Money). Put them in, but then flush them out before they get worthless.

And above all, don't vote for Bobo. A long history of carrying water to the elephant is not a substitute for leadership, integrity, and brains. We don't need strong backs in Congress, we need wise heads. Find one and vote for it, no matter the gender or the race or the party of the body that it is attached to.

If you don't, then the Republican party - and all the rest of America, in fact - is doomed.

Monday, February 1, 2010

How about this for a new law...

I just read about a wealthy man who stopped making payments on his house. He is upside-down in his mortgage, so he simply stopped making payments and is living cost-free in the house until the bank forecloses. That's a minimum of 6 months, probably more like two years because of the foreclosure backlog.

Meanwhile, the US Taxpayer is bailing out his bank.

That means a wealthy man who can afford the monthly payments is taking money out of our pockets to pay for a very nice house. Somehow seems wrong, doesn't it?

When the bank loans me money, their first collateral is my good name. They know I will pay the payments in a timely manner because I have a good credit score and I have some integrity. I don't just bail on a loan and let other people pay my debts. The secondary collateral is the house, because if they were wrong about my good name, there is still something of value that they can take and redeem to protect their other investors, and the taxpayer who is the ultimate fail-safe for the bankers.

I'd like to propose a new law that makes it a federal crime for a person or corporation to stop making payments on a taxpayer-insured loan when the borrower can clearly afford to make the payments. Since the risk has been spread to all tax payers, robbing from all tax payers by failing to make an affordable payment is tantamount to theft by swindle, and should be punishable as such.

"Taxpayer insured loans" include anything handled by Fannie Mae or Freddie Mac, or insured by AIG, or made through any other bank that received TARP funds, or any other loan that ultimately will hurt the taxpayers if there is a default.

For punishment, I would suggest 25 years in prison (adjusted for the remaining term on the loan), and confiscation of all unencumbered personal property. Sell the personal property at auction to help settle the mortgage debt. Since the debtor will be in prison for the foreseeable future, they won't need that big-screen TV anyhow.

For corporations defaulting on such debts (and they do it with distressing regularity), the government should dismantle and disband that corporation and jail it's board of directors and every executive above the level where the decision to screw the taxpayers was made. Put some teeth in the law; too long the rich and the powerful have stolen from the masses using the law and the government as a stooge. Oh, that hurts the other employees and the investors? Yes. The investors took an educated risk when they loaned money to the company. The employees will be sold along with the division that they worked for.

Think what this threat will do to corporate culture. Suddenly the middle manager who proposes screwing the bank or the taxpayer is a pariah, rather than a hero. Integrity will increase. There will be a personal motivation for every employee and every stockholder to encourage corporate ethics. How is this a bad thing?

Perhaps I am too harsh on people who default on their loans when they can make the payments. After all, it's not their fault that the housing market plummeted, right? No, it is not. But it's not my fault that my son had an emergency appendectomy last year... but I still had to cough up the three thousand dollars that my insurance did not cover. It's not my fault that Haiti had an earthquake, but my tax dollars and my personal charity are going there. It's not my fault that Katrina hit New Orleans, but I got to help pay for that mess, too.

Being responsible and grown up means that you get to pay for things that were not your fault. That's how we are; we spread the risk. I don't mind paying to help after natural disasters. I don't mind paying for the guy who cannot get a job. What I have a problem with is paying for the mortgage of the person who has the financial resources to pay, and who promised to pay, but then changed his mind while he could still afford the payments.

My hope in asking for this law is that it will never need to be enforced; that the threat of consequences will deter people and corporations from demanding that all of us taxpayers foot the bill for their greed and foolishness. I may be a little naive here; perhaps there are people who are willing to risk it all to screw the rest of us. For those people, perhaps the Department of Homeland Security should be involved.

Who is with me on this?

Thursday, January 21, 2010

The secret of prosperity

I've run out of text from the book that I once tried to write; it's time to move on to do some real blogging (not the copy-and-paste variety).

Recently I have been perusing a 2007 edition of a 400-year-old translation of a 13th century copy of a 2000-year-old document, and in doing so, I stumbled across the secret of wealth. It is something that anyone can do, but few want to.

Everyone wants money, and everyone who has it wants more of it. Most of us feel that we don't have enough money, so we fall victim to this scam and that program. We send money in response to various advertisements that promise to reveal the secret of wealth. And we do so with the suspicion that the secret might start out "First, take out an ad that starts with How to get rich..." No, that's not the secret.

But in these ancient writings, I have found the awful secret. The secret to prosperity is something that we've been conditioned to avoid. I know people who shun the very appearance of this secret thing that can, in fact, make you rich.

One of the reasons that the United States of America is in serious trouble today is because so many people make it their life's mission to avoid doing the one thing that could make them wealthy. The government for years has rewarded millions of people for not doing this one thing that could make them wealthy.

It started in the 1930s, when a few farmers were paid cash bonuses for not doing this secret thing. In the 1960s this program was expanded to include people in the cities, and has since increased to the point where the government spent $577,000,000,000 dollars just in 2009 to keep people from taking advantage of the one thing that could make them truly wealthy.

$577 billion dollars was about 4% of the U.S. Gross Domestic Product for 2009. That means that out of every dollar's worth of goods that you produced, four cents went into a program that helps people to avoid wealth! How incredibly stupid is that?

You've read far enough. It's time to reveal the age-old secret to wealth that people have been trying to avoid. I'm not asking you to send me money, I'm going to tell you the secret for free. Be advised, however, that the secret to wealth is a four-letter word. This is not for the faint of heart - but for the few who have studied and perfected it's techniques, the rewards have been stunning.

Bill Gates does it. Warren Buffet does it. The CEO of IBM got there by doing it. And you can do it too - if you are willing to put aside your very natural aversion to it. Most people who do it freely admit that they will only do it as long as they absolutely have to, and they look forward to the day when they won't have to do it any more. We pity the poor fools who become addicted to it, and vow never to become one of them. It really is that bad.

Ready?

Here it is.

The secret to prosperity is . . .

Work.

That's right; I said it. Right out loud (as I was typing). I'm not ashamed of it. I enjoy it. And I look forward to doing it for as long as I can.

In the New Living Translation, Proverbs 13:4 says "Lazy people want much but get little, but those who work hard will prosper"

There you have it - from God's word to your eyes - the secret to prosperity is work. There are no shortcuts. Now, close the browser and go do some of it. That's what I'm about to do.