The migration turned out to be a whole bunch easier than expected. Three cheers for WordPress' built-in Blogger migration support. It's not 100% perfect, and I'm not set on the theme either, but it's good enough to kiss Blogger goodbye.
Update your bookmarks: http://blog.probonogeek.org
Update your feed readers: http://blog.probonogeek.org/feed
Thanks for all the good times, hope to see you 'round me new place.
Sunday, February 15, 2009
Time for a Change
I started this blog with a tip of the hat to my earlier efforts at an online journal and a hope that Blogger would be a more permanent home than past attempts. By any objective measure, Blogger has been a complete success, clocking a total of 289 posts since April of 2005. Less prolific than, say, Wonkette's twenty posts a day, but not too shabby for a dude whose never kept a blog longer than a year.
Recently, I've grown frustrated with Blogger. It's a fine platform, and having someone else deal with the hosting is certainly a plus... but in the end, it's a service over which I have no control. It does exactly what Google wants it to do, and nothing more. For a long time I didn't want more... but times, they are a changing. The first hint of longing came when friends launched two new blogs with WordPress, Minor Failures and GeekBeer. Both blogs have gravatar support, an idea with which I am absolutely smitten. Then, most recently, I posted some code examples and found the Blogger support for showing that code was most disappointing. Combined with the byzantine themeing system, the inability to change the blog's domain name, and the general need to refresh the look & feel of the site; one gets a very compelling case to switch blogging platforms.
I administer dozens of WordPress blogs for work and thus have a deal of familiarity not only with general hosting and administration concerns, but also the internal code structure. PHP isn't my first choice of languages, but it's always fun to contribute when you can. So, gentle readers, this marks my last second-to-last post with Blogger. I'm going to take a few days to write a conversion script that will port as much content as possible from the old blog to the new one and find a reasonable theme from which to start customization. Soon as the new blog isn't embarrassing to look at, I will switch the Apache configuration so that blog.probonogeek.org points to the WordPress deployment instead of redirecting you to Blogger. Once that is done I will make a final post letting readers know where the new RSS feed is at and then leave good old reliable http://probonogeek.blogspot.com behind.
Recently, I've grown frustrated with Blogger. It's a fine platform, and having someone else deal with the hosting is certainly a plus... but in the end, it's a service over which I have no control. It does exactly what Google wants it to do, and nothing more. For a long time I didn't want more... but times, they are a changing. The first hint of longing came when friends launched two new blogs with WordPress, Minor Failures and GeekBeer. Both blogs have gravatar support, an idea with which I am absolutely smitten. Then, most recently, I posted some code examples and found the Blogger support for showing that code was most disappointing. Combined with the byzantine themeing system, the inability to change the blog's domain name, and the general need to refresh the look & feel of the site; one gets a very compelling case to switch blogging platforms.
I administer dozens of WordPress blogs for work and thus have a deal of familiarity not only with general hosting and administration concerns, but also the internal code structure. PHP isn't my first choice of languages, but it's always fun to contribute when you can. So, gentle readers, this marks my last second-to-last post with Blogger. I'm going to take a few days to write a conversion script that will port as much content as possible from the old blog to the new one and find a reasonable theme from which to start customization. Soon as the new blog isn't embarrassing to look at, I will switch the Apache configuration so that blog.probonogeek.org points to the WordPress deployment instead of redirecting you to Blogger. Once that is done I will make a final post letting readers know where the new RSS feed is at and then leave good old reliable http://probonogeek.blogspot.com behind.
Wednesday, February 11, 2009
The Trouble with Enumerables
Quite a lot of political postings for what's suppose to be a technical journal recently... time for a return to our traditional values!
Today's topic is Enumerables. Originally I thought this post was going to be about iterators, but on reflection, iterators aren't really the trouble here... but I'm getting ahead of myself. Ruby, dynamic scripting language of MVC fame, has this Enumerable concept. What it does is takes a set of objects and performs actions on that set of objects, sometimes returning a modified set, sometimes returning a single element from the set. The available actions are known as iterators, and some of the more common ones are each, select, and collect.
The underlying mechanic for all of these iterators is the each iterator, that does nothing more than return each item in the set, one at a time. You can then wrap the each iterator with additional functionality to generate all the additional iterators... so, if you wanted to go through each item in the set until you find an item that meets an established criteria, you would use detect. Or, if you wanted all of the items that meet the criteria, you would use select. The big upside is that you get really clean looking code since you are using all this built in magic instead of writing your own.
Let's look at a bit of code to see what I'm talking about. We start with an array of hashes describing a person, with their name and address:
But, the truth is, sets of data are not equal in the eye's of their maker. In fact, in the dynamic language world there are really two different kinds of sets, each with their own particular strengths and weaknesses. On one hand, you have the arrays, which is ordered data, meaning that each item in the set is stored in a specific order, 0..n, and you can loop through that safe in the knowledge that you're going to get the data in the same order every time. On the other hand you have hashes, which is keyed data, meaning that each item is stored based on a hashed key value, such that you can find it again quickly by just repeating the hash algorithm.
Let's return to the code example from above. I used an array there, but if I know I want to use that data to find addresses based on a name, it would be much faster if I used a hash that looked like this:
Which is why Enumerables are trouble. Because they are so darn easy to use they hide the fact that you may have traded a possible constant time function for a linear time function with no actual gain in functionality.
So, my fellow ruby developers (and any other language that has enumerable like functionality), the next time you reach for your favorite iterator, ask yourself, am I using this because it's easy and looks clean, or am I using it because it's the best tool for the job? There are plenty of good reasons to using an enumerable, but if your sole reason is because it's "easy and clean," then you are only asking for trouble down the road when you put your code into production and suddenly that array of four items you tested during development has become 4,000 items and that one function is slowing everything down, to say nothing of all the other functions where you made the same short-sighted decision.
Today's topic is Enumerables. Originally I thought this post was going to be about iterators, but on reflection, iterators aren't really the trouble here... but I'm getting ahead of myself. Ruby, dynamic scripting language of MVC fame, has this Enumerable concept. What it does is takes a set of objects and performs actions on that set of objects, sometimes returning a modified set, sometimes returning a single element from the set. The available actions are known as iterators, and some of the more common ones are each, select, and collect.
The underlying mechanic for all of these iterators is the each iterator, that does nothing more than return each item in the set, one at a time. You can then wrap the each iterator with additional functionality to generate all the additional iterators... so, if you wanted to go through each item in the set until you find an item that meets an established criteria, you would use detect. Or, if you wanted all of the items that meet the criteria, you would use select. The big upside is that you get really clean looking code since you are using all this built in magic instead of writing your own.
Let's look at a bit of code to see what I'm talking about. We start with an array of hashes describing a person, with their name and address:
person_array = [
{
:name => 'alice',
:address => '123 Fake Street'
},{
:name => 'bob',
:address => '1600 Pennsylvania Avenue'
},{
:name => 'charlie'
:address => 'Infinite Loop'
}
]
Now, we want to know alice's address, so we can use the detect iterator to find a hash with a :name value that equals "alice" person = person_array.detect { |person| person[:name] == 'alice' }
puts person[:address]
Which, one must admit, is pretty slick. In that one little line of code we go all the looping, variable checking, and returning behavior. You can even take it a step further and wrap the whole thing in a method: def address_for(name,person_array)
person = person_array.detect { |person| person[:name] == name }
return person[:address]
end
Now, you're probably asking, if I think all of this is so slick, why title this post The Trouble with Enumerables? The reason these little guys are trouble is because they can hide inefficient implementations behind clean looking code because it teaches developers to treat all sets of data as equivalent.But, the truth is, sets of data are not equal in the eye's of their maker. In fact, in the dynamic language world there are really two different kinds of sets, each with their own particular strengths and weaknesses. On one hand, you have the arrays, which is ordered data, meaning that each item in the set is stored in a specific order, 0..n, and you can loop through that safe in the knowledge that you're going to get the data in the same order every time. On the other hand you have hashes, which is keyed data, meaning that each item is stored based on a hashed key value, such that you can find it again quickly by just repeating the hash algorithm.
Let's return to the code example from above. I used an array there, but if I know I want to use that data to find addresses based on a name, it would be much faster if I used a hash that looked like this:
person_hash = {
:alice => '123 Fake Street',
:bob => '1600 Pennsylvania Avenue',
:charlie => 'Infinite Loop'
}
Then to access alice's address all we would need to do is: puts person_hash[:alice]
We can even wrap it in the same method as above: def address_for(name,person_hash)
return person_hash[name]
end
Now, the output is the same in both cases, "123 Fake Street", but the two implementations differ in important ways. The first one (with the array) is an O(n) speed function, meaning that to find the desired result under the worse case scenario, it will take n runs of the function to do so (n being the number of items in the array). That's because we have to look at each item in the array to see which one has a :name value of "alice". The second implementation (with the hash) is just O(1), or whatever constant number you want to put in between the parentheses. No matter how many items are in the hash, it will take the same amount of time to find alice's address.Which is why Enumerables are trouble. Because they are so darn easy to use they hide the fact that you may have traded a possible constant time function for a linear time function with no actual gain in functionality.
So, my fellow ruby developers (and any other language that has enumerable like functionality), the next time you reach for your favorite iterator, ask yourself, am I using this because it's easy and looks clean, or am I using it because it's the best tool for the job? There are plenty of good reasons to using an enumerable, but if your sole reason is because it's "easy and clean," then you are only asking for trouble down the road when you put your code into production and suddenly that array of four items you tested during development has become 4,000 items and that one function is slowing everything down, to say nothing of all the other functions where you made the same short-sighted decision.
Monday, February 09, 2009
Thoughts on Stimulus
Sen. Arlen Specter (R-PA) has a piece in the Washington Post this morning entitled, Why I Support the Stimulus. Beside the rather boring title, I think -- in general -- I agree. There has been much machination about how the Obama administration failed to play this properly, but I think that's wrong... both in function and form.
Functionally, this is a stimulus bill (though, I prefer the term recovery bill, not sure why that language isn't used more frequently) whose primary purpose is to get the economy moving through a large scale injection of government spending. Period, full stop. It is not a green energy bill, or a universal health care bill, or an education reform bill. Those partisans who saw the stimulus as an opportunity to attach their personal pet project, regardless of how meretricious the idea might be, are guilty of the same sin as when the Republicans used September 11th to push through only tangentially related policy objectives through a hurried congressional approval process.
Specter, a moderate Republican, has joined with other Senate moderates to trim many of these programs. The folks over at Think Progress' Wonk Room would have you believe the sky is falling and that these Senators oppose the programs they are either eliminating or reducing. But there is little evidence of that, and Specter admits that many of the programs being cut are "worthy in themselves." But his point is that we have an appropriations process for this sort of thing, and with that process comes deliberation, transparency, and accountability. Just as anti-war activists were angered by the Bush Administration's refusal to fund the Iraq War through the normal appropriations in an effort to hide the real cost, so too should we be angry when any other administration tries to go through the back door.
Which brings us to form. This isn't a game! Do you hear me Nate Silver. Obama did not run -- and he did not win -- on the argument that he was going to get his way every time. He was elected on the premise that government is broken because we treat it like a game. There is this great story, which I can't seem to find online now, that I first heard reported on the Daily Show. Leading up to the 2006 midterm elections, where the polls suggested the Democrats where going to seize power in the House (the Senate was still too close to call), a White House official was asked how Bush was going to work together with the new Democratic Committee Chairs. The official responded with a glib response about how, "we are playing this game to win it," implying the Administration wasn't going to entertain the idea that the Republicans would lose their majority. Then, in a moment of absolute political honesty, a reporter gave a follow up... "It isn't a game. The American people want to know how you are going to govern."
And the dude was absolutely right. I've been in politics, I know it's easy to treat the whole thing like a game, with pieces you move around the board and objectives achieved. But this is real life, it has real consequences, and developing strategies based on the philosophy that this is a game, and not governing, is exactly what Obama ran against. He is governing, best he knows how, and helping forge a stimulus bill he believes will get America moving again. The rest of the Congress, they are governing too, in their own way and with their own priorities. But we shouldn't treat this as a game, and we shouldn't say anyone played anything right or wrong. It's not about winning and losing, it's about the our lives.
Functionally, this is a stimulus bill (though, I prefer the term recovery bill, not sure why that language isn't used more frequently) whose primary purpose is to get the economy moving through a large scale injection of government spending. Period, full stop. It is not a green energy bill, or a universal health care bill, or an education reform bill. Those partisans who saw the stimulus as an opportunity to attach their personal pet project, regardless of how meretricious the idea might be, are guilty of the same sin as when the Republicans used September 11th to push through only tangentially related policy objectives through a hurried congressional approval process.
Specter, a moderate Republican, has joined with other Senate moderates to trim many of these programs. The folks over at Think Progress' Wonk Room would have you believe the sky is falling and that these Senators oppose the programs they are either eliminating or reducing. But there is little evidence of that, and Specter admits that many of the programs being cut are "worthy in themselves." But his point is that we have an appropriations process for this sort of thing, and with that process comes deliberation, transparency, and accountability. Just as anti-war activists were angered by the Bush Administration's refusal to fund the Iraq War through the normal appropriations in an effort to hide the real cost, so too should we be angry when any other administration tries to go through the back door.
Which brings us to form. This isn't a game! Do you hear me Nate Silver. Obama did not run -- and he did not win -- on the argument that he was going to get his way every time. He was elected on the premise that government is broken because we treat it like a game. There is this great story, which I can't seem to find online now, that I first heard reported on the Daily Show. Leading up to the 2006 midterm elections, where the polls suggested the Democrats where going to seize power in the House (the Senate was still too close to call), a White House official was asked how Bush was going to work together with the new Democratic Committee Chairs. The official responded with a glib response about how, "we are playing this game to win it," implying the Administration wasn't going to entertain the idea that the Republicans would lose their majority. Then, in a moment of absolute political honesty, a reporter gave a follow up... "It isn't a game. The American people want to know how you are going to govern."
And the dude was absolutely right. I've been in politics, I know it's easy to treat the whole thing like a game, with pieces you move around the board and objectives achieved. But this is real life, it has real consequences, and developing strategies based on the philosophy that this is a game, and not governing, is exactly what Obama ran against. He is governing, best he knows how, and helping forge a stimulus bill he believes will get America moving again. The rest of the Congress, they are governing too, in their own way and with their own priorities. But we shouldn't treat this as a game, and we shouldn't say anyone played anything right or wrong. It's not about winning and losing, it's about the our lives.
Tuesday, February 03, 2009
A Bad Day for American Health Care Reform?
Today Sen. Tom Daschle, former Senate Majority Leader from South Dakota, asked President Obama to withdraw his nomination as Secretary of Health and Human Services. I will admit that when Daschle was first nominated, I was very excited. I thought, here was a man who knows the Senate better than most, is a passionate advocate for change in health care, and may be the one guy who can shepherd universal health care through the Congress. I honestly don't know how he would perform as an administrator, but you can solve that with a good Deputy Secretary. But this guy, this guy was going to make the politics happen.
However, I cannot agree with Sen. Kerry's comment following today's announcement.
If you had asked me before last year's tax season, I might have had a different feeling. Last year I fretted extensively about my taxes because so much of my income was as an independent contractor. As I had failed to make quarterly installments, I had a significant tax burden to pay... and I had to save and scrimp for months to come up with the money by April 15. I didn't have to do that -- a lot of what I earned never got reported as 1099 income -- but I reported it anyway because the law is clear. The law was equally clear for Sen. Daschle, as it is for rest American upper class who seems to be engaging in massive and widespread tax fraud. I wonder, how many people making over a million dollars annually in this country would pass through this kind of scrutiny? It sort of make sense, if you think about it... try and skim off as much off your taxes as you can and bet that if you do get caught, you'll get the mess cleared up through lawyers. It's a win-win... unless you are the average tax payer who can't afford tax lawyers and whose only real option is to pay to the best of their ability and pray they aren't audited.
Yes, I too wish Sen. Daschle could have served as the new Secretary of Health and Human Services, but I wish even more that he had shown a basic level of respect to his fellow citizens and the law and shouldered his share of the burden, instead of trying to get away with tax evasion until suddenly it became a political issue.
It's just like John Stewart said on the Daily Show.... "pay your f*cking taxes."
However, I cannot agree with Sen. Kerry's comment following today's announcement.
I wish Tom Daschle had not decided to withdraw his nomination... While Tom’s decision is a reminder of his loyalty to President Obama and his determination not to be a distraction, this was no ordinary appointment and today is not a good day for the cause of health care reform.With all due respect to Sen. Kerry, today is not the bad day for the cause of health care reform. The bad day was when Sen. Daschle, a man who served on the Finance Committee of the United State Senate (they write the tax code), failed in his basic obligation to pay his taxes. This isn't the sort of difficult to understand tax situation, like with Sec. Geithner, this is an obvious case of either gross negligence or willful evasion.
If you had asked me before last year's tax season, I might have had a different feeling. Last year I fretted extensively about my taxes because so much of my income was as an independent contractor. As I had failed to make quarterly installments, I had a significant tax burden to pay... and I had to save and scrimp for months to come up with the money by April 15. I didn't have to do that -- a lot of what I earned never got reported as 1099 income -- but I reported it anyway because the law is clear. The law was equally clear for Sen. Daschle, as it is for rest American upper class who seems to be engaging in massive and widespread tax fraud. I wonder, how many people making over a million dollars annually in this country would pass through this kind of scrutiny? It sort of make sense, if you think about it... try and skim off as much off your taxes as you can and bet that if you do get caught, you'll get the mess cleared up through lawyers. It's a win-win... unless you are the average tax payer who can't afford tax lawyers and whose only real option is to pay to the best of their ability and pray they aren't audited.
Yes, I too wish Sen. Daschle could have served as the new Secretary of Health and Human Services, but I wish even more that he had shown a basic level of respect to his fellow citizens and the law and shouldered his share of the burden, instead of trying to get away with tax evasion until suddenly it became a political issue.
It's just like John Stewart said on the Daily Show.... "pay your f*cking taxes."
Sunday, January 25, 2009
Frost/Nixon
This afternoon Sarah and I took in a matinée at the local two screen cineplex, finally seeing Frost/Nixon. If you are a fan of political biographies, I highly recommend it. The movie centers around a series of interviews between David Frost, a British talk show personality, and Richard M. Nixon, the 37th President of the United States.
Two things really struck me about the movie...
First, what would it take for a modern day politician to agree to a series of interviews on such a broad range of subjects with no editorial control? Where are the interviews with Roland Regan, George H. W. Bush, or Bill Clinton? Sure, they have memoirs -- tightly controller spin jobs designed to white-wash the record for the sake of legacy -- but where is the inquisitor? Who forces our political leaders to see beyond their own self-image and face the facts of their administration? Say what you will about Richard Nixon, but it took guts to agree to that interview, and it showed a nature of his character you don't often see.
Second, I think my young age takes me out of the target demo for this movie. Viewers are supposed to be rooting against Nixon, or at least rooting for his eventual admission... which is not to saw I wasn't. But I found I was doing it more out of a desire for a NASCAR crash than for some sort of political reckoning. Perhaps if I were of the Watergate generation, I would feel an attachment... but Nixon was so long ago for me that the movie could have just as easily been about Ulysses S. Grant. Which begs the question: what will future generations think of our rage towards the Bush Administration?
Two things really struck me about the movie...
First, what would it take for a modern day politician to agree to a series of interviews on such a broad range of subjects with no editorial control? Where are the interviews with Roland Regan, George H. W. Bush, or Bill Clinton? Sure, they have memoirs -- tightly controller spin jobs designed to white-wash the record for the sake of legacy -- but where is the inquisitor? Who forces our political leaders to see beyond their own self-image and face the facts of their administration? Say what you will about Richard Nixon, but it took guts to agree to that interview, and it showed a nature of his character you don't often see.
Second, I think my young age takes me out of the target demo for this movie. Viewers are supposed to be rooting against Nixon, or at least rooting for his eventual admission... which is not to saw I wasn't. But I found I was doing it more out of a desire for a NASCAR crash than for some sort of political reckoning. Perhaps if I were of the Watergate generation, I would feel an attachment... but Nixon was so long ago for me that the movie could have just as easily been about Ulysses S. Grant. Which begs the question: what will future generations think of our rage towards the Bush Administration?
Tuesday, January 20, 2009
Reflections on the new Administration
As I watch the Obamas dance in, what I am told, is their fifth ball of the evening, I can't help but pen some thoughts on the new Administration and what it means to me. CNN reports a crowd of 2.2 million were on hand to see the speech in person and there were predictions that the TV viewership would surpass any other TV event in history. Polling indicates that President Obama enjoys higher approval ratings than any incoming President. Globally... well, all I can is my Aunt -- my Aunt who lives in Nicaragua and has more or less dedicated her life to fighting U.S. policy in Latin America -- is genuinely proud of her country's President, and may even, one day, call him her President.
Obama is now at the Western Ball, which includes not only my home state of Washington, but my adopted state of California. Seems like a good time to think about what this all means for me. I already wrote a few words about transitioning from the Loyal Opposition to the Party in Power. But there are other personal implications. For example, this is the very first time I have voted for a winning presidential candidate. It's also the first time I gave any serious money to a candidate... like, got fancy high donor letters thanking me sort of serious. It's the first time I feel like I contributed, both morally and materially, to a campaign that mattered.
It's also a great honor to know people who are preparing to join the White House staff. For the first time my generation is in a position to contribute in a very direct way to our nation. They may not be the most high level jobs ever, but they are in the halls of power and they begin the process of training to, one day, run the nation. My hat is off to them, for their sacrifice (those jobs don't pay well, or offer much in the way of rest and relaxation) and for accepting the heavy burden that comes with being the future. I hope some day I can join them.
To the Administration as a whole, I have but a few words. I told one of my friends who is starting a new White House job that they will have the unique opportunity to make the world a better place, and not just in the metaphorical sense... they could actually go into the office in the morning, and thanks to their work, come out that evening the world would actually be a better place. After saying it, I realized I had transfered my unrealistic expectations of Obama onto his team... which I suppose is only natural, if a tad unfair.
My words then, are this... it's okay to fail in meeting our soaring expectations. But it is not okay to fail alone. The government of America is powerful and can do great things, but the people of America are more powerful yet and we are your greatest resource. If you try to carry the burden alone, and fail, you will not only have squandered an opportunity, you will have turned against the ideals of the campaign you work for. Have enough humility to understand your limitations and seek the wisdom of your fellow countrymen as you seek to fulfill our greatest destiny.
With that I say, good luck America. We've done a great thing today but much remains to be done. Let's roll up our sleeves and get to work.
Obama is now at the Western Ball, which includes not only my home state of Washington, but my adopted state of California. Seems like a good time to think about what this all means for me. I already wrote a few words about transitioning from the Loyal Opposition to the Party in Power. But there are other personal implications. For example, this is the very first time I have voted for a winning presidential candidate. It's also the first time I gave any serious money to a candidate... like, got fancy high donor letters thanking me sort of serious. It's the first time I feel like I contributed, both morally and materially, to a campaign that mattered.
It's also a great honor to know people who are preparing to join the White House staff. For the first time my generation is in a position to contribute in a very direct way to our nation. They may not be the most high level jobs ever, but they are in the halls of power and they begin the process of training to, one day, run the nation. My hat is off to them, for their sacrifice (those jobs don't pay well, or offer much in the way of rest and relaxation) and for accepting the heavy burden that comes with being the future. I hope some day I can join them.
To the Administration as a whole, I have but a few words. I told one of my friends who is starting a new White House job that they will have the unique opportunity to make the world a better place, and not just in the metaphorical sense... they could actually go into the office in the morning, and thanks to their work, come out that evening the world would actually be a better place. After saying it, I realized I had transfered my unrealistic expectations of Obama onto his team... which I suppose is only natural, if a tad unfair.
My words then, are this... it's okay to fail in meeting our soaring expectations. But it is not okay to fail alone. The government of America is powerful and can do great things, but the people of America are more powerful yet and we are your greatest resource. If you try to carry the burden alone, and fail, you will not only have squandered an opportunity, you will have turned against the ideals of the campaign you work for. Have enough humility to understand your limitations and seek the wisdom of your fellow countrymen as you seek to fulfill our greatest destiny.
With that I say, good luck America. We've done a great thing today but much remains to be done. Let's roll up our sleeves and get to work.
Subscribe to:
Posts (Atom)