Monday, January 26, 2009

Managing dotfiles with git

[read part II here - I have completed and open-sourced a solution]

Like anyone that's developed on *nix for many years, I have ended up with a very customized set of dotfiles. However, when I get a new machine or even make a change to a dotfile that I'd like on all of my machines, it can be a real PITA to keep things synchronized.

Since I'm trying to learn git, I thought this would present a great opportunity to learn git and solve the problem of managing dotfiles across multiple machines.

I found a couple of great blog posts about this topic that I thought I'd share:

and

Which was good background info. However, it didn't seem so clean to me to have a git repo in my home directory just to manage the dotfiles. A little more searching and I also ran across a github repo that has a solution to make dotfile management cleaner, and I am using his Rakefile to allow me to easily clone and install my dotfile setup anywhere.

I did have a little trouble setting up a bare git repo to serve as my central repo for pushing/pulling, but this article helped me get that set up as well.

Enjoy!
Alan

Tuesday, January 20, 2009

Welcome, President Obama! And Now for a Prediction...

The moment I heard Obama's speech at the 2004 DNC, I knew he was the real deal. Even though I had a hunch he could break out and run for President in 2008, I am still stunned that he pulled it off. I didn't think the country could elect a true leader, but apparently "Yes, we can!"

I am an independent, and I don't really like political parties, especially since we really only have two of them. Maybe I'm just projecting, but Obama doesn't really seem like a Democrat to me. People complained during the campaign that he didn't offer many specifics of his plans, causing the left to worry he was too centrist and the right to worry that he was too classically liberal.

But to me, he just seemed like a reasonable guy that was playing the game he had to play in order to get elected. Now we'll see what he's really made of, and my prediction is that he's going to change everything, even more than people expect.

I was telling someone today at lunch of my long-held belief that there exists a set of policies that would get 75-80% support and approval from the public, and that those polices look different from a "Democratic" or "Republican" set of policies that would get only 50-60% support. To me these solutions seem obvious, but in the slash & burn political atmosphere that's dominated the national stage for as long as I can remember, they never saw the light of day. No one asked the right questions, and no leader was there to chart a course to deliver true solutions that work for everyone.

With Obama in office, this all changes.

My Predictions
What I see in Obama is a guy that's going figure out the "third way". I've heard this phrase a lot on shows lately, and I think you'll be hearing even more of it. As a result of this "third way," I am expecting some of the following things to happen:
  • Obama is going to have to stomp on the Democrats to show them that he's in charge. I don't think that Congress gets it yet, and I think the new Democratic-majority Congress is going to try to jam through a bunch of partisan crap. Obama is going to veto something unexpected to show that he's setting the agenda and that he's not going to stand for bad government anymore. This will cause Democrats to cower, Republicans to cheer, and he'll have the public solidly in his corner for the rest of his term. This will extend his honeymoon period far longer than the horrible economy would otherwise allow. This will happen within 3-6 months.
  • Corollary: Harry Reid or Nancy Pelosi, or both, will lose their leadership position.
  • This will be the most transparent administration, ever. Expect publishing of lots of data, numbers, etc. There's a chance he'll have some press conferences where he answers more questions than any President in recent history.
  • There will be huge energy infrastructure investments.
  • He's going to let some companies collapse; maybe financial, maybe autos. The financial system is nowhere near fixed, and he isn't going to let people believe it is. Expect the markets to get worse before they get better. Expect some serious new regulation around financial products to help prevent this type of mess in the future.
  • There will be aggressive tax cuts on investment-generating activities: small businesses, capital gains, etc. 
  • He's going to cut a lot of government spending programs.
I am looking forward to finding out if I'm any good at this prediction business. Check back in a few months!

Friday, January 16, 2009

How to test Ajax Apps with Selenium

I have been working a bit on phocoa, my php web framework, and am trying to be really good about testing.

Since I added a lot of Ajax support into the project I've been using Selenium to execute these Ajax tests. At first I couldn't find any best-practices for doing a lot of Ajax testing with it, especially from PHPUnit, but today I managed to come up with a couple of things that work pretty well.

1. Selenium IDE
First off, the Selenium IDE is a fantastic tool. It installs as a Firefox extension, and adds a "Selenium IDE" option to the "Tools" menu. Once you pull up the IDE window, you can just hit "record" and run your app, recording tests along the way by right-clicking interesting objects and then choosing the test you want to perform on that object. You can tweak tests and run them in-browser via the IDE window.

Even cooler is the "clipboard integration." First, click on the IDE window, then choose your language under the "Options->Clipboard Format" menu item.  Then, you can select all of the steps, hit "copy", and then "paste" into your text editor, and boom you have valid code for your test framework that will execute the steps you just entered.

NOTE: You might notice that the code created doesn't always exactly mirror the steps in the Selenium IDE. That's because the IDE has test functions that don't exist in Selenium Core (the part that actually runs the test). I think this is weird architecturally, but hey it is what it is. So certain tests like "waitForText" get expanded into really ugly loops in PHP, but they do work.

2. Cleaner Javascript Testing
While the automated setup was nice, I don't like sloppy code, and plus I still wanted to be able to assert things in Javascript. That's when I figured out a good way to use the "waitForCondition" test. This test is supported by the language drivers (ie PHPUnit) and allows you to simply execute a javascript statement which will automatically re-run periodically until the result of the expression is true, or it times out. Perfect for Ajax stuff.

How's it look? Here's an example PHPUnit test:

    public function testWFRPCRequestShouldProcessWFActionResponsePhocoaUIUpdater()
    {  
        $this->open("/webapp/test/requests/wfrpc");
        $this->click("runTest");
        $this->waitForCondition("selenium.browserbot.getCurrentWindow().$('testResult').innerHTML === 'PHOCOA Ajax Response'");
    }

Since my framework has Prototype loaded, I can use all of Prototype's goodness to write my tests. Just be sure to use the "selenium.browserbot.getCurrentWindow()" syntax to get to the proper "window" object for your page under test.

Sunday, January 11, 2009

AdDeflation: why ads aren't worth anything anymore and what it means for your startup

It's every internet entrepreneur's dream: come up with something cool, make it free, and get rich off ads. Problem is, this almost never happens.

I don't like to talk smack without backing it up with some numbers, but even a simple economic thought exercise will lead you to this conclusion. People are flocking to the internet in everyday life way faster than the buying power of those people grows, and on top of that, companies design sites to create more impressions, further exacerbating the effect.

Hence my neologism for today: "Adflation."

Well crap, that word already exists, and for the exact opposite reason I propose today.

"Adflation" was apparently coined by the radio industry in 1975, defined as the "increase in the cost of advertising space" due to the lack of growth in the places to advertise. How far we've come! Interestingly, the history of the term inflation has gone through multiple related usages which are similarly confusing as to what measure grows at the expense of another.

Ok, so my NEW neologism for today is "Addeflation," and I define it to mean the devaluation of an ad impression due to the uncontrolled growth of ad impressions that are created by the post-scarcity digital economy.

In a nutshell, it used to be so hard to reach people that ads were extremely valuable. But now that you can't even go to the bathroom without seeing an ad, we have been trained to ignore them.

I am a serial web entrepreneur. I've never been interested in media plays, though. Probably because I'm such a cynic of advertising. I personally use advertising only to be informed of the existence of something. I over-research everything I purchase, and I don't think I'm alone in that habit anymore.

While I am happy to yield the point that plenty of companies that are media plays make lots of money, I am always very skeptical whenever anyone pitches me an idea where the business model is ads.

There are three main reasons why:
  1. It's way harder to get lots of users than most people think.
  2. People tend to confuse "stuff millions of people will use for free" with "value of millions of people using free stuff."
  3. Failing to factor in addeflation to their future predictions of ad revenues.
I think that we're at a crucial fork in the road for advertising. Unless those creating ads can come up with a way to make ads worth looking at again, addeflation will continue to spiral out of control.

If ads are your startup's key to profitability, think about the three points I make above and see if there isn't a better revenue model for your company than the one used by the underpants gnomes!

Sunday, January 04, 2009

My Investment Philosophy; 2009 Outlook & Trading Strategy

My overriding investment strategy is based on a few pillars:

  • For the long term, you simply can't beat low-cost index funds to give you a market-tracking diversified base.

  • Invest only in companies you understand well. Very well.

  • Active trading is just gambling. Maybe not craps, but definitely poker. Skill can help, but it's still mostly luck.

  • Use funds only for long-term exposure to sectors with long-term growth potential where I cannot develop good information on individual stocks, and where no good indexes are available.

At the end of 2008 I took a hard look at my portfolio. I realized that over time I have ended up with a good portion of my portfolio in actively managed funds, something that I don't like for the long term.

Current Market Perspective

My current view of the market: short-term pessimism, long-term optimism combined with high volatility.

I think the economy is not near bottom. I am of the opinion that there are a lot more skeletons in the closet, with far more downside risk than upside potential, especially in the next 3-6 months. I am tangentially involved in the real estate industry, and watch it closely. It is a mess. I think listings and deal volume will start to increase again in the next 3 months [I sure hope so], but sales prices will be way down. Deal volume may recover by 2009-2010, but it will probably take 3+ years before the overall dollar volume returns to 2007 levels.

2009 Strategies and Tactics

With the end-of-year rally to nearly 9000, I decided it was the perfect opportunity to cash out of all of my actively managed funds and even some of my index exposure. I was also nearly totally invested in the market, so I wanted to improve the cash portion of my portfolio, especially as a reserve for buying when the market goes down.

This environment is a near-perfect fit for my trading strategy. Over the next few months I will be increasing positions of my favorite companies (Berkshire Hathaway [BRKB] and Apple Computer [AAPL]) and then selling covered calls.

I will probably also increase my exposure in the WilderHill Clean Energy ETF [PBW], a green-energy ETF. It has gotten hammered (down from 22 to 9) in the last year or so, but I am invested in it as a 20-year play for energy sector exposure. The current low in energy prices makes for a perfect time to load up on this sector. It will probably lag for 2-3 years as energy demand recovers, but in the long run I think it will outperform in a major way.

I am not sure where I sit on "peak oil", but I do know that energy demand growth will eventually outstrip supply growth, and when that happens, just like this summer, energy prices will spiral uncontrollably upward. As far as energy prices go, this recession came just in time. Hopefully the next time energy spikes the green energy industry will be in a position where it can add to supply fast enough to keep up with demand growth, and if it can, PBW will pay off handsomely.

Notes on Apple

Apple has about $25B in cash and a market cap of $80B, yielding an implicit value on their business of $55B. They have been putting out impressive net income numbers; 2B, 3.5B, 4.8B in 2006, 2007, and 2008 respectively. With a discount rate of 5% and assuming they can pull out even 3B a year for a while, that's a $60B valuation on their current business assuming no growth. Thus there is essentially no growth priced into their current share price. I have been impressed by their ability to transition to iPhone from iPod without significantly affecting sales volumes or margins. Coupled with aggressive international expansion of iPhone, I think that they will continue to perform. I see RIMM as a dead-end in the long term, just like PALM. Google's Android is the only significant competitor, and Apple will take large market shares given the current competitive environment.