A question came up today about how to reverse a sentence. Word by word, preserving periods etc. I’ve done stuff like this before but I really saw an opportunity to solve this contrived quiz type question with TDD. It’s perfect really. Tedious string checking? Screw it. Let my test tell me when I’m done.
Ok so I could have probably done this more comfortably in Java but it would have been more lines. I banged this out in Ruby, including “learning” test cases (it’s really easy) in about an hour. At one point I realized how easy string manipulation is in Ruby for this and I literally said, “holy shit Ruby is amazing”. And then the edge cases started happening. I was only handling periods and my algorithm fell over flat on three sentences because I was trying to do a string[start, end] when it’s really string[start, length]. I fixed it with learning the String#slice syntax.
Ok enough fanboi service. There’s two files. One’s the test and one’s the class. Run the test and not the class (ie: ruby tc_reverser.rb).
I have to apologize for the scrollbars in the above posted code. I tried many different ways of escaping carriage returns for better formatting but it would have required a lot of changes to deal with the \n and so on in the tests. I had something nicely formatted working but the tabs and spaces for alignment then screwed the test and broke the pretty formatting a different way.
When you run the test case it looks like this:
Loaded suite ~/src/ruby/tc_reverser
Set television first our. Today up it picked just dad. Television a have you do? Them of two have we, know you, yeah, well. Wow! Rich be must you. You teasing he's, honey, oh. Sets television two has nobody.
Man, up shape. Slacker a you're. Life your of rest the for slacker a be to want you do?
1985 in States United the of president who's, huh, boy future, me tell then?
Bastard space you. Pine my killed you.
Finished in 0.003567 seconds.
4 tests, 4 assertions, 0 failures, 0 errors
Marty McFly would be proud. So, some limitations. First, I don’t handle elipsis (…) characters at all. It splits on sentence delimiters which one is a period. The eplisis would cause major weirdness. I also don’t handle recapitalizing the word “Dad” as you can see in the “test_everything” test. This would require language parsing or a massive pick list. I also don’t handle slang or abbreviations. For example, “You told ‘em?” would turn into “‘em told you?” which might not be exactly right.
There are many other edge cases that this thing would fall flat on. My test case tests what functionality I wanted and nothing more.
Ruby’s String#slice was super handy on this as well as capitalize, reverse and even a regex split that I didn’t use (amazing!). You can see it here. It would split text into an array really easily:
But then I’d lose the delimiter character (!?. etc) and would have to save it, search it or some other nonsense. Still, really neat that you can split on a regex.
Walter Gropius, founded the Bauhaus.
He loved Claire De Lune from Ocean’s Eleven, builds up in fountain scene.
Find the simple.
Discover the hook and bust your ass to make your app enjoyable.
When in doubt, polish.
Demo’d his mock up/wireframe iPhone app Brief. Really looks nice. http://giveabrief.com/
Ruby based BS script for mock up movement.
Mentioned we should check out a Brett Victor mock up talk at WWDC. Video might be hard to find.
Nic Schlueter @schlu
Taxi Magic (super awesome), PM Android and WebOS
Very cool taxi booking and payment app.
Order of market importance
iPhone -> Android -> Blackberry -> iPad -> WebOS -> WinMobile Phone 7 -> WinMobile 6.5
Basically WinMobile is dead.
Things to worry about
Isms (metaphors per platform)
Cross Device Within Platform
Back button kills app. Home keeps it alive. These are hardware buttons so this is the way it is. You can’t disable this. Android phones don’t get latest versions of the OS. And they don’t care because they’re going to sell a newer phone. So you have to support old OS’s.
Learn to love the menus
Hardware back button
T-Mobile users prepare for pain
Blackberry users never upgrade their OS
Very low expectations
software swipe down menu, supported by almost all apps
most similar to iPhone
Platform Quirks (deep dive)
must support landscape if you want cred!
watch the font size
large variety in PPI and resolution in phones
so you have to use different pixel density features of fonts?
Which OS to Target
1.6 unless you have a good reason
6-9 mo you can safely target 2.0 or 2.1
expensive to test old devices (subscriptions)
device manufacturers don’t make it a priority to update device OS
layout manager not quite as flexible as Android, you have to do lots of detection on your end
Currently a lot of resolutions
In the future, should be less than Android
Which OS to target. The Blackberry App World allows you to submit apps targeted from 4.2.1+.
Enterprises might want you to target older devices.
Too many threads bug
6-7 threads seem to be the max. Nasty. A problem on older BBs.
build support into your price
either the app is going to suck or you’ll be broke if you don’t
unreleased phones will break your app
some crazy APN process to enable 3rd party internet support on your app
$2000/year to be a partner. They’ll send source code. 1-on-1 support person. If you’re serious about BB, it’s worth it.
multi-resolutions, not that bad. It’s all CSS3.
Bottom position sticky to the bottom.
PDK makes games fairly trivial. C & C++ are easily portable.
Single threaded, not a problem with Ajax async for network calls etc.
Ares web based IDE developing in the browser.
Is it worth it? Probably not. Still better than WindowsMobile! HAHA
iPhone location services are awesome, spoiled. Others aren’t as good. The Droid rate limits how frequently you can get a location. Even between app restarts. Check time on the last known location. Nasty behavior for him to figure out.
BB Location. Slow GPS only. Not on older phones.
WebOS Location is basically fine.
Do not do things that kill the battery. Location or network.
Consider the user experience if a user comes back to a screen days later.
prog con running
save state when users leave app
your app gets killed in low mem situtations
your prog con running
do what you want (spawn, background, you can watch sms/email - poor man’s push)
won’t kill your app, prevents users from starting a new app if too much mem in use
You must have a card or icon when running in bg, or prepare to be killed
Apple - submit, wait, pray (14 days to 24 hours to 3 days). Apple is the only one with identifiers for betas. 70/30
Android - no permission, 325 character description limit, can only sell from certain countries. Money collected from Google Checkout. Betas run from your own server. Free to publish. 70/30
Blackberry - 3ish day approval time. $2.99 minimum price. Betas run through your own server. $200 per app. 80/20 split
WebOS - 5ish day approval. $50 per app. 70/30.
Dana Nuon @wdnuon
iBooks Page Curl in Six Lines of Code
Transforming page by page turning with deformation. Method returns a vector which is applied to a flat matrix. Each vertex in a matrix has an X/Y. The function adds a Z.
He basically showed how to implement the Apple iBook page turn effect in six lines of code using a Xerox algorithm from a one page PDF with some super heavy conic math. Super awesome demos he had. He’s been doing this stuff for a while. Very experienced, very nice chats after his talk.
Luis de la Rosa @louielouie
Seven Ways to Improve Your App with Servers
Pro: Access more data, differentiate
Con: More work, maintenance
JSON vs XML
JSON - smaller, more efficient - TouchJSON
XML - built-in, ubiquitous - TouchXML
runner-ups: plist (no server will recognize this), custom binary
API enables community (high score list). More processing power (upload image to amazon mechanical turk)
Debugging. Inspect traffic. Charles Proxy. Adjust WiFi proxy preference. Debug with proxy.
Push notification: Your Server -> Apple Push Server -> iPad -> Popup: Your App: Hello World!
Best Practice, custom data to highlight item. Push some JSON to highlight.
Consumable (example: uBoot torpedos).
Non-consumable (ie: uBoot levels) - usually built-in
In-App Purchase Server Product Model
App store handles CC but then passes it to you.
iPad -> App Store -> Your Server -> iPad
User data survives data / app loss. Or enable multiple devices per user. Out of scope: WiFi Sync (sync to mac) + GameKit (P2P)
Easy to setup
Best practice: Send specific custom data (which level are people playing the most?)
Best practice: Crash handler
Make money with free app
Design: Dedicate some space
Animation may help
How to implement
Hire a consultant like Happy Apps
3rd party providers like Millennial Media
Apple (they don’t do much)
Answered questions and talked about how to do analytics, marketing, ads and what iAds might affect the space. He had solid metrics and graphs that I can’t type out like he did last year with his Tap Metrics talk.
14 Days and 11 Apps Later
An amazing walkthrough his flurry of app submissions. He walked through ideas he and his team had for the iPad, demo’d his ELEVEN APPS and showed sales results. Shotgun approach gets a bit of cash but not really going to start a business. He had a lot of great insight like, “it’s not about making money but about getting your $99 worth and learning”. I’m not doing his talk justice. Cool guy.
James Norton @jnorton
OpenGL ES 2.0 & the OpenGL Shading Language
Programmable shaders enable things that are difficult or impossible without them
Computations in the GPU
Can free up memory by replacing static textures
Shaders (introduced in 2.0)
Vertex Shaders operate on vertex data (attributes)
Enables CPU to offload many vertex computations to GPU
Fragment Shaders operate on fragment (pixel) data
Allow per-pixel effects like per-pixel lighting, procedural textures (bump mapping or env mapping), noise, etc
Based on C
Variables, structures, arrays, operators, functions, flow control
Additional types to support gfx operations (vectors and matrices)
Differences from C
Stricter type conversions
Function parameters can be qualified with modification: in (default), inout, out
For loopers require iteration count to be known at compile time
Array indices must be constants
Scalars - float, int, bool
Vectors and Matrices
Ops work with vec and matrices too
Multiplication op handles vec matrix and mat/matrix multiplies correctly
TV Noise Fade in Demo
Sigmoid Function: s(t) = 1 / (1 + e^ -f(t-t0) )
Vertex Shader simply passes position to gl_Position like before.
Fragment Shader preample
`precision highp float; // use high p as defaulit for floats
uniforma smapler2D test_pattern_texture; // texture sampler for text patter
uniform highp float time; //time since animation start
varying highp vec2 vTexCoord;
I went to renew my membership on my iPhone developer account and although the membership is $99/year, my expiration date was only extended out for 3 months. I opened a ticket and it took about a month or two to get this thing resolved. I had to send screenshots, steps and evidence that I was doing the right thing (ok, fine, tier 1 support). Eventually I got a person that had a trick up their sleeve but didn’t quite get it right. I’m blogging this in case this is happening to someone else.
First, the symptoms. Let’s say your dev account is about to expire in January 2010. You want to renew for another year. You add a year subscription to your cart, pay for it. You’d expect your new expire date to be Jan-2011. But in your profile and in the “thanks for ordering” activation page it says March 2010 or something else wrong. Support send me activation links basically to the same page that wouldn’t activate any differently. Each time I checked out, it would say March 2010.
The trick was to click on renew membership (as if paying again), click the checkbox to select which membership you want to buy ($99 year) and hit continue. Now you’re on a “Review your purchase” page. Click continue here. Finally, it says “Proceed to your country’s Apple Online Store to purchase” and has an add to cart button. Stop here.
Click the following link: http://developer.apple.com/iphone/enroll/activate.action. It should bring you to a page with a single textbox for your activation code (the one you’ve been trying to use all along). Put this in and hit continue. Your expire date should be correct now. If not, try using a link formatted like this:
Seems like they have some bug in the dev store. Please comment if this helped you so it’s documented.