Worth a listen – The Jugtown Pirates

If you spend any time in San Francisco, you may have heard the Jugtown Pirates playing their unique brand of bluegrass around the ferry building. They now have a new album, Darda, which they funded with a Kickstarter project. It’s now available in iTunes and it’s fun & enjoyable, even if you’re not into bluegrass. It has a more polished sound with styles raging from rock, alt-country, and blues.

Jugtown Pirates

Sugar Rush 1.2.1

I apologize for the lack of posts recently, as I’ve been more interested in writing code than blogging. Most of my work has been on some enterprise projects, but I’ve also made an update to Sugar Rush.

I submitted Sugar Rush version 1.2.1 today, which lets you earn real world bonuses with Kiip.

What Occupy Wall Street is really about

An article at AlterNet explains the facts that are driving the Occupy Wall street movement.

Since Reagan’s time, we’ve been led to believe free market “conventional wisdom” that is fundamentally wrong. Some of the more significant points:

  • The “trickle down” theory (also known as “Voodo economics”): if you give enough money to the already-rich eventually some of that money will trickle down to the rest of us. This has been proven wrong beyond a doubt, yet the Republicans stubbornly cling to this belief.

    They say that if wealthy people have more money they will use that money to start businesses and hire people. But anyone with a real business will tell you that people coming in the door and buying things is what creates jobs. In a real economy, people wanting to buy things – demand – is what causes businesses to form and people to be hired.

    History – and a quick look around us today – shows that when all the money goes to a few at the top demand from the rest of us dries up and everything breaks down. Taxing the people at the top and reinvesting the money into the democratic society is fundamental to keeping things going.

    This chart proves the point. While corporate profits are up, employment is down. Corporations aren’t reinvesting their tax breaks to create new jobs, so nothing “trickles down”.

    corporate-profits-employment.png
  • Government and taxes take money out of the economy: Also wrong. In reality the taxes that government collects are invested in the “public structures” that create the prosperity and lifestyle we enjoy – or at least did before taxes were cut. Tax revenue builds the infrastructure of transportation, courts, schools, universities, research facilities and other institutions that enable our businesses to grow and prosper and the consumer protection, safety inspection, water and sewer, health, parks and arts that help us live and enjoy our lives.

    The government needs taxes to operate. Our tax rate is among the lowest in the world, and is much lower than it was during Reagan’s era. As a result, the government is deprived of the funds it needs just for normal operation, which forces it to cut back needed services and has allowed our infrastructure to crumble. Our roads and bridges are in unsafe and deplorable condition for that reason.

    Raising taxes on the 1% and corporate taxes to more reasonable levels, and reinvesting that tax income on infrastructure development would do more to create jobs than any more tax cuts and would boost the overall economy.

Supply-side economics is fundamentally wrong and has never worked. What does work is “demand-side” economics: give the people more spending power (lower taxes at the bottom rather than the top), which will encourage them to buy more, which will drive business and create more jobs, therefore benefiting everyone.

Core Data debugging fun

A few days ago I spent a lot of time tracking down a data validation error in Core Data which turned out to have a very simple cause.

The application I’m working on has two entities for customer and order. Each order must be linked to a single customer.

When a new order is saved, I call this function to save changes:


- (void)saveContext {

    NSError *error = nil;
	NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
    if (managedObjectContext != nil) {
        if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        }
    }
}

The first time I created a new order, I was able to save it successfully. The next time I tried to save an order, I got a validation error. When I inspect the new order I just created, it looks correct, with a proper customer relationship.

Looking at the NSManagedObjectContext in the debugger offers a few clues. You’ll see that it has sets of inserted & changed items, which you can inspect by typing ‘po managedObjectContext->_insertedObjects‘ or ‘po managedObjectContext->_changedObjects‘.

Screen Shot 2011-10-13 at 8.20.37 PM.png

The set of inserted object contained exactly what I expected, but the set of changed items contained some unexpected items, including the previous order, which now had its customer relationship set to nil. Since the customer is required, the data validation failure was not on our newly inserted item, but on the previous order which used to be valid.

How could I be changing that previous order? I couldn’t find any place in my code which could have been doing it. Instead it turned out to be a simple error in my data model.

When you create a relationship, it can be either required or optional, and it can be to a single entity or to many entities. Every relationship also needs to have an inverse relationship.

In this case, my order had a required to-one relationship with a customer, which meant customer also had to have an inverse relationship to orders, which was optional. However, I neglected to set my customer to order relationship as to-many.

Therefore, although I never touched the customer’s relationship to orders, when I created a new order & set the customer, Core Data also set the customer’s order relationship. Since I didn’t make it to-many, doing so wiped out the relationship to the previous order, which also wiped out that order’s required relationship to a customer.

Moral of this story: check your relationships carefully and make sure you set the proper attributes for the inverse relationship. In this case, I spent many hours debugging something caused by setting a checkbox incorrectly in the model editor.

Sugar Rush 1.2

I’ve submitted Sugar Rush 1.2, which adds support for a new Halloween candy pack, as well as internal changes to support multiple themes or candy sets. Also, if you bought donuts, you now have two varieties with even more power.

Screenshot 2011.10.09 14.43.57.png

The Halloween pack gives you a new spooky background, candy corn, pumpkins, and candy apples. You can pick the theme from the main menu screen. Each theme has its own leader board in the game center to keep the scoring fair, since the amount of candies & their distribution frequency differs in each theme. If you also bought donuts, they will remain available in all themes.

How far we’ve come

To see how far we’ve come since 1984, just compare the specs of the first Macintosh with today’s iPhone 4GS:

1984 Macintosh 128.png

We now carry in our pocket a device with a faster processor, more storage, and a higher resolution screen in a much smaller package than the computer we had sitting on our desk 27 years ago. Today’s Macintosh is many times faster, with a very different CPU, and has many times more storage, yet it’s still recognizable as a Macintosh and still has the same elegant simplicity.

R.I.P. Steve Jobs

Apple reports that Steve Jobs has died:

Apple has lost a visionary and creative genius, and the world has lost an amazing human being. Those of us who have been fortunate enough to know and work with Steve have lost a dear friend and an inspiring mentor. Steve leaves behind a company that only he could have built, and his spirit will forever be the foundation of Apple.

Apple’s home page is now a tribute to Steve Jobs.

Screen Shot 2011-10-05 at 8.06.19 PM.png

Steve Jobs truly changed the world. His influence has impacted the music & entertainment industries as much as in impacted the computer industry. The devices he created changed the way we listen to music, watch movies, and interact with our phones.

Easy Twitter & FaceBook sharing with ShareKit

I’ve had a few questions about how to implement Twitter & FaceBook sharing, so here’s how I did it.

ShareKit provides an easy drop-in solution for posting to Twitter, FaceBook, Instapaper, Tumbler, and many other services. However, in many cases you don’t need all of the features and simply want to post a status to FaceBook or Twitter.

It takes only two lines of code to simply share an item to Twitter, FaceBook, or most other supported services:

  1. Create a SHKItem with the text you want to post
  2. Call the shareItem: method of the appropriate subclass.

These are the specific methods for Twitter & FaceBook:


- (IBAction)tweet:(id)sender
{
    SHKItem *aTweet = [SHKItem text: @"Share this text"];
    [SHKTwitter shareItem:aTweet];
}

- (IBAction)facebook:(id)sender
{
    SHKItem *post = [SHKItem text: @"Share this text"];
    [SHKFacebook shareItem:post];
}

When you call shareItem: it will display the login & authentication prompt and show the item to be shared.

The most difficult part is setting up your application on Twitter or FaceBook with the correct permissions and obtaining the proper API keys. Read the instructions in SHKConfig.h carefully for details on how to set up your application and enter the API keys there.

I have my own branch of ShareKit at https://github.com/mike3k/ShareKit which fixes a problem related to iOS 5 and gets rid of most of the compiler warnings.

Democrats Suck at Politics

Via Matt Richman:

“Some economists call the 30 years from 1947-1977 the “Great Prosperity”. We invested in our infrastructure. We expanded our higher education system so that low-income families could send their kids to college. Working conditions got better. Productivity increased. But most importantly, the income of the average worker more than doubled — and everyone’s standard of living increased. 

“Fast forward to 1980. Imagine you’re in an auditorium filled with 100 people. Everyone there makes a different amount of money. One person is a top 1 percenter; another person is a top 2 percenter; a third person is a top 3 percenter; etc. Joe, the top 1 percenter in the crowd, owns many times more money than the average, middle-of-the-road guy in the auditorium. He worked hard, started his own business, and innovated in ways most people couldn’t imagine. He was — and should be — rewarded.

“But the problem is what’s happened since 1980. If only 5 dollars of new income had been created over the last 30 years, 4 of them would have gone to Joe while everyone else got a penny. 80% of all new income created over the last 30 years has gone to the top 1% of earners. The rich have gotten richer while the middle class has faced stagnation. 

“Why did this happen? Because of Republican trickle-down ‘voodoo’ economic policy devised by David Stockman that was, in his own words, ‘a Trojan horse to bring down the top rate’ for the rich.

“Over the last 30 years our tax policy has slowly shifted to favor the rich. The top marginal Income Tax rate has dropped from 70% to 35%. The long-term Capital Gains tax rate has dropped from 28% to 15%. The result? Warren Buffet now pays a lower tax rate than teachers, firefighters, and cops.

“Embracing Republican “supply-side” economic theory has also led to the upward transfer of wealth. Social inequality is now at the highest levels it’s been at since the Great Depression. The top 1% of earners — 3 million people — make more money every year than the bottom 150 million combined, and the 400 richest Americans now own more of it than the bottom 150 million.

“A strong middle class is the basis of a vibrant economy. Adopting Republican economic ideas has caused the middle class to decline. The median household income has gone down 7% — $3,807 — since 1999. 46.2 million Americans now live in poverty — the largest amount on record. Republican economic policies caused the middle class to stagnate for the last 30 years. It was Republican economic policies that got us into this mess. Only Democratic policy can get us out of it.”

Unfortunately we don’t have a true liberal with the guts to stand up and say that. Despite the Republican rhetoric, Obama is not a liberal (and neither was Clinton, for that matter). Instead of a bold liberal who would push through real reform, we’re stuck with centrists who give in to the Republicans on every major issue. We really need someone more like Bernie Sanders.

Sync OmniFocus with your own server

OmniFocus provides several ways to sync your data between devices, including MobileMe and their beta Omni Sync Server. If you have a web hosting account (such as DreamHost) that supports WebDAV, you can set up your own sync server without having to subscribe to any other services. Here’s how I set it up on DreamHost.

1. On your web host, set up a WebDAV directory. On DreamHost, go to Goodies -> Htaccess/WebDAV and choose a fully hosted domain. In the next screen, enter the name of a directory you want to use for WebDAV and password protect it.

Screen Shot 2011-09-08 at 8.52.37 PM.png

2. In OmniFocus on your Mac, go to Sync settings and switch to the advanced tab. Enter the name of a subfolder inside the directory you specified in step 1.

Screen Shot 2011-09-08 at 8.49.34 PM.png

3. Enter that same path on all of your mobile devices that you want to sync with it.

I find it to be much faster than MobileMe using my DreamHost server. Your results may vary depending on your web host or server.