Tuesday, December 11, 2012

HOWTO: MonoTouch Enterprise Deployment

Okay, so you've gotten the "Engage" hand-gesture from your Captain to deploy your MonoTouch app to the rest of the crew of the Enterprise. Now all you need to know is which buttons to press on your helm...

Step 1.

First, you'll need to make sure that you've created and installed your "In-House" Distribution Certificate via Apple's iOS Provisioning Portal.

Step 2.

Open your Project Options in MonoDevelop and navigate to the iPhone Bundle Signing section.

If you've got MonoDevelop 3.1.0 or later, you'll be able to set your configuration to:

Otherwise you'll simply have to select your Provisioning Profile manually.

Once you've selected your signing certificate and provisioning profile, click the OK button to dismiss the Project Options dialog.

Step 3.

In MonoDevelop, click on the Build menu and select Archive. This will build your project and archive it in a location that Xcode will be able to see it in its Organizer window.

Step 4.

Launch Xcode and then click on the Window menu and select Organizer. At the top of Xcode's Organizer window, you will see an array of icons. Click on the one labeled Archives.

Find your application in the list of archives and select it.

Step 5.

Now click on the Distribute... button in the top-right area of the window and select Save for Enterprise or Ad-Hoc Deployment.

The next screen will prompt you for your code-signing certificate, providing you with a drop-down menu listing your available options.

Clicking Next will cause an action sheet to slide into view, prompting you for the location to save the AppName.ipa package and the AppName.plist file.

Important: Make sure to toggle the Save for Enterprise Distribution checkbox.

Once you've finished filling out all of the fields, click on the Save button.

Step 6.

You'll need to upload the saved AppName.ipa and AppName.plist files to your corporate web server in the location that you specified in the previous step. You'll also need a web page that will link to your app using a hyperlink similar to the one below:

<a href="itms-services://?action=download-manifest&url=http://internal.mycompany.com/Applications/AppName.plist">Install AppName!</a>

That's it! You're done!

Thursday, August 30, 2012

A Better Alternative to the TSA?

Most everyone agrees that going through airport security and being groped by the TSA is not only offensive, but also a major nuisance.

How about replacing the TSA with privately run airport security?

It sounds like San Francisco travelers much prefer their privately run airport security than the TSA at all other US airports.

Sunday, August 12, 2012

Grading Romney's Green Energy Stimulus "Investments": Epic Fail

Yesterday (well, technically late Friday night), I criticized Obama's Green Energy failures.

Today I want to point out that in my research for my previous blog post, I discovered that Mitt Romney has a Green Energy stimulus failure of his own: Konarka.

While Governor of Massachusetts, Mitt Romney gave a state loan of $1.5 million to Konarka which recently filed for bankruptcy and fired all of its workers.

According to the Boston Globe,
In January 2003, shortly after taking office in Massachusetts, Romney held another press conference -- at Konarka, where he announced a plan to loan $24 million from the state’s renewable energy trust fund to startups with the potential to create jobs.

The Bush Administration, too, granted this company $3.6 million in tax payer money and the Obama Administration later gave tax credits to the company.
Under the Bush administration, Konarka received a $1.6 million US Army contract in 2005 and a $3.6 million award from the Department of Energy in 2007. Under the Obama administration, Konarka was one of 183 clean energy companies nationwide that got a total of $2.3 billion in tax credits as part of the 2009 stimulus.

Aye yei yei, my head hurts (probably related to my flu, but this news isn't helping).

Where did the rest of that $24 million in planned loans go? Were any of those companies successful? Were those loans paid back?


According to this Politico article, it appears that Konarka paid back the $1.5 million loan. It also appears that the decision to loan that money to Konarka was made in December of 2002, before Romney became Governor.

The article also suggests that Deval Patrick's Administration loaned another $5 million to Konarka. It's not mentioned in the article when they were given this loan or if this loan was ever paid back.

Friday, August 10, 2012

Grading Obama's Green Energy Stimulus "Investments": Epic Fail

Earlier this year (in January), President Obama declared in his State of the Union speech that he would not "cede the wind or solar or battery industry to China or Germany". He wanted to "double down on a clean energy industry that has never been more promising".

What brought this up, you ask?

Well, earlier this week, I noticed an article in my iGoogle page in the Google News widget that Waltham, Massachusetts-based company, A123 Systems, was being bought out by a Chinese conglomerate (Wanxiang Group). In 2009, when the Obama Administration provided financial relief to this company to the tune of a $250 million grant on top of the $135 million in grants and tax breaks that it got from the state of Michigan (for building a factory in 2010 and where it recently laid off 17% of its workforce), a $30 million grant for a federal wind energy storage project, and another $380 million that they made from their IPO that same year, their stock value peaked at around $25.77/share. Today? $0.45/share. The Chinese are literally buying this clean energy company that the Obama Administration wasted our tax dollars on for pennies on the dollar - but in a way, thank God they are, or A123 Systems would be filing for bankruptcy and every employee would be losing their job.

This news got me thinking: what other green energy companies has the Obama Administration used tax payer money to invest in? How are they doing? We all know about Solyndra because it was a very public and embarrassing bust for the Obama Administration, but what about the others?

I decided to do a little research and find out...

Tesla Motor Company

Tesla Motors is actually one of the more promising of the green energy stimulus recipients (having actually met their June 2012 deadline of delivering the first of their Model S electrical cars - 29 delivered as of the end of July!), but even their future isn't bright enough to force me to wear shades.

In June, 2009, Tesla Motors received a $465 million loan from the Department of Energy. Of this $465 million loan, Tesla owner and Obama campaign donor, Elon Musk, reportedly pocketed $15 million. I have to wonder if there was any political back-scratching going on here...

Their entry-level Model S with a reduced-range battery (160 mile range, as opposed to the 300-mile range battery that has gotten them a fair bit of press) still costs $49,900 after a whopping $7,500 federal tax deduction for buyers which still makes it more expensive than most of its competitors which are charging under $40,000 even without any federal tax deductions factored in (except Fisker Automotive, another recipient of stimulus, which is charging $95,000 for their hybrid). Supposedly 10,000 potential buyers have made deposits of $5,000 (fully refundable), which, at first glance, seems pretty impressive (especially compared to the Chevy Volt, another recipient of Obama's stimulus, which sold about 20,000 units since it first went on the market 2 years ago in 2010). Of course, GM isn't exactly the golden yardstick by which success should be measured. For comparison, most automakers sell ~200,000 cars/year for most of their models, some as many as 300,000/year.

The company reportedly lost $90 million the first quarter of 2012 (up from $50 million in losses for the same quarter in 2011) and $106 million in the second quarter of 2012. So far, they've only produced around 40 Model S's (delivering 29 of those so far) but expect to produce and deliver the rest of their initial 5,000 car production by the end of the year. If they don't manage to pull that off, it's suspected that they'll need to look for another round of funding.

Ever since I was a kid, I've always wondered why no one had come along and made a fully electric car (I was really into RC car racing as a kid, and opted for the electric motors instead of gas-powered).

Let's hope Tesla succeed, but they'll have quite a challenge ahead of them competing with Toyota, Ford, Nissan, GM, etc. who all have EVs in their lineup as well (and all substantially cheaper).

Keep in mind that according to a CNNMoney analysis, GM's failed Chevy Volt sales are largely blamed on its expensive sticker price (~$40,000) which is roughly $10k lower than the discounted price of the Tesla Model S.

I suspect the market for EVs right now, at least in the US, is limited to households that expect to buy more than 1 car (160 miles isn't enough to go on much of a road trip), where the members of the household only plan to use it for driving to and from work and shopping expeditions.

The 300-mile Model S variant would be more appealing for households only wanting to own 1 car, but the $84,900 sticker price would give them a heart attack.

The current auto loan rate is about 4.5% for a 5-year loan which works out to be around $931/month in car payments for the Tesla Model S. For a Toyota Camry Hybrid, it works out to $465/month (it's a ~$25,000 car). The Huffington Post, earlier this year, published an info-graphic that stated the average household spends $2120.40 on gas/year ($179/month), however, in 2011, CNNMoney claimed that the average household spent $386/month on gas (I suspect that this is based on 2+ cars per household). If, for the sake of argument, we assume that the average American spends $386/month on gas per car (that's around 100 gallons of gas per month, which seems rather extreme), then it's still cheaper to go with a Toyota Camry Hybrid for at least the first 6 years (that $80/month savings by going with a Hybrid is enough to cover a 6th year of gas payments) for the average American. Interestingly, the average American only keeps their car for 63.9 months (a little over 5 years) as estimated in 2011, which was up 4.5 months since 2009 (let's hope this trend continues). If the Huffington Post info-graphic is correct, then it will actually take closer to 10 years or more before the average American breaks even by going with the $50k Tesla Model S (depending how much gas prices change between now and then, of course).

Fisker Automotive

In September of 2009, the Obama Administration announced that it would be giving Fisker Automotive a loan of $529 million to supposedly create 5,000 jobs in the US.

As ABC reported in 2011:
Vice President Joseph Biden heralded the Energy Department's $529 million loan to the start-up electric car company called Fisker as a bright new path to thousands of American manufacturing jobs. But two years after the loan was announced, the company's manufacturing jobs are still limited to the assembly of the flashy electric Fisker Karma sports car in Finland.

Somehow this doesn't seem like it delivered on its promises to create jobs in America. Luckily, the US Government stopped funding Fisker Automotive after loaning it $193 million due to a failure to meet milestones.

Tesla Motors also filed a lawsuit against them claiming that Fisker Automotive stole trade secrets and design ideas from them.


Ener1 was a battery maker for electric cars with lofty goals and promises (such as creating 1400 new jobs). They received a $118.5 million grant. They later filed for bankruptcy in January of 2012. In their bankruptcy filing, they claimed to have $73.9 million in assets and $90.5 million in debt.

Update: It appears that Ener1 emerged from bankruptcy at the end of March, ceding control to a Russian tycoon.

The Chicago Tribune has a handy timeline of events for Ener1.

Beacon Power

Beacon Power received $43 million in loan guarantees to build a flywheel power plant. 2 years later, they filed for bankruptcy and earlier this year found an equity firm willing to buy most of its assets for $30 million.

Energy Conversion Devices & United Solar Ovonic LLC

Energy Conversion Devices received a $13.3 million in stimulus tax credit (not a loan this time) in January of 2010. In February, 2012, they filed for bankruptcy; $350 million in debt with only $318 million in assets. In May of 2012, they announced that they would be laying off 300 employees because they were unable to find a buyer for their United Solar Ovonic LLC unit.

Abound Solar

Abound Solar was, like Solyndra, a solar-panel maker that received $400 million in government-guaranteed loans.

In February, they closed down their factory in Indiana, unable to compete with Chinese solar panel makers. In June, they filed for bankruptcy and laid off their 125 workers.

Luckily, Abound Solar had only received $68 million before the DOE wised up and cut off their credit last September. According to the New York Times article (linked above), the DOE also expects to receive some of that money back (I get the feeling that "some" means "very little", but every little bit counts, I suppose).

Amonix Solar

Yet another Solar energy company. Amonix received a $15.4 million DOE grant and another $9.5 million in Federal tax credits for opening a factory in North Las Vegas which it closed down 14 months later, according to Gigaom.

Cogentrix Energy

According to Cogentrix, they received $90.6 million in government loans in order to "support the Alamosa Solar Generating Project, a 30 megawatt (MW) High Concentration Photovoltaic (HCPV) power generation facility that will generate clean, emissions-free power in Colorado."

No bankruptcy filings... yet. Amazing. Could this be an actual success story?

Of course, their project only began in May 2012, so don't hold your breath.

They are/were also a big customer of Amonix Solar, so it sounds like they'll have to start shopping elsewhere.

BrightSource Energy

This company received $1.6 billion in federal loan guarantees in order to create 1400 jobs at its peak, according to their CEO. Uh... wut? That's over a $1 million per job created. Ouch!

More worrisome is that Robert Kennedy, Jr.'s firm is the largest investor in BrightSource and that one of the ex-Principals of his firm went to work for the DOE after the 2008 elections.

At the time of the grant from the DOE, they were $1.8 billion in debt and only generating $13.5 million in revenue each year.

To top it off, this loan was given to them in order to finish what Solar Trust of America failed to deliver as part of its DOE loan before going bankrupt.

Whether political favoritism was truly at play or not, this deal stinks to high heaven.


As most of you probably remember from the news a year or two ago, this company received $535 million in stimulus loans in 2009 from the DOE and managed to use up $527 million of that before going out of business.

What you may not remember is that the Solyndra offices (along with the CEO's home) were raided by the FBI in an investigation into whether or not Solyndra had misrepresented their finances.

There's also question about whether George Kaiser used his political connections to influence the DOE to provide loans to the company. We'll likely never know, but seeing as how many of these companies seem to have had political ties, it does make me suspicious.

Evergreen Solar

Evergreen Solar, Inc. received $125 million in Federal stimulus funds in 2009 and another $58 million in funds from Massachusetts in 2010. Then, in 2011, Evergreen Solar filed for bankruptcy, laying off 800 workers.

Update 8/11/2012:


Ecotality is a company that makes and installs charge stations for electric cars. It received $99.8 million in green energy stimulus funding in 2009 and another $26.4 million in 2011 and is now under investigation for insider trading. As CBS News points out, they were supposed to install 14,000 charge stations across 5 states but have only installed 6400.

Mountain Plaza, Inc.

This company received $424,000 in stimulus funds in 2010 to install electric chargers at truck stops in Tennessee despite having filed for bankruptcy 12 days earlier and being sued for $2 million by the U.S. Bank. They also had numerous other financial troubles.

Needless to say, this company went kaput.

Raser Technologies

This company received a $33 million grant in green energy stimulus to build a geothermal plant in Utah. Late last year, in November of 2011, investors in Raser Technologies filed a lawsuit against current and former executives of the company for Federal Securities Law violations (in other words, fraud). Apparently these executives were short-selling the company's stock.

Can Obama pick 'em, or can he pick 'em?


Spectrawatt received $500,000 worth of stimulus grant money in 2009 only to turn around and file for bankruptcy and lay off most of their workers in 2010, paying out $745,000 to the executives before finally closing up shop.

They assure us that the $745,000 wasn't golden parachutes, but rather used to pay for unspent vacation time.

Color me convinced.

Azure Dynamics

This company apparently converted Ford commercial vans into hybrids and fully-electric vehicles. I'm unable to find an exact figure, but supposedly they received millions of dollars in stimulus from Obama's Green Energy bill.

Several cities bought hybrid buses (using millions of dollars in stimulus money of their own) from Azure in 2010 only to discover that the buses were "lemons", suffering from expensive maintenance problems.

Supposedly, these buses were supposed to be 30% cheaper in maintenance according to this PR announcement.

They have since filed for bankruptcy protection in Canada (in March of 2012).

Solar Trust of America

This solar power company received $2.1 billion in stimulus loans in 2011, filing for bankruptcy in April of 2012. Reportedly, they've found a buyer (NextEra Energy, which, coincidentally, also received a $935 million loan from the DOE a year ago). According to Reuters, Solar Trust had $10 million in assets and between $50 and $100 million in liabilities.

Le sigh...


The DOE granted this company a $1.2 billion loan guarantee in the spring of 2011. According to their CEO, they'd be filing for bankruptcy by now if it wasn't for big oil company, Total, buying 60% of the company back in December of 2011.

There are a dozen or so other companies, but I'm going to call it quits for now. You get the idea.

Some of the other companies that I've come up with for having received stimulus money and/or tax breaks from Obama's Green Energy Stimulus Plan are:
  • Olsen's Crop Service
  • Range Fuels
  • Thompson River Power LLC.
  • Willard & Kelsey Solar Group
  • Babcock & Brown
  • Granite Reliable Power
  • NextEra Energy
  • First Solar
  • NRG Solar
  • Ormat Nevada
  • Schneider Electric
  • Johnson Controls
  • General Motors
  • Nissan

I'll leave it to readers to finish this investigation on their own time.

For those who have misunderstood my point and concluded that the goal of this post was to claim that Green Energy as a whole is not worth investing in: I make no claims to have investigated all Green Energy companies, only those which I have found that received stimulus loans, grants and/or tax breaks, so I would not feel comfortable in making any such claim. My purpose is also not to convince people to vote for Mitt Romney (which is a pretty laughable accusation to make about me, seeing as how I agree more with Obama than I do with Mitt Romney), but rather to criticize where criticism is due.

Obama can do better.

The Obama Administration has a lot of room for improvement when selecting which companies (Green Energy or not) to invest taxpayer money in. We, as tax payers, have a right to be upset that our money is funding failing companies instead of delivering what was promised: successful Green Energy technology / products and millions of new jobs for American workers. So far, neither of these goals has been reached.

I understand that not all companies that even the most knowledgeable investors invest in will turn to gold, but in order to be considered successful, they have to choose more winners than losers, and those winners have to make up for the losses incurred by the losers. From what I've seen, Obama's Administration has not only chosen more losers than winners, but also has not covered the losses of those losers.

If the US Government was a Venture Capital firm, it would have been considered a failure. Why is it so taboo to measure Obama's success with investing in Green Energy companies using the same yardstick?

One of the great mistakes is to judge policies and programs by their intentions rather than their results.
-- Milton Friedman

Sunday, June 17, 2012

Beware Inflation

By a continuing process of inflation, government can confiscate, secretly and unobserved, an important part of the wealth of their citizens.

-- John Maynard Keynes, The Economic Consequences of the Peace

Saturday, March 17, 2012

Introducing MonoTouch.SQLite

I've been working on a personal side-project writing an app for the iPad that makes use of SQLite-Net, displaying that data in a UITableView.

Up until this past week, I had been using Miguel de Icaza's wonderful MonoTouch.Dialog library for displaying my data. Unfortunately, I wanted search filtering to be persistent, which means that I really needed to use Apple's UISearchDisplayController but I couldn't find an easy way to retrofit that onto MonoTouch.Dialog's DialogViewController to replace the simpler UISearchBar API that it currently uses. Since I had to look at creating an alternate solution, I figured I might as well solve the other potential problem I had with MonoTouch.Dialog, which is that my app really needed to be able to handle tables with a massive number of items. This brings us to...


MonoTouch.Dialog really made using UITableViews in iPhone and iPad apps trivial and I wanted to try and repeat at least some of that with MonoTouch.SQLite.

The first thing I had to do was to figure out a way of modeling the data in such a way as to allow a generic class to do most of the work for the developer. After a few sleepless nights of hacking last weekend, I figured out a fairly simple approach that seems to work pretty well. I started off thinking that I wouldn't be able to get around having to have a subclassable model, so I made most everything virtual. This is the public API that I came up with:

public class SQLiteTableModel<T> : IDisposable where T : new ()
    public SQLiteTableModel (SQLiteConnection sqlitedb, int pageSize, SQLiteOrderBy orderBy, string sectionExpr);

    // 2 ways of setting the search criteria
    public SQLiteWhereExpression SearchExpression { get; set; }
    public string SearchText { get; set; }

    // Gets the total number of table rows
    public int Count { get; }

    // Gets the number of table sections
    public int SectionCount { get; }

    // Gets the section titles
    public string[] SectionTitles { get; }

    // Gets the row count for a particular section
    public int GetRowCount (int section);

    // Get the index of an item
    public int IndexOf (T item, IComparer<t> comparer);

    // Convert item index into a section and row
    public bool IndexToSectionAndRow (int index, out int section, out int row);

    // Convert section and row into an item index
    public int SectionAndRowToIndex (int section, int row);

    // 2 ways of getting an item
    public T GetItem (int section, int row);
    public T GetItem (int index);

    // Reset the state of the model
    public void ReloadData ();

You can see the full class implementation here.

It turns out, though, that it really isn't necessary to subclass my model unless you want to have finer control over the specific SQL query commands that it makes (all of those methods are virtual).


As I started porting my iPad app to use my SQLiteTableModel class, I started to realize that I could abstract a lot of my usage of the model into a reusable base class. What I came up with will blow your mind.

Are you ready?

In order to populate a UITableView with the contents of an SQLite table, all you have to do is subclass SQLiteTableViewController<T> and implement 1 method:

protected UITableViewCell GetCell (UITableView tableView, NSIndexPath path, T item)

That's it.

I've written up a sample iPhone app that illustrates just how easy this is.

But wait! There's more!

If you order in the next 30 minutes, you can also get this free complimentary Sham-Wow!

Okay, just kidding about that Sham-Wow! bit, but I wasn't kidding about there being more:

Remember when I said one of the problems I wanted to solve was persistent search filtering? Yea, well, I did it. SQLiteTableViewController handles all of that for you as well. In fact, give searching a try in that sample above.

At this point I bet you're thinking, "wow, how could this get any better?"

I'll tell you. Remember how SQLiteTableModel had 2 methods for setting the search criteria? Well, the one that takes a string parses it to create a SQLiteWhereExpression allowing the user to match against specific fields. For example, if you had the following data item:

public class Contact {
    public string FirstName;
    public string LastName;
    public string PhoneNumber;
    public string Address;
    public string Comments;

...the user could type:

address:"Newton, MA"

and SQLiteTableModel would construct a query to match "Newton, MA" against only the Address field.

If the user, instead, types:

address:"Newton, MA" firstname:Jane

then the matches that would display in the list would be limited to contacts with a first name of "Jane" who live also in "Newton, MA".

I've also taken the liberty of implementing a SQLiteSearchAliasAttribute that allows you to specify aliases for your fields (or even the same alias to multiple fields!). For example, you could do this:

public class Contact {
    [SQLiteSearchAlias ("first")][SQLiteSearchAlias ("name")]
    public string FirstName;
    [SQLiteSearchAlias ("last")][SQLiteSearchAlias ("name")]
    public string LastName;
    [SQLiteSearchAlias ("phone")]
    public string PhoneNumber;
    public string Address;
    public string Comments;

This would allow your users to use "name" to match against either FirstName or LastName!

It also means they can type "first" instead of "firstname" to match against only the first name, as in the above example.

Where Can I Find This Awesome Library?

Glad you asked! You can find it on my GitHub page: MonoTouch.SQLite.

Well? What are you waiting for? Get hacking!

Sunday, February 12, 2012

Meet the Hackers

This past week, I've started to get back into photography a bit more (thanks, Nina!) and started taking my camera into the office with me every day to remind myself to take photos. As a result, I've taken a bunch of photographs of my co-workers in the office.

Would you like to meet the hackers?

The Founders

Most of you would probably recognize the infamous Miguel de Icaza, Xamarin's CTO:

Miguel de Icaza

Next up is our very own Steve Jobs, Nat Friedman, our CEO and the man who reminds us to pay attention to the details:

Nat Friedman

Another person many of you will recognize is our very own COO, Joseph Hill:

Joseph Hill

MonoDevelop Team

Well, okay, I've only got a photo of the famous Michael Hutchinson, but he's a very important player in the development of MonoDevelop.

Michael Hutchinson

QA Team

Next up, we have the QA team. They do their best to make sure that we, the developers, didn't break anything. When they aren't testing a specific application before a launch, they hammer away at our products and try to find weak spots in our code (but we still love them anyway!)

This is PJ, and as you can see, he's demonstrating how to QA popcorn corn cobs:


(Did it pass the test, PJ?)

Next up is Lindsey. She's been working on writing automated tests to make it less likely for releases to include regressions. Let's hope she's successful!


Release Team

Alex Corrado is the man behind the curtain. He's our head Release Team engineer and also the brilliant mastermind that started CXXI, the Mono C++ interop project that we hope to give him time to finish someday soon.

Alex Corrado

Web Team

The newest addition to our ranks (just this week, in fact!), but long-time contributor to the Mono project, is Bojan Rajković. You can see we've already put him to work (he is no doubt puzzling over some ASP.NET code on his screen).

Bojan Rajković

Documentation Team

Nina is the only Cambridge resident on our Docs Team. Specifically, she hacks on our Documentation Portal. She's also the one who has encouraged me to get back into taking photographs, so she'll have to put up with me using her as a guinea pig the most. Here she is taunting me with her hot cup of Chaider:


Code Snippet Licensing

All code posted to this blog is licensed under the MIT/X11 license unless otherwise stated in the post itself.