Digging into PastryKit

If you haven’t already, go read the DaringFireball piece on PastryKit. Are you back? Good. If you’re the least bit like me, you’re probably a least a little bit intrigued. If you’re sorta like me you probably cut and pasted http://help.apple.com/iphone/3/mobile/dist/PastryKit-ug-compact.js into jsbeautifier.org. If you’re kinda like me you also dug into http://help.apple.com/iphone/3/mobile/javascript.js to see how PastryKit is used. And finally, if you’re exactly like me, you’ve probably already dissected the framework and won’t need to read this post :)

PastryKit, at least the one on the iPhone User Guide, contains (it’s possible their compiler strips out classes/functions their site doesn’t use)

  • PKUtils – collection of util functions (eg. degreesToRadians, objectHasMethod, etc)
  • PKClass, PKObject – classes that make inheritance easier. PKObjects to have observer methods for properties and PKClasses are able to synthetize properties ala ObjC.
  • PKPoint, PKSize, PKImage – self explanatory OOO objects for points, sizes, and <img>
  • PKAnimator – simple animator class taskrunner/setTimeout style. Even PastryKit doesn’t use WebKitAnimations since the API is fubar’d! As far as I can tell nothing in the framework or iPhone User Guide uses this
  • PKTransition – This is where all the real animation is done, including the scroll effect, has the ability to commit animation transactions.
  • PKView, PKContentView, PKRootView – View hierarchy, akin to one you would set up in Interface Builder. Very Xcode. I echo Gruber’s sentiments that PastryKit could show up in the next DashCode. Or at the very least the remnants of Apple’s web apps as an app strategy circa 2008.
  • PKScrollIndicator – The magical class that creates the DHTML scrollbar when a view is scrolled.
  • PKSearchBar, PKTableView, PKNavigationView, PKToolbar – the main view classes used to construct an actual app. (Along with PKScrollView, PKTableViewCell, PKNavigationItem, PKControl)

If you’ve built anything in Xcode all this seems very familiar. Applications are built by setting up a hierarchy of views such as:

// create a new navigation view
navigation = new PKNavigationView();
// set a size for the view
navigation.size = new PKSize(height, width);
// init some basic parameters about the view
 // add the view to the root view
PKRootView.sharedRoot.addSubview(navigation);
// build the rest of your views

I gave myself a couple hours to build a basic view app from scratch using PastryKit. It was painful and time consuming. There are plenty of methods that are required by the framework that you must declare unknowingly (eg. tableViewCellForRowAtPath vs tableViewCustomCellForRowAtPath dependent on what your table view is styled). Without proper documentation the framework is difficult to do any real work with. I’ll tinker with it some more but if you’re interested in a semi-prepackaged PastryKit and my work so far you can grab it here.

PKScrollIndicator is the best part of the framework, jQTouch should definitely look into “borrowing” this code. Meanwhile, I’ll be waiting for a documented official release of PastryKit.

Bonus: You can use the following to disable scrolling in Mobile Safari.

document.addEventListener('touchmove', function(e) {
  e.preventDefault();
}, true);

This coupled with window.scrollTo(0,0) is how PastryKit hides the navigation bar.

Update: Sorry, should be document.addEventListener() instead of window.addEventListener(). I’ve added a demo no scroll page here. Just view the source.

11 comments

Streaming Cure for Digital Packrat

Two years ago I read this article from wired.com outlines how downloading has lead to a digital version of compulsive hoarding. I definitely had some sort of this disorder with hard drives and CD-Rs full of digital content – most of which I’ve never even consumed.

In the past couple of years that need to collect has faded. Why? Streaming.

With the advent of the streaming age (YouTube, Hulu and Netflix streaming for video, IMEEM and Lala for music) there’s absolutely no need to horde any longer. With every thing just a few keystroke away, there’s no need to download, catalog, store, organize, curate your own private digital collection.

Anybody else experience the same change in your downloading habits?

Comments Off

Bypassing Palm Pre’s Sprint Activation

Update: This whole process has been automated and “idiot-proofed” by Rod Whitby on his blog.

Last week, I went to pick up a Palm Pre sans a Sprint contract. The Sprint sales person had no problem selling me a $550 Palm Pre, but it was up to me to “Activate” the device. Sadly, I couldn’t find good step by step instructions on how to do this. The best I could find, still was very confusing because it never explained why I was doing the things it was asking me to do.

So here’s a step-by-step tutorial on how to bypass Sprint’s activation for a Palm Pre. Hopefully you can use the webOS Internals tutorial and this to bypass activation. This will enable you to develop apps or use the Palm Pre as a wifi/bt device. Note, you will need to be comfortable with linux command line, tools, and editing files.

First, the goal of this “hack” is to bypass the Sprint Activation but also to enable WiFi so you can create a profile on palm.com without service. We are going to be basically hacking an additional menu item which then brings up the WiFi preferences pane.
Continue reading

19 comments

Twitter Weekly Updates for 2010-08-17

  • Whoa, Disney bought Marvel? Incredibles and X-Men crossover inevitable! Frozo vs iceman gogogo #
Comments Off

Best Argument Against Government AppStore Intervention

The FCC is probing Apple, AT&T, and Google over the whole Google voice fiasco. Although I wish Apple would open up it’s platform, I definitely don’t think the government should get involved. Also is any precedence set for the government intervention? No, I don’t believe so. Everybody is comparing Apple and the iPhone to Microsoft and Windows. The argument is that the government got involved there so why shouldn’t they intervene and stop Apple?

The best counter I’ve heard to this was discussed three weeks ago on the Engadget podcast (start listening at 23:05). Instead of thinking of Microsoft and Windows, think of Nintendo and the Wii (or Sony/PS3, Microsoft/XBox).

Think about it. Nintendo controls what’s available for sale on it’s console system. They also have an AppStore where they disallow content (e.g. they would never allow an emulator that enables you to play all NES games). They censor games, take a cut of sales, and they have full control of the eco-system. Yet, there’s no government intervention asking Nintendo to open up their platform. We purchase these console fully knowing that they will never be open.

At the risk of sounding like a fanboy, sadly Apple is just a victim of their own success.

Comments Off

From a Walled Garden to 1984

apple19845
Everybody, hailed the iPhone as the savior to set developers and mobile businesses free from the walled gardens of traditional carriers. At first, Apple instantly gifted developers with easy access to a mobile audience that bypassed having to deal with carriers. The ancient lumbering beasts that are Verizon, AT&T, Sprint, and T-Mobile were out of the picture. Now we didn’t have to worry about being “on deck” or pre-installed onto phones to reach a mobile audience. All we had to do was submit our application to Apple and within a couple weeks, BOOM, someone with an iPhone would have your application.

Sadly, we all knew that we were climbing out of the walled garden only to land straight into 1984.

The problem is that Apple doesn’t need to explain why it removed Google Voice, NetShare, Podcaster, or Sling from the App Store. Developers can try to abandon the platform, but there are plenty of others to take their place. Developers and businesses can’t just turn a blind eye to the 30-40 million (depending on who you ask) iPhone install base. To put that number into perspective, when you factor in iPod Touches, it rivals one of the best handheld selling devices of all time, Nintendo DS, in yearly sales.

I’m going to predict that Apple doesn’t have to back down from it’s position any time soon and there will be nary a mention of abandoning ship from everybody attending the sold out iPhoneDevCamp this weekend.

Comments Off

New Google Chrome OS

Google just announced that they will be releasing an OS based around Chrome. An amazing move for Google as this gets them instantly on a the radar of every netbook manufacturer out there.

Microsoft’s licensing fees for Windows are generally $40+ per copy. Manufacturers are barely eeking out a profit in the sub $300 price range and having to pay per copy of Windows kills that margin. There is already a ton of competition in this space from Moblin to Jolicloud to whatever is going to be on the CrunchPad.

At first glance, from a product perspective, I wonder why Google is not using Android? There is already an SDK out there, Android is already open source, and Android already has an app marketplace. Bifurcating their “OS” strategy seems like a bad move on the surface.

5 comments

Why Apple Needs to Make a iPhone Keyboard

Apple needs to introduce a physical keyboard attachment for the iPhone. With the 3.0, Apple gave developers access to the connector and it’s inevitable that devs will want to start supporting physical inputs in their apps. This would be so much easier if Apple said okay here’s the keyboard and here is a standardized API to use. Consumers and developers both win.

Let’s imagine Apple doesn’t do an OEM keyboard. A third party manufacture is going to fill the space but who will it be? Which apps support it? What if there are multiple keyboards that each work with different apps? Am I, as a consumer, going to have to decide which one to buy and hope my favorite apps support it?

The scenario above could be absolutely avoid if Apple puts out their own keyboard. If Apple is serious about the iPhone being a gaming platform then a gamepad would be nice too.

1 comment

Palm Prē Impressions

pre
There are more than enough reviews out there of the Palm Prē out there so this won’t be one of them (I leave that to the professionals ;) ).

I had a chance to actually play with a production Prē today and here are my impressions:

  • It’s small. Much smaller than an iPhone when closed
  • I almost cut my finger when I slid the keyboard down. I can’t believe they let those sharp edges out of the factory
  • screen is absolutely beautiful, crisper than my iPhone
  • Everything is rounded, almost to a fault.
  • It’s blazingly fast. Rendering a webpage is quicker than any other mobile device I’ve come across
  • In some cases they give no visual feedback that something has happened. For example if you click on a link in the browser, it just sits there. Something should happen on the screen to indicate that I’ve taken an action. These rough edges make it obviously the Prē was rushed.
  • Multi-tasking is huge. Once you’re accustom to switching apps without quitting, I’m not sure you’ll be able to go back to the iPhone way.

Only time well tell if the Prē catches up to the iPhone on the software/app front. The only leg up that the Prē has is multi-tasking which I’m sure Apple will eventually let out of the bag. (I think Apple will roll out “approved” apps that are approved to run in the background, it’s inevitable.)

On the hardware front, I think all the Prē reviews have been unfairly comparing the iPhone 3G against the Prē. The fair fight is the iPhone 3G S vs Prē and if you’ve read the reviews that hit the web today, the iPhone 3G S wins hands down.

Overall, I think Palm has a winner on it’s hands. Palm has a strong chance to second in marketshare behind Apple if they can deliver WebOS on multiple carriers and on multiple devices.

Comments Off

Kindle DX

51fm0bpqzl_aa280_Disclaimer: The last book I fiction book I’ve read was probably in high school, and probably The Catcher in the Rye. However, I read. From technical books, to blogs, to magazines… to me reading is reading.

I’ll get straight the point since this post won’t carry much weight anyway. I don’t see the point of the Kindle DX. Let’s take a look at it from various value propositions.

Newspaper Replacement

Great. Let’s go green, get rid of the insanely inefficient newspaper delivery system. From paper, to ink, to delivery trucks, to ultra-wasteful fully stocked newspaper machines going digital will do everybody a whole lot of good.

Consumers get their news faster, the newspapers cut out fixed costs and go digital. WIN-WIN. The only thing I see missing from this picture is the advertising space that newspapers are missing. But that can be mitigated by selling more targeted ads, better ad targeting system, and geo targeted ads even. Right now there’s little or no metrics on ads put into newspapers.

This all sounds great, except for the fact that I already get all these newspapers digitally. nytimes.com, NYT iPhone app, it’s already here and it’s free. Why would I need a Kindle for this? On top of that, does the Kindle version of NY Times off the crossword puzzle?

Textbook Replacement

Textbooks cost, $80, and you have to buy them every year. There’s no pricing yet on Amazon’s digital versions but I’m going to go out on a limb and say they’ll be less than $80. Fantastic! Cheaper textbooks (forgetting the fact that the Kindle itself will be $489 unsubsidized) are a win for any college student. However, you’re missing the tactile feel of having a physical book. Dogging pages, highlighting excepts, scribbling notes on the sides. You’ll be missing all those!

What would be great would be a touchscreen notebook reader that OCRs your scribbled notes. That way you can get full indexing and search.

eBook Reader

Granted, I don’t read much outside of magazine or blogs. That might be because I have ADD but it might just be that I like my news and information in bit sized portions. If they made the Kindle color (which I think you need to properly absorb a magazine article) and offer me a subscription of magazines delivered digitally then I might just consider it.

In the end, Amazon jilted their Kindle fans, who most likely just purchased a Kindle 2 months ago by launching the Kindle DX. They got the pricing wrong, $489, when they should have worked with newspapers to offer some sort of subsidized version of the Kindle. They obviously didn’t get the textbook replacement since only a small handful of universities are taking part in the pilot.

But who knows, maybe piracy will save the Kindle.

Comments Off

iPhone 3.0 now with SquirrelFish Extreme?

I saw a post on Ajaxian about how iPhone 3.0 might now include SquirrelFish Extreme so I did a quick and dirty using this. Here’s are the results (raw spreadsheet here).

iPhone 3.0 definitely has something, (whether it’s SquirrelFish or Nitro), but it’s 3x-10x faster than iPhone 2.2.

Update: Dear Apple, if this is against the NDA shoot me an email waynepan at me dot com ;)

47 comments

New Gmail Spammer Trick

I just received a spam that I thought was a very clever way to by pass Gmail’s spam filters. They put in a docs.google.com link! They would probably never filter out email with links to docs.google.com! Genius.

picture-2

Comments Off

Dissecting Safari 4′s Welcome Screen

If you’ve downloaded Safari 4 Beta then you’ve seen a very cool welcome screen. If you haven’t seen it click the video above (or if you’re running Safari 4 you can view it again here). I was curious as to how this page was put together so I did some dissecting…

HTML 5 – Cleverly, Apple decided to use HTML5 and the <audio> and <video> tags for the sound effects and part of the animation. The only part that is a full blown .mov is the ending compass sequence. Here is the .mov.

CSS Animation – The first 2 animations, the Apple logo (plus lens flare) and the Welcome to Safari 4 are achieved by a combination of CSS animations (stylesheet) and a series of images.

The Welcome to Safari 4, is the simplest of the 2. It uses this image:
header
… and this scaling animation rule:

@-webkit-keyframes header {
	from {
		opacity: 0;
		-webkit-transform: scale(2.6);
		-webkit-animation-timing-function: linear;
	}
	20% {
		opacity: 1;
		-webkit-transform: scale(1);
		-webkit-animation-timing-function: linear;
	}
	77% {
		opacity: 1;
		-webkit-transform: scale(0.9);
		-webkit-animation-timing-function: linear;
	}
	to {
		opacity: 0;
		-webkit-transform: scale(0.1);
		-webkit-animation-timing-function: linear;
	}
}

The Apple logo animation is bit more tricky and is achieved with these four images:
apple_icon apple_flare apple_spots apple_flare_icon
… plus 4 different css animation rules that are similar to the rule above but each image’s opacity is changed from 0 to 1 at the appropriate time.

Works on an iPhone – What’s more impressive is that this page more or less works on an iPhone! The .mov and audio do not play, but everything animations properly. I removed the javascript that disables the page for non-Safari 4 browsers and put it here http://waynepan.com/s/safari4.

Bonus! – At the end of all the animation, the page redirects you to topsites://, which of course takes you to Top Sites.

The Safari Welcome screen is a peak into the future. It shows us what’s possible when you get to throw all backwards compatibility concerns out the window… (no pun intended.)

8 comments

Macworld Keynote

My random reactions to Macworld Keynote announcements.

Face recognition in iPhoto is pretty slick tech. Tagging people on facebook is way too laborious right now, this will speed up the uploading of drunk blackmail pictures.

Music lessons in Garage Band is something I’ll personally be using. I’m excited for the prospect of guitar lessons by John Mayer. I can dream, can’t I?

New Keynote templates and transitions will enable more crappy slide presentations possible. I’m a believer in less is more for presentations. All those fancy transitions and animations should be used sparing.

iWork.com? Yeah, like me.com was a rousing success. I give it a year until it’s somewhat stable and another year until it has feature parity with Google Docs.

New 17″ MacBooks with crazy new batteries. Batteries are tough tech but I for one cannot wait for batteries that last 24 hours.

DRM-free iTunes is fantastic. Too bad Amazon.com is still 10c cheaper per song (and iTunes-Plus is $1.29, that’s 40c

That’s it? Oh wait… one more thing! That’s right, AAPL just took a dive.

1 comment

I Wish This Was Only $7.49/yr


Somebody at GoDaddy needs to think about their promotion text.

Comments Off

2009 Predictions

Last year I was 50% accurate, let’s try for better this year. :)

  • Twitter will not be acquired. They’ll have their first revenue stream keeping them independent for a bit longer.
  • Digg will not be acquired. There’s still a ton of crazy things they can do to become the center of news. I just hope they figure out how to get rid of the nerd factor. Just look at this list, it’s not exactly the things your mom would read.
  • Apple will open up iTunes infrastructure to developers to start accepting micro-payments. The biggest hurdle for mobile (in the US more than others) is how do you get users to pay you without help from the carriers. If Apple opens this up the industry will take a huge leap in the right direction.
  • Android phones sales will not exceed iPhones, maybe in 2010. Apple still has too much momentum and good Android phones (read: good hardware) still haven’t launched.
  • Facebook connect will become more ubiquitous than OpenID as a way to login to websites. I’m guessing here but there are way more Facebook users and OpenID users. I, for one, won’t be using it but then again I’m more paranoid about my online privacy than others.
  • IE6 marketshare will fall under 10% by years end. Millions of web devs will implode as they are overcome with joy.
1 comment

2008 Predictions Retrospective

So 2008 is almost coming to an end and what a wild ride in the tech industry. In some cases we’re better off, no more start ups getting inflated valuations for putting a website (see crazy valuations of facebook apps). On the other hand the economy seems to be going to hell in a hand basket and most startups are going into survival mode.

In the beginning of the year I made some predictions. Lets see how those turned out….

Facebook will decline as people either go to the next hottest thing or advertisers realize their ROI on the FB ad platform isn’t the greatest.50% Wrong/50% Correct
I was wrong on the general consumer side as facebook.com has been increasing steadily on the one metric that matters these days, minutes spent. TC reported that Facebook is gaining on Google and passed MySpace back in March.

However, I wasn’t wrong on the ad platform side. Facebook’s ad platform has fallen flat on it’s face. Facebook Beacon hasn’t been relaunched since the original debacle. Most app developers have moved on as they realized their $0.10 eCPMs weren’t worth the headache. With it’s $15 billion valuation from the Microsoft round is a distant memory, they’re bleeding money.

Google will acquire at least two mobile companies to aid Android iPhone will continue to gain mobile browser market share stagnating the mobile web even more. Wrong
I couldn’t find an authoritative list of Google’s 2008 acquisitions but I don’t recall them making a single mobile one this year. Not surprising since nobody is in the M&A market these days.

Slide or RockYou will be acquired. If 07 was the year of widget, 08 will be the year they cash in. Wrong!
Nobody wanted to acquire these guys… low social network eCPMS with a bad economy equal no cash out.

Google or Microsoft will launch an Amazon AWS competitor Correct!
Google App engine was launched, with just a little fanfare. I think once they start supporting languages other than Python, it’ll do quite well.

Yahoo will close at least 4 more properties in an attempt to slim down. Correct!
I think the death count is somewhere north of 15 properties. This list used to be a LOT longer.

A web 2.0 company outside the US will eek out a new niche – Unknown
Honestly, I don’t know one “web 2.0″ company that I currently use that is based outside of the US except for last.fm. If you use one please leave a comment… Is it because startups can’t break into the US market?

At any rate, stay tuned for my 2009 Predictions. Obviously I’m Nostradamus when it comes to these things (/sarcasm)

1 comment

Apple Actually Fixes A Bug, How About Another?

Earlier this year, when I was developing the AdMob iPhone Ad Units, I ran into a curious bug involving iFrames and CSS Transforms. I didn’t think anything of the bug at the time other than it just seemed wrong. We abandoned some of our ideas because of this bug so I filed it away and moved on.

Fast forward a few months to the iPhoneDevCamp where I met John Resig for the first time. We chatted a bit about the iPhone and mentioned off hand about the bug I ran across. He, excitedly, wanted to see the bug in action and I whipped up a small demo page and showed him. Later on that day he caught up with me and mentioned that he discovered that it was far more severe than he had originally thought and that he filed a bug against Apple.

That bug has now been fixed in iPhone 2.2 and Resig has a full write up here. (I don’t think Apple would’ve fixed this bug if I had been the one to report it so I’m happy that Resig was able to bring it to their attention.)

There was another bug I ran into regarding iFrames and touch events. Curiously enough, touchevents do not register properly in iFrames. This first test [http://waynepan.com/iphone/] demonstrates that you first must touch the parent document before touching the iFrame for the iFrame to register your touch event. The second test [http://waynepan.com/iphone/touchtest2.html] shows that touch events only register in an iFrame for the top ~100px of the entire page. The problem is best illustrated by visiting those links on your iPhone.

These bugs are not security showstoppers, like the click-jacking bug, but they do prevent web app developers from doing cool things in iFrames. We were originally going to use touch start, change, and end events to cycle through ads or give the user the ability to hide them. Ultimately, it was not possible because the iFrame was not receiving the proper events.

So far these have not been fixed in iPhone 2.2 and I still have bug into Apple for this (radar id: 6089245).

2 comments

Taking Full Advantage of CloudFront

We (AdMob) are exploring Amazon’s new AWS service CloudFront which is a simple CDN. Amazon built this services as a true CDN that people could use instead of using S3 what it wasn’t meant for.

There’s a few things I’ve discovered about CloudFront that bear repeating here. These points are important if you’re attempting to use CloudFront to serve up static portions of your website.

  • CloudFront pulls from S3 only if the CF node doesn’t already have a local copy. This means that the only way to push out a new file is to change the filename. (style.v1.css, styles.v2.css, etc.) This means that your framework will have to take advantage of this. Without file versioning you’re at risk of serving stale files from different nodes on CloudFront.
  • CloudFront doesn’t automatically detect if a browser accepts gzip encoding. You will have to keep separate versions of gzip files (and upload them pre-gzipped). The easiest way to do this is to keep a separate CNAME, eg static.domain.com and staticu.domain.com (u for uncompressed). Your website will then detect the Accept-Encoding header from the client and serve up the appropriate file. Gzipping could decrease your static content by 75% which not only speeds things up for your users but decrease your CloudFront costs.
  • You should set the appropriate headers when uploading content to S3. That means setting a far futures Expires Header and a Cache-Control header. You can read more about these here. There are two GUI programs that allow you to do this, BucketExplorer and jets3t. If you want to write scripts, I would suggest ruby and the AWS::S3 gem.

Here is some ruby code to do what I’ve described above.

require 'rubygems'
require 'aws/s3'
require 'stringio'
require 'zlib'

AWS::S3::Base.establish_connection!(
  :access_key_id => '[key]',
  :secret_access_key => '[key]'
)

strio = StringIO.open('', 'w')
gz = Zlib::GzipWriter.new(strio)
gz.write(open('[file]').read)
gz.close
AWS::S3::S3Object.store('[s3 location]',
                        strio.string,
                        '[s3 bucket]',
                        :access => :public_read,
                        'Content-Encoding' => 'gzip',
                        'Content-Type' => 'application/x-javascript',
                        'Expires' => 'Fri, 16 Nov 2018 22:09:29 GMT') 
4 comments

Somebody Explain to Me the Green Dot

You know the green dot on the upper left of all OS X windows? This one: .

I have no clue what it does. I’ve even been afraid to hit it 99% of the time because I have no idea what it’s going to do. I just clicked it for one of my Firefox windows and look what happened:

For all the good things that OS X does well, there’s still so many that it does wrong (see the ironically named “Finder”).

3 comments