Here is a quickie shell script (bash) tip. If you ever want to insert a random sleep/pause into a running script:
sleep $[ ( $RANDOM % 10 ) + 1 ]s
This will introduce a 1-10 second random sleep/pause in the script. Can be handy at times.
Here is a quickie shell script (bash) tip. If you ever want to insert a random sleep/pause into a running script:
sleep $[ ( $RANDOM % 10 ) + 1 ]s
This will introduce a 1-10 second random sleep/pause in the script. Can be handy at times.
Posted at 11:35 AM in Web/Tech | Permalink | Comments (0) | TrackBack (0)
I recently decided to give the functional web testing framework Selenium (and the related premium test execution service, Sauce Labs) a trial run, using the Altos Research purchase workflow as a testbed. After a few hours of experimenting, I had run into a stone wall: Automating the test of an jquery autocomplete menu.
In the workflow I wanted to test, users are asked to type the first few letters of the name of a US County into a text field. An AJAX request is then triggered to find matching counties, and a list of matches is presented to users. It looks something like this:
Users are then expected to use the mouse or keyboard to select an item from the menu, which is then added to their shopping cart. Because this technique relies heavily on dynamically created DOM elements and jquery javascript, the normal Selenium Firefox macro recorder/IDE won't record any of the important events required to make the menu behave like it should.
After much experimentation and fiddling around with levers and knobs, I came up with the following successful sequence that would trigger Selenium to correctly invoke the autocomplete menu (the first four entries in this test case). The name of the text field on which the autocomplete is based is 'county_search'. The user will enter the letters 'lake', causing the server to search for all matching counties. One of those matches will be 'Lake County, IL':
The trick is in the XPath expression that tells Selenium how to select the item from the dynamically generated menu. As it turns out, the default behavior of the JQuery autocomplete widget is to render each item inside an anchor (<a>) within a list item (<li>). Or in other words:
<html><body><ul><li><a>Lake County, IL</a></li></ul></body></html>
When the script is converted to Java/Junit source code, it will look like this:
selenium.typeKeys("county_search", "lake");
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isTextPresent("Lake County, IL")) break; } catch (Exception e) {}
Thread.sleep(1000);
}
selenium.mouseOver("//html/body/ul/li/a[. = \"Lake County, IL\"]");
selenium.click("//html/body/ul/li/a[. = \"Lake County, IL\"]");
Posted at 11:01 AM in Web/Tech | Permalink | Comments (0) | TrackBack (0)
Long time friend and all around smart guy Steen Simonsen recently pointed out to me an excellent article published by the Cato Institute: "Restriction or Legalization? Measuring the Economic Benefits of Immigration Reform" (summary available on-line, and full PDF available for download). The conclusions drawn by the authors are similar to most macro-economic analyses of immigrant labor that I have read: Immigrant laborers have a net positive impact on both the national US economy as well as the local economies in which they are employed.
While reading through the paper, I found myself once again nodding in agreement with the analysis and recommendations. According to their modeling, a program of legalized immigrant labor combined with a moderate visa tax (paid for by employers) would have a net impact on the US GNP of +1.25% over the next decade. Policies that instead stressed border protection or employer punishment resulted in -0.55% decreases in the GNP.
This led me to ask "If the macro-economic models are so strongly in support of increased legalization of immigrant labor in the US, why did Arizonans just pass such a draconian anti-immigration law?"
My answer is that macro-economic effects are too abstract to factor into the micro-economic decision making process of the average US voter. In other words, it is impossibly hard for an individual US citizen to directly observe a 1.27% increase in the GNP. It cannot be seen or heard, making it all but impossible for most people to wrap their heads around it. Myself included.
As the recent list of Nobel Prizes in Economics emphasizing the importance of human psychology indicates, the behavior of economic participants (real people like you and me) is often far from purely rational. Rarely does anyone think to themselves "Well, this political decision will have a net positive economic impact on my life in the next ten years, therefore I will support this policy despite the undesirable economic conditions I find myself in today."
Instead, people make their political decisions based on the micro-economic environment they find themselves in on a daily basis. Unlike an increase in the GNP, they can 'see' the Mexican day laborers waiting outside their local Home Depot. They can 'see' the number of Mexican children in the classrooms at their local elementary school. They can 'hear' the Spanish conversation from the people in front of them at the grocery checkout line. These are all very observable effects, and because of that they exert a much stronger political influence on the voting preferences of the people in these situations.
Rightly or wrongly, many people will correlate these visible signs of Mexican immigration to their current undesirable economic situation. They do not need proof of causation, just what their senses tell them is a preponderance of correlation. "My life sucks, I see more and more Mexican immigrants in my community, therefore illegal immigration must be the cause of my crappy economic situation."
I wish there were a more visceral appeal that could be made to voters - a way to more directly demonstrate the positive impacts of increasing legal immigration. But until someone comes up with a solution to that problem, the inherent human xenophobic tendency will continue to win the political debate.
Posted at 10:09 AM in Economics, Politics | Permalink | Comments (0) | TrackBack (0)
I just received a fundraising request from MoveOn.org that opened with the following expression of indignation:
"Blue Cross has just announced that it's immediately raising premiums charged to hundreds of thousands of individual customers by as much as 39%—even though their parent company's profits soared to a record $4.7 billion last year. Even worse, the insurer has so far refused to explain why they're increasing their rates, and warned that they might do so again this year without warning."
The demand that MoveOn.org is making:
"Anthem Blue Cross must provide a detailed explanation for their exorbitant rate increases, or else roll them back immediately"
When I read that statement, the first thought that came to mind was: Besides Blue Cross customers and shareholder, who can vote with their dollars, what the heck gave MoveOn.org the idea that they should be able to override Blue Cross business decisions?
I am a business owner. If I decide to increase my prices, I may very well suffer the consequence of customers deciding to take their business elsewhere. Blue Cross certainly faces the same possible outcome. They answer to their share holders, and they answer to their customers. What obligation do that have to answer to MoveOn.org? None, as far as I can tell.
What I don't understand is where MoveOn.org got the idea that Blue Cross should somehow be compelled to explain their decision - or even reverse it. Does the government own and operate Blue Cross? No. Is MoveOn.org a significant shareholder in Blue Cross? No. Does MoveOn.org seem to think we operate in a centrally planned economy where 'the people' are entitled to hold private companies accountable to their demands? Apparently.
Posted at 05:37 PM in Politics | Permalink | Comments (2) | TrackBack (0)
Reading an article today on the accomplishments of the National Ignition Facility, I was somehow struck by the similarity in the design of the NIF and the Cerebro chamber, featured in the X-Men movies. Putting the images side-by-side shows just how strikingly similar they are:
Hmm - controlled nuclear fusion or mutant detection. You be the judge!
Posted at 09:25 AM in Film, Science | Permalink | Comments (0) | TrackBack (0)
Update #1 [Sunday, Jan 24th, 9:08am]: I have been experimenting with various encodings and bitrates to try and determine what 'works best'. So far, there is what I've settled upon:
Update #3 [Saturday, Feb 13, 9:09am]: In the most recent batch of encodings, I have migrated away from using AVCWare Total Video Converter to convert the video. Instead, I have opted for a two step video conversion process that starts with MakeMKV to extract the video and audio tracks from the files decrypted by AnyDVD HD, followed by the ever trusty HandBrake to convert that video+audio MKV file into the final form.
Here are screenshots of my Handbrake configuration:
Original Post:
Not too long ago I made the upgrade to the Android 2.0 enabled Moto Droid on Verizon. I'd been using the HTC Titan (a.k.a. VX6800) for a while, but accidentally dropped it in the toilet a while back and decided it was time to move on.
In general, I've been thrilled with the Moto Droid and with the Android platform in general. One thing that I wanted to be able to do was watch episodes of the Band of Brothers series that I had previously purchased on Blu-Ray Disc. I just hadn't made the time to watch these at home, and decided that watching them on the Droid while at the gym would be perfect.
After a bit of snooping, tweaking and futzing I put together the following recipe that will allow you to rip and convert Blu-Ray vdieo into a format suitable for perfect playback on the Moto Droid. This will probably work on other Android devices, although video dimensions and bitrates may differ. Also note that this is not free (as in beer) or free (as in speech) - it will require that you purchase two pieces of commercial software.
My list of ingredients:
The AnyDVD HD application is used to remove the encryption (a.k.a. DRM) from the video files stored on the Blu-Ray disc, allowing the files to be accessed. The AVCWare Total Video Converter is then used to convert the original Blu-Ray video files (stored in a format called AVCHD) into format that can be played on the Moto Droid (MP4 file format with MPEG4 video encoding and AAC audio encoding).
One the following tools have been installed, the process is actually quite simple:
Posted at 09:11 AM in Web/Tech | Permalink | Comments (0) | TrackBack (0)
I really do enjoy many of the articles available on-line from the British science mag New Scientist. I have no desire to subscribe to a printed edition - I know I won't read the paper version, and don't want it. So I attempted to find an 'on-line only' subscription.
Nope. Nada. Nuthin.
In order to gain unlimited access to the on-line articles, you must subscribe to the printed edition. So instead of allowing me to just pay them money for on-line access, they lose an on-line reader. Too bad. So sad.
Posted at 03:43 PM in Economics, Science | Permalink | Comments (0) | TrackBack (0)
Here is a head scratcher for you:
While investigating a customer-reported problem with one of Altos Research's WordPress Plugin, I had sent off a technical support request to GoDaddy.com's support team. The problem was being caused by HTTP 404 status codes being returned by server-side PHP scripts generating JSON-formatted output. This is a fairly typical thing for a PHP script to do as part of a modern AJAX-powered web application, and our WordPress plugin is one of those.
After Googling around a bit, I did come across another developer who'd experienced similar problems with a GoDaddy.com hosted application, as described in this StackOverflow.com question:
http://stackoverflow.com/questions/948116/ajax-404-with-results-using-buddypress
The solution is fairly simple, as it turns out (you must manually set an HTTP status code value of '200').
But before I'd come across this answer, I had decided to submit a description of the problem using the GoDaddy.com Technical Support form. About 5 hours later, I received the following answer:
"Ajax requires a Windows operating system; the domain welcomehomenwi.com is on a Linux server. To switch the operating system of your hosting account, please use the following instructions"
Huh? AJAX in the GoDaddy.com environment requires that you switch from a Linux-based host to a WIndows server? In either case, the WordPress plugin problem has been fixed, and it didn't require that our customer switch their hosting service to a Windows server. Sheesh.
Posted at 08:54 PM in Web/Tech | Permalink | Comments (0) | TrackBack (0)
For reasons I cannot quite explain, finding a downloadable mp3 recording of Barack Obama's Nobel Peace Prize acceptance speech proved rather difficult. I did finally manage to track down a good quality recording, and have made it available as an mp3 download here:
Obama-nobel-prize-acceptance-speech.mp3
If you haven't already heard it, the speech is worth a read/view/listen. If anything, throw the mp3 on your audio player and give it a listen during your commute to and from work. In the speech, Obama makes a compelling argument for the inevitability of war, for the necessity of war and for the moral justification of war. That is not a very comfortable argument to make while accepting an award with the word 'Peace' in the title.Posted at 09:32 PM in Current Affairs | Permalink | Comments (0) | TrackBack (0)
Apple has taken many well deserved punches for the opacity of the iPhone App Store approval process. However, Apple deserves major credit for finally breaking the suffocating control of the mobile service provider over the set applications that can be installed on a mobile device.
In my three years as an engineering manager at Motorola's Mobile Devices business unit, I was approached dozens of times by energetic mobile application entrepreneurs who all asked the same question:
"How do I get my application onto your phones?"
The only answer available at the time was:
"Talk to the mobile network operators (carriers). You'll need to negotiate the pre-installation of your application with each operator for each device they support. One at a time. It will be impossibly hard and likely to fail, so you should probably give up now."
At the time, I had no useful advice on how they could achieve the widespread distribution their business plan depended on. It was depressing.
I am now convinced that Apple and the iPhone App Store have finally cracked that nut. This article from the NYTimes triggered my change in attitude:
To quote:
"Still, the App Store is markedly better than the alternative, says Peter Farago, a marketing executive at Flurry, a mobile analytics company in San Francisco. Gone are the days when mobile developers had to negotiate with major telecommunications companies if they had any hopes of publishing their applications on a mobile phone.
“It took six to nine months to build a relationship with a carrier, maybe a quarter-million to get the infrastructure built, and the company took 50 percent or more from each dollar,” Mr. Farago says, a process that limited access to mobile platforms. “Apple has helped create a much healthier middle class of developers and expanded the pie for everyone.”
This is indeed a watershed period for the developer of mobile applications. The break between carrier and application control (AT&T + iPhone) now has the momentum. We already see signs of this spreading from carrier to carrier (Verizon, Sprint) and platform to platform (Android, WebOS, Blackberry).
Finally, a nice dose of free (free as in speech) in the world of mobile devices.
Posted at 07:19 PM in Economics, Web/Tech | Permalink | Comments (0) | TrackBack (0)