Using Mechanize to download images from Stock Exchange
I wanted to download several images from stock.xchng and thought this would be a good time to learn how to screen scrape with Mechanize.
It turns out it is pretty simple. This is why I love Ruby and the Rails community.
Branding: EVO, Droid X, Captivate, Galaxy S, Epic, etc. vs iPhone
This morning while reading Crunchgear I came across a review for the Samsung Galaxy S. The blurb to the article made my brain hurt.
There are a total of five Galaxy S-based handsets: The AT&T Captivate, which I have here in my hand, the T-Mobile Vibrant, the Verizon Fascinate (identical to the Vibrant except for an LED flash), the Sprint Epic 4G (with slide-out keyboard), and the “vanilla” international Galaxy S. They’re much the same but have some features setting them apart, mainly in the body department. Even so, the experience on one should be pretty similar to the experience for another, so consider this our review of the Galaxy S line — with the caveat that your mileage may vary slightly on the other models.
All the models listed there are for ONE phone from ONE company. This is nuts. Now if you start adding all the other Android phones in the market like EVO, Droid X, etc. you start realizing that these companies have no chance against Apple marketing.
I consider myself a techie and I can hardly keep up with all these names, imagine how well the average Joe keeps up. The only unifying brand is Android and I dare you to ask a lay person what that is. I can just imagine the blank stare. Now I know from experience that everyone knows iPhone. Simple, one company, one brand, one phone. Did these people not learn anything from “Intel Inside.” This is basic stuff people. A friend posted a picture of his new Droid X and what brand stood out most to me when I saw the picture? Verizon.
If Google wants to have a shot at Apple, it should get some marketing behind Android and work with device manufacturers to unite under the Android brand instead of creating one phone with 5 names. When I saw Palm not focusing on one simple Pre model I saw their end, I feel like a fortune teller again with the mess that is the android device marketplace.
Post with Echofon Bookmarklet
I couldn’t find a good bookmarklet for Echofon like the one I had been using for Tweetie, so I modified that one to work with Echofon. Just drag the link below to your bookmarks toolbar. Enjoy
The Secret to Losing Weight by David Heinemeier Hansson (or what he would say)
Disclaimer: David had nothing to do with this post, but I am a big fan of his and I have watched several of his speeches like this one. His words (or my version of them) been my inspiration for losing weight over the last month and a half.
I have created a book for losing weight in the form of DHH. It’s embedded below for free, enjoy:
The background for the book
Over the years my wife would come to me and mention how she wanted to join some program like Weight Watchers and every time I would say “Give me the money and I will tell you to not eat so much.” She would moan and grown about her weight about once a year, but about 6 months ago she started reducing her caloric intake. Without counting points she switched to eating smaller portions for lunch and dinner and she began eating a lot more vegetables. This has worked for her, she has lost weight and is very happy with her results. Her mantra was “Nothing tastes as good as Skinny feels” We heard that from some skinny girl on a reality show, don’t remember where.
I had kept my same routine, but in January I finally thought I needed to loose some weight after speaking to a friend who had managed to do just that. He had reduced his caloric intake and began exercising and in a few weeks had amazing results (Biggest Loser type of results). He has been at it for about 10 weeks and has lost over 40 pounds.
My Journey Begins
So taking my own advice I decided to “Stop Eating so F-ing much.” I didn’t think I could cut calories since I only had breakfast on the weekends and rarely had lunch. My main meal came at dinner and I thought I couldn’t possibly be consuming so many calories. My one weakness was for dessert. I love my ice cream before bed.
My friend, who is married to a dietician who does not necessarily like our method to weight loss, told me that to loose a pound of fat you needed to burn 3500 calories. The engineer in me kicked into high gear. Now I knew all I had to do was consume a lot less then what my body burned. This was not necessarily a new revelation, but this number gave me a target. I had read how people who began a diet and exercise program tended to either remain the same or gain some weight. A few years back when I was doing a lot of traveling I began taking advantage of the hotel’s fitness centers and after months I saw little to no weight loss. At the time I thought that given how little I ate adding exercise would have an impact. Realistically I think at most I probably burned an additional 500 calories a day. Hardly a dent. Exercise also tends to have the negative effect of giving you a sense of entitlement to more food since you now are exercising.
To top things off, Linus pretty much nailed it when it came to exercise, at least for me.
Counting Caliroes
To be fair my wife and I already ate fairly healthy compared to most of America. We would have salad with a side of protein at least twice a week and very rarely had any sort of fast food. She cooks almost every day so our problem wasn’t eating a lot of takeout or ready to eat meals.
For me it all came down to having no clue how many calories I was consuming. I had become complacent since I only ate one meal a day on most days, but once I started looking it was obvious.
I set a goal of consuming 1000 calories a day. I didn’t go out and get a food scale, but I started looking at labels and modifying what I ate so that I consumed fewer calories. Ice Cream was substituted with a single piece of Lindor Truffle (I love these things). 73.3 calories to cap off my day with milk chocolate goodness.
The most amazing fact was opening my eyes to how many calories are in all sorts of things I ate. The tortilla for a breakfast burrito was over 100 calories each and that’s just the tortilla. One wouldn’t satisfy me on the weekends so I would have to eat 3. How about In N Out once in a blue moon. A Double Double, French Fries and a Chocolate shake? That can’t be so bad, I have that less than once a month. Well, that meal is over 1600 calories, WOW!!!
I still have no clue the calories in certain things my wife cooks, but we have increased the number of salad only meals and I have reduced my portions.
How has it worked?
In just over 6 weeks I have lost about 10 pounds. I have not suddenly picked up exercise. I do the same things I used to do, all I have done was stopped eating so many calories. If you watch Survivor you know that losing weight is not so difficult. Everyone on that show loses weight. I am convinced that the US would be a lot thinner if the government did not subsidize high fructose corn syrup because everything unhealthy has it and it packs in the calories. I am also pretty sure that if everyone became more aware of how many calories they consumed, they would actively work to reduce them.
Is this Healthy?
I am not a doctor, nor do I play one on TV, but I just had a physical last week and all is well. Carrying around an extra 10-15 lbs. can’t be so good and realistically a lot of people in the world, probably the majority, get by with fewer calories than I was consuming. I have also read studies on longevity and reduction of caloric intake.
“I am so hungry… WAAAHHH“
Most of my life I have not eaten breakfast or lunch and I have met many people who ask how I can go all day without eating. I have come to the conclusion that their attitude is both psychological and related to their ingrained belief that X meal is important or that the body has to have food X number of times a day. They get a headache if they don’t eat, they can’t function if they don’t eat, etc. How are people in third world countries surviving? My dog eats once a day and she has had a pretty full life. I will admit that whenever I am on vacation I tend to eat more meals per day and switching back to the single meal after an extended period of multiple meals is difficult. It is hard to fight the hunger, but after a couple of days you body adjusts. Another thing which makes hunger worse is eating junk food or anything high in carbs or sugar.
When I started my calorie reduction the hardest part was the weekend. I could no longer have 6 pancakes or 3 burritos, but after a few weekends I had conditioned my mind to not expect such luxuries. Watch the contestants on Survivor. The first few episodes people talk about how hungry they are, how they can’t function, etc. But that, they adjust. So can anyone.
The first rule of process improvement
Everyone knows that you can’t control that which you can’t measure. Now that I am actively calculating the calories I am consuming I have been able to qucickly achieve that which had aluded me for many years. My goal is to loose at least 10 more pounds. I then figure that a person my size probably consumes around 2000 calories(educated guess, I am not a health Nazi yet lol), so I can probably increase my intake without gaining any more weight, but at least now I will be more aware of what I am consuming.
Now, as Peldi would say…. Onward
Medicare Fraud – Inspecting Quality into a process rarely works well
I just watched a story on 60 Minutes on how simple it is to game the Medicare system out of millions of dollars. Essentially, with a few pieces of static data a criminal can bill the system for medical equipment without having even met the Medicare patient. The government will pay the charges in 30 days and if the criminal gets a hint that they are under investigation, they just close shop and open up another business reusing the same list of patients.
The criminals purchase lists of patients for $10 per patient and bill Medicare for any number of devices or drugs. In the report they interview a person whose credentials were used to bill the system from two prosthetic arms. The man had his real arms and only learned of the fraud from a quarterly statement from Medicare.
What I found most interesting is that the solution being employed to reduce the fraud is more law enforcement and more auditing. To me this is backwards. The government is trying to inspect quality into the billing and payment process. No matter how successful the government is, given the simplicity of the crime, I doubt the effectiveness of their efforts.
Instead of inspecting quality at the back end of the process, it is always better to prevent the defect. From what I know of the process based on the report, it seems that the main flaw is the fact that it is so simple to acquire the static patient credentials needed to bill the government.
![]()
While there are probably more ways to prevent fraud, the solution I thought of immediately is giving each patient a single use token device like Secure ID. If the patient is involved in a medical transaction, they would be required to provide the provider a single use number which the provider would use to authorize that transaction with the government. While this would not prevent fraudulent companies from billing for unnecessary equipment, it would immediately render the patient lists useless since companies could not use them without the single use token.
A second line of defense would be to employ data mining software like those used by credit card companies. I imagine it would be possible to develop algorithms that would catch potential fraud before invoices are paid. For example, prior to paying for prosthetics, the system would assure that amputations had been billed.
It is usually simpler to add more inspections to the end of a process, but it rarely has the impact that error prevention does.
Competing poorly outside your core is not the way to win
On Twitter today @paul_irish shared this infographic which illustrates why the legacy carriers can’t effectively compete with low-cost airlines.

The information on this picture is nothing you can’t learn from taking any business school class, but what is interesting is how something so obvious is not put to good use. I have felt for a long time that by trying to compete with the low cost airlines, the legacy airlines are “stuck in the middle” as Porter suggested. Today these companies are neither differentiated nor low cost.
Bailout after bailout the legacy airlines pursue the same failed strategies. They continue to cut costs at the expense of service and I have noticed in my travels that the low cost airlines continue to outperform. The same was true of the US automakers and we see where that led.
Instead of trying to compete on price, legacy airlines should look for ways to leverage their size and put up a good fight against low cost airlines. A “fly anywhere” for a month pass from American Airlines is surely better than one from JetBlue. How about giving passengers who have to go through hubs the flexibility to book their connecting flight on a different day? I think everyone would see the value in being able to take a detour for a few days in Chicago on their way to Indiana. This perk would win favor with passengers while only increasing airline costs marginally (for additional baggage handling, automated check-in, etc.).
When a company sees itself losing sales to someone following a different generic strategy it can’t defend itself by trying to compete using the competitor’s strategy. It needs to get better at their strategy when on the surface it appears they need to abandon it.
Could Target ever beat Walmart on price? Probably not. Instead it chooses to have reasonable prices and compete on differentiation tied to style and trendiness. Dell has been trying for a few years to compete with Apple on style and has not done any better. When Apple was faced with extinction in the 90s instead of trying to compete on price they chose to go after innovation which was their core and is why today they are the model every company tries to copy. If you look at the early 90s, you can argue that it was the CEOs who lost that focus at Apple which put it in the predicament in the first place.
So when someone is competing with you don’t blindly abandon your core strategy. Look for ways to leverage what you have because your competitor won’t be able to effectively counter a strategy foreign to them.
Virtual relationships and the art communication
Services like Twitter and Facebook have allowed us to connect with people in ways we never imagined. They have also allowed us to learn more about these people and to put our virtual feet in our mouths without even know we had.
You see, verbal communication and written communication are very different beasts. When you hear someone tell you something you get cues about their intention and motivation from the manner in which they say it. If someone is speaking to you and you are standing in front of them, you can pick up additional cues, but in the written word all you have are the words in front of you.
Some people are naturally gifted at writing eloquently. These people can defuse conflicts with just the right words, however, there are others who can innocently put a few words together and come across the wrong way. A comment made in jest or the combination of several tweets over time can distance those with whom you’d previously had close relationships.
The problem with social networks is that it is very hard to know if those in your network have been offended by something you said or something you did. It is even more difficult to try to mend a relationship once you think you have offended someone. In this new medium we don’t “have to” work with one another. We can block a user or simply choose to ignore them.
An employee known to work at a certain company posts a link to a video and their followers will unconsciously attach the emotions the feel while watching the video to the company. If a person makes a comment about healthcare reform, the type of computer they use, the political party they belong to or if their positions on such matters can be inferred, some followers will superimpose their offline prejudices on to those people and possibly the companies they work for.
We all look for ways to connect with others who share our passions, the problem now is that these passions are now being merged on to the same stream. One of your followers may share your interest for a programming language, but the same person may detest your love for Sarah Palin.
In the long run we are going to have to make a few concessions if we want to make the most of this new medium. We are going to have to learn to be more open with one another and instead of ignoring those who hurt us we could try to find the best in them and learn to forgive. We are going to have to understand that we are all multi faceted individuals and while in some ways we will agree, in other ways we may not. We shouldn’t throw the baby out with the bath water because there are still great things we can learn from one another. Now more than ever we need to give people the benefit of a doubt because some people are just not as gifted at putting together 140 characters as others.
Sending email in Rails via GMail & using HAML with Action Mailer
Sending Email via Gmail
I was following the Action Mailer Rails Guide to set up outbound email from my app and I came across a problem when trying to use GMail. Many blog posts and the Rails guide point to plugins which enable TLS. I kept running into a wall and getting this error:
wrong number of arguments (3 for 2)
Luckily I finally found there is a very simple solution which is defined in the Rails API in ActionMailer::Base. This essentially says that Section 5.2 of the Rails Guide can be simplified by adding an additional parameter to the smtp_settings:
1 2 3 4 5 6 7 8 9 | ActionMailer::Base.smtp_settings = { :enable_starttls_auto => true, :address => "smtp.gmail.com", :port => 587, :domain => "domain.com", :user_name => "user@domain.com", :password => "password", :authentication => :plain } |
There is no plugin / gem needed, but you must be on Ruby 1.8.7
From the Rails API:
:enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it. It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
Using HAML with ActionMailer
Section 5.3 of the Rails Guide also mentions a configuration setting to get Action Mailer to recognize HAML templates. This configuration is not needed. As I found here.
I added comments to the Rails Guide Lighthouse ticket, so hopefully the guide will be updated.
Book Review: Rails Freelancing Handbook
As part of helping out on a RailsBridge project, I was given a copy of the Rails Freelancing Handbook by Mike Gunderloy so I thought I would share my impression of it.
Overview
Even though the book has the word Rails in the title, a lot of the advice in this book can apply to anyone who wants to work on their own, from a freelance designer to a business consultant.
The book covers topics from deciding if freelancing is for you to legal and tax implications, marketing, and managing clients.
Writing Style
This book packs a lot of good advice and is a quick read at just 65 pages. I love this. There is no fluff, just clear concise advice based on Mike”s personal experience as a freelancer.
Mike’s Advice
Mike does not pretend to have all the answers, but instead points you in the right direction. Whether that means telling you to find a lawyer and an accountant, or pointing you to web resources for doing it yourself if you can’t afford one,. This makes the book a really practical resource which you can refer to as you move through the stages of becoming a freelancer.
You will find that Mike’s advice is pretty comprehensive and you will gain nuggets of wisdom even if you have experience freelancing. Even though I have done consulting work and have gone through the process of establishing an LLC, I learned about factoring receivables which was something I had no idea even existed.
Mike even covers ergonomics, using multiple monitors, and web based tools to improve your workflow. I had never put as much thought into an office chair as I know Mike has, and since I’m a person that rather get the Consumer Reports version, I found this topic particularly interesting.
Conclusin
For under $10 you can’t ask for more. This book is full of actionable advice for anyone starting a small business. There is a free chapter online, so check that out and if you find it as useful as I did, you will want to get yourself a copy of this book.
The problem with SKU proliferation
TechCrunch has a short post on the number of models of handsets Nokia and Sony Ericson have on their site.
Why Nokia and Sony Ericsson are failing
For reasons of market segmentation and distribution strategies electronics companies choose to spin new almost identical models of products which on some marketing plan may seem reasonable, but which in fact tend to confuse the customer and add operational overhead.
Whenever someone asks me about a laptop I can quickly tell them about all the Apple models, not only because I am a Mac user, but because remembering the permutations is incredibly simple. MacBook, MacBook Air, and MacBook Pro. It’s not hard to remember even for a person who tends to forget things, like me.
Look at companies like Toyota and Honda and you will find the same thing. Very simple, clearly differentiated models each targeting a specific segment of the market.
Large consumer manufacturers should take note and not create a new indistinguishable model just to sell a “different” TV at Costco. The iPod you can get at Costco and Walmart are in fact the same ones you get at Best Buy or at the Apple store. Simple for the company and simple for the consumer.

