Fit-PC2 and Ubuntu 10.04

I had Ubuntu 9.04 running on my Fit-PC2 and I wanted to move up to 10.04. I ran: sudo apt-get update; sudo apt-get dist-upgrade and it chugged along doing the update. Install went fine and I was impressed that you can jump major revs like that.
Although there was one bit of weirdness: when I did the dist-upgrade I noticed that it was going to upgrade openoffice. I didn't want openoffice at all on there so I was going to remove it before it upgraded. So I hit Ctrl-C which promptly locked the whole box. I thought it was heat related and so I got an ice pack and wrapped the Fit in ice. I tried it again, Ctrl-C locks the box. Like, the whole box. Caps lock dead. Anyway, I've never seen that before. When I let the dist-upgrade go, it worked fine.
When it booted 10.04, my display was set to 1280x1024 and was running slow. It was running the vesa driver. So I downloaded the paulsbo driver for the GMA500 (the 'gpu' that the Fit-PC2 uses) and although the module built fine, it really screwed up everything. The screen would blank, X would be trying to start, there'd be video garbage doing all kinds of weird things.
So I wiped the whole thing and installed 9.10 and followed the 9.10 installation instructions on the Fit wiki. I installed the netbook-remix distro (i386) and the install instructions still work. Now I just need to get rid of the netbook-remix gui. Too bad they don't have desktop-switcher anymore.
Also, I was playing around with Xmonad which is interesting if not a bit understated. It reminds me of when I used Enlightenment back in 1999. The styles are different but the amount of config editing is the same.
Reversing sentences with Ruby.
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).
tc_reverser.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | require 'test/unit' require 'reverser' # Be wary of newlines in the test and expected trings. # Do not try to word wrap with escapes. It's very picky. class TestReverser < Test::Unit::TestCase # Optional #def setup #end def teardown if @test_passed then puts "\n #{@r.reverse}" # more verbose for successful passes puts "#{@method_name.upcase} OK.\n\n" else puts "#{@method_name.upcase} FAIL.\n\n" end end # simple test def test_reverser test = "You space bastard. You killed my pine." expected = "Bastard space you. Pine my killed you." @r = Reverser.new(test) assert_equal(expected, @r.reverse, "Fail.") end # Test multiple sentence delimiters def test_multiple_sentence_delimiters test = "Shape up, man. You're a slacker. Do you want to be a slacker for the rest of your life?" expected = "Man, up shape. Slacker a you're. Life your of rest the for slacker a be to want you do?" @r = Reverser.new(test) assert_equal(expected, @r.reverse, "Fail.") end # Test no periods, question mark and commas def test_question_comma test = "Then tell me, future boy, huh, who's president of the United States in 1985?" expected = "1985 in States United the of president who's, huh, boy future, me tell then?" @r = Reverser.new(test) assert_equal(expected, @r.reverse, "Fail.") end # Big test def test_everything test = "Our first television set. Dad just picked it up today. Do you have a television? Well, yeah, you know, we have two of them. Wow! You must be rich. Oh, honey, he's teasing you. Nobody has two television sets." expected = "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." @r = Reverser.new(test) assert_equal(expected, @r.reverse, "Fail.") end end |
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.
reverser.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # A class that reverses sentences. # "My dog has fleas." --> "Fleas has dog my." class Reverser # tasty constructor, full of taste def initialize(text) @text = text end def reverse delim_location = 0 # char by char, remember !?. for sentence determination delim_last_location = 0 # allows us to move on to the next sentence delim_i = 0 # an iterator new_sentence = "" # inits an empty string for string methods to work new_sentence_array = Array.new punc_array = Array.new # list of punctuation marks in order @text.each_char do |char| delim_i += 1 # iterator if (char == "." || char == "?" || char == "!") # we hit a deliminter (?!.), remember it sentence = @text.slice(delim_last_location..delim_i) sentence.strip! new_sentence_array.push(sentence) punc_array.push(char) delim_last_location = delim_i # remember our substring position end end i = 0 new_sentence_array.each do |s| returned_sentence = do_reverse(s) # reverse words sentence by sentence new_sentence += "#{returned_sentence}#{punc_array[i]}" # append the delimiter back if (i+1 != new_sentence_array.length) # look ahead for last sentence new_sentence += " " # only append spaces if this is not the last sentence end i += 1 end new_sentence # return new_sentence end def do_reverse(s) s.chop! # trim delimiter text_array = s.split(" ") # split on spaces to array text_array[0].downcase! # downcase first word text_array.reverse! # destructive reverse # need to move commas back text_array_i = 0 text_array.each do |e| text_array_i += 1 if e.include? "," e.chop! # modify original array text_array[text_array_i - 2] += "," end end text_array[0].capitalize! text_array = text_array.join(" ") # destructive join text_array.to_s # return reversed array end end |
When you run the test case it looks like this:
Loaded suite ~/src/ruby/tc_reverser
StartedSet 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.
TEST_EVERYTHING OK!.
Man, up shape. Slacker a you're. Life your of rest the for slacker a be to want you do?
TEST_MULTIPLE_SENTENCE_DELIMITERS OK!.
1985 in States United the of president who's, huh, boy future, me tell then?
TEST_QUESTION_COMMA OK!.
Bastard space you. Pine my killed you.
TEST_REVERSER OK!.
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:
sentence_array = @text.split(/[\.\!\?]/) # split with regular expression new_sentence_array = Array.new sentence_array.each do |s| new_sentence_array.push(do_reverse(s)) end puts sentence_array[2] return
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.
iPadDC 2010
Some notes from the 2010 iPadDC conference, I typed as fast as I could. 2nd annual iPhone OS barcamp style un-conference with many good speakers and donuts. Yum.
Full slides might be available under the #iPadDC hashtag.
Rob Rhyne @capttaco
iPad UI Design
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
Pleasing Everyone
blog.simpltry.com
Taxi Magic (super awesome), PM Android and WebOS
JSConf
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
- Location
- Multitasking
- App Stores
Androidisms
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.
BlackBerryism
- Learn to love the menus
- Hardware back button
- T-Mobile users prepare for pain
- Blackberry users never upgrade their OS
- Very low expectations
WebOSisms
- hardware back
- software swipe down menu, supported by almost all apps
- most similar to iPhone
Platform Quirks (deep dive)
Android
- screen resolution
- biggest challenge
- 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
Blackberry
- 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.
Future Proof
- 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
T-Mobile
- some crazy APN process to enable 3rd party internet support on your app
BB partner
$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.
WebOS
- 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.
Multitasking
- 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.
Android
- full access
- prog con running
- save state when users leave app
- your app gets killed in low mem situtations
BB
- full access
- your prog con running
- do what you want (spawn, background, you can watch sms/email - poor man's push)
WebOS
- full access
- 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
App Stores
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!
- Registration
- Push message, badge, sound. Message 5lines, 24 char
- Best Practice, custom data to highlight item. Push some JSON to highlight.
In-App Purchase
Three types:
- Consumable (example: uBoot torpedos).
- Non-consumable (ie: uBoot levels) - usually built-in
- Subscriptions (magazine)
In-App Purchase Server Product Model
- App store handles CC but then passes it to you.
iPad -> App Store -> Your Server -> iPad
Sync
User data survives data / app loss. Or enable multiple devices per user. Out of scope: WiFi Sync (sync to mac) + GameKit (P2P)
Analytics
- Track usage
- Easy to setup
- Best practice: Send specific custom data (which level are people playing the most?)
- Best practice: Crash handler
Advertising
- Make money with free app
- Design: Dedicate some space
- Animation may help
How to implement
- Hire a consultant like Happy Apps
- DIY
- 3rd party providers like Millennial Media
- Apple (they don't do much)
Christopher Brown
iPad Advertising
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.
David Smith
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
Graphics Pipeline
Why 2.0?
- 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
Shading Language
- 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
- No pointers
- 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
Variable Types
- Scalars - float, int, bool
Vectors and Matrices
- Ops work with vec and matrices too
- Multiplication op handles vec matrix and mat/matrix multiplies correctly
- Math ops likely to be HW accel
- Position component access
vec2 pos = vec2(0,1.0)
float xPost = pos.x;
float yPos = pos.y;
Variable Constructors
vec2 texCoord = vec2(0.5, 0.5);
Type conversion
int count = 4;
float fCount = float(count);
Flexible
vec3 pos = vec3(1.0,1.0,1.0);
vec2 something = vec2(pos);
Precision Qualifiers
lowp,mediump,highp (high precision)
highp vec4 color;
MUST declare default or per var precision for float in frag shaders
Type Modifiers
- Uniforms - readonly variables passed in by the application
- Attributes - per-vertex input to the vertex shader
- Varyings - user to communicate form vertex shaders to fragment shader
Simple Shaders
Vertex Shader
attribute vec4 position;
attribute vec2 texCoord;
varying vec2 fTexCoord;
void main(void) {
gl_Position = position; // no view transformation
fTexCoord = texCoord; // will be linearly interpolated
}
Fragment Shader
precision highp float;
varying vec2 fTexCoord;
uniform sampler2D myTextureSampler;
void main(void) {
gl_FragColor = texture2D(myTextureSampler,fTexCoord);
}
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;
void main() {
float weight = sigmoid(time);
float randStatic = rand(vTextCoord);
float randDynamic = rand(vec2(randStatic,weight));
vec4 texVal = texture2D(test_pattern_texture, vTexCoord);
//don't add noise to the black border
if(textVal != vec4(0,0,0,1)){
gl_FragColor = weight * texVal + (12.0 - weight) * randDynamic;
} else {
gl_FragColor = texVal;
}
}
// sigmoid function
float sigmoid(highp float t) {
float f = 10.0;
float t0 = 1.25;
return 1.0 / (1.0 + exp(f * -(t - t0)));
}
// pseudo random number generator
float rand(highp vec2 pos){
return fract(sin(dot(pos, vec2(12.0909, 78 ....
}
Final Thoughts
- OpenGL ES 2.0 allows developers more flexibility than OpenGL ES 1.1. Only will run on 3GS, iPad
- Gold book (the purple book).
- Orange book later for advanced.
How to pair a Bluetooth Keyboard with an iPad

I figured out something that was a bit unintuitive. I have an Apple Wireless Bluetooth keyboard paired with a Mac. I wanted to see if it works on my iPad. I went to Bluetooth->Disconnect on the Mac and the keyboard showed up in the iPad Bluetooth discovery screen but it wouldn't pair.
I just happened to find a method to get this working:
- Select disconnect on the Mac.
- Turn off bluetooth completely on the Mac.
- Hold down the power button on the keyboard to turn it off.
- Press the power button once on the keyboard to turn it on.
- The keyboard will show up in the iPad bluetooth list as before but now when you click it, the keyboard light will start flashing as it pairs.
- The iPad will tell you to type a code and enter.
- Good to go!
It works for text areas in the browser and email windows. The on-screen keyboard doesn't appear. It's way faster to enter a blog post like this (hehe). It doesn't seem to work for navigating menus (with the arrow keys or anything). Think of it as a replacement for the on screen keyboard.
Also, be aware that you do have to unpair with the computer. Pairing means 1-to-1. Not 1-to-many. This is how bluetooth (even on PC) works unfortunately. If you want to broadcast keyboard strokes out to many computers you'll have to use something like VNC. Unfortunately there isn't a VNC server that I know of for the iPad yet (if ever). The iPhone versions of VNC require you to jailbreak your phone which can be a pain if you like "quick and easy". I rarely use my bluetooth keyboard on my media center so I didn't buy a second one. Your mileage may vary.
Hope this helps someone! Post a comment if it did.
iPadcolypse
The Wiff was using the yahoo tv guide (free app) and wants one. It's got potential as a living room multitasker thingy. I got the 32gb. The 64gb is useless because you still have to pick your media you want to sync. Maybe the 16gb would have been better but I wanted to cram a bunch of stuff on it. If they had a 1TB one (lol) then you could sync your whole iTunes library and movies etc etc. I wish it had an SD slot and some other expansion stuff on it. Like it just mounting up as a disk.
But I did grab an app called "GoodReader". It'll probably be replaced by something better (a lot of apps are rushed first to market attempts) but it has DropBox download support (not sync). So I just threw my ebook PDFs (like from other publishers such as PragProg other than the Kindle) and that's how I got PDFs on it.
Among the star apps so far:
- Kindle app (free), pretty nice. Nicer than the Kindle. I wish it had two page view like iBooks does. iBooks doesn't have shit for selection right now. No tech books. All my tech books are in the Kindle store or PDF.
- Twitterific (widscreen is the best mode, probably more improvements later)
- NY Times (please release digital Wired mag like this)
- Yahoo Entertainment app
- ABC app, plays episodes in crappy SD but free
- Weatherbug (super slick Radar and forecast all in one huge data overload view)
- Evernote (online notebook). Not as slick as it should be. No formatting options while editing.
- BBC news (meh kinda redudant)
- Plants vs Zombies (PvZ), perfect port
All the official apps are super polished. I haven't bought the iLife suite apps. I don't think I need them (maybe I will at work?). I'm waiting for a few of my favorite devs to update their apps:
- Mint
- IRC chat called FlowChat
- Lux Touch (woo multitouch strategy)
- Some kind of SSH awesomeness.
- Ruler app (just because I could measure bigger things?)
- Official facebook app
- How about a WoW auction app?!?! COME ON! Even if I don't play.
Many apps are $10. So I'm holding out for more free competition.
There's a scrabble app that plays with your phone. You put your tiles on your phone as the tile rack so you can hide your letters. Everyone plays on the iPad. I haven't tried it but what a great idea! I'd like to see the MS Surface stuff on these devices like that. Imagine some geeky strategy game or RPG. Or Battleship.
I have to figure out how to sync my calendar and all the stuff I set up on my phone. I'm trying to keep the two devices separate. For example, I don't need any apps that scan barcodes because it doesn't have a camera. :P
I'm surprised how fast this thing is. I see why so many games are coming out. Sorry for the short write-up but I'm in toy overload mode.
Dokuwiki April Fools 2010
I was checking out some syntax on dokuwiki's website and suddenly a duck appeared from the right hand side. When I hovered over it, I got a web browser crosshair. When I clicked on it (*bang*), a bullet hole image appeared in the web page and the duck (*quack*) fell to the bottom of the browser window.
Duck hunt!
I didn't see it blogged about yet so there ya go. Techcrunch has a good wrap-up of 2010 april fool's jokes. This year didn't seem as big as last year's.
SCP vs RSync vs SMB vs FTP
@fearthepenguin made an rsync comment that made me curious. He said that rsync in cygwin is faster than native SMB in Windows. Ok I haven't done this test in a while, let's get a reminder about how fat SMB is.
Test Setup
SOHO gigabit switch. Ubuntu 9.10 and octo-core 2008 Mac Pro running 10.6. Both pretty fast boxes. Regular SATA drives in each, not very fast I/O. Whatever, network should be the bottleneck.
Get my test file generated.
$ dd if=/dev/zero of=1gb_file.zeros bs=1G count=1
1073741824 bytes (1.1 GB) copied, 133.577 s, 8.0 MB/s
Ignore that 8.0 MB/s. You can do a blocksize trick to make it output a file faster, I just didn't feel like looking up the switches. Now you can see Mr. 1GB Zero File in all it's empty and big glory.
$ ls -lh
total 1.2G
-rw-r--r-- 1 dude herd 1.0G 2010-02-11 12:29 1gb_file.zeros
The Tests
RSync
Copy from ubuntu box to Mac Pro:
$ time rsync -t /tmp/1gb_file.zeros dude@mac:~/tmp
real 0m17.694s
user 0m11.577s
sys 0m3.056s
SMB
Mount Mac share from Ubuntu box. Copy same file from ubuntu box to Mac Pro over SMB mount. I never do this. It's stupid, slow, strips permissions and requires a mount. In the name of science!
# time cp /tmp/1gb_file.zeros /mnt/tmp
real 0m32.649s
user 0m0.008s
sys 0m0.568s
FTP
Ok let's goddamn turn on OSX FTP and test that too. FTP is stupid.
The remote file "1gb_file.zeros" already exists.
Local: 1073741824 bytes, dated Thu 11 Feb 2010 12:29:06 PM EST.
(Files are identical, skipped)
Hey at least FTP is showing some smarts about it. Or maybe ncftp just rules. I dunno. Deleted it and got FTP time.
$ time ncftpput -u dude -p whoa mac /dest/tmp /tmp/1gb_file.zeros
/tmp/1gb_file.zeros: 1.00 GB 39.09 MB/s
real 0m26.507s
user 0m0.036s
sys 0m0.828s
SCP
Is SCP any different than rsync?
$ time scp /tmp/1gb_file.zeros dude@mac:~/tmp
1gb_file.zeros 100% 1024MB 42.7MB/s 00:24
real 0m24.303s
user 0m9.641s
sys 0m2.212s
Weird. It is. I wonder if rsync has compression flags whereas ssh does not without the -C magic switches. You can get SCP to be pretty quick with blowfish or arcfour:
$ time scp -c arcfour /tmp/1gb_file.zeros dude@mac:~/tmp
1gb_file.zeros 100% 1024MB 46.6MB/s 00:22
real 0m21.653s
user 0m5.452s
sys 0m2.032s
Conclusion
| rsync | SMB | FTP | SCP | SCP arcfour | |
|---|---|---|---|---|---|
| time | 17.694 | 32.649 | 26.507 | 24.303 | 21.653 |
| MB/sec | 57.87 | 31.36 | 38.63 | 42.13 | 47.29 |
So RSync is pretty quick and SMB is pretty slow. @fearthepenguin was right.
Buying a cat with logic switches
Charles Petzold's book Code is an awesome read. I'm reading it again actually. It's so elegant and simple. Walks you through history and experiments in a style I find extremely invoking. I wanted to build a logic switch but I don't want to blow anything up so I tried this java applet at falstad.com and it works pretty well. I tried qucs but it's way too complicate for me and doesn't include an LED.
An example from Code (this is not the exact example) is where he's trying to buy a pet from a pet store and he creates a logic circuit that will light up a light bulb when the pet is correct. Let's say I'm looking for a normal gray cat as a house pet (not a tiger! rawr!). When I flip all the switches correctly, the LED lights up but if I get a gray tiger (that's technically a cat) then the LED (the red dot) says nope.
The salesman brings me a gray tiger. Nope.

The salesman brings me a gray cat that's not a tiger. Yep.

iPhoneDevCampDC 2009

Went to the first annual iPhone Dev Camp here in DC. It was a barcamp style event over two days. It was very enjoyable although there were quite a few heavy hitters there (I wasn't one of them). There were a few different types of people there and I was one of the ones who doesn't have anything on the app store and isn't making any money off iPhone dev. A few people there had apps I knew from the press as well as an author (Dave Mark -- who was great) that I've read quite a bit from.
What follows is some of the notes that I took at the conference. It's by no means a transcription.
Peter Corbett - Apps for Democracy
@corbet3000
He met with Vivek Kundra (CTO/fed CIO DC) and started a dontest for DC, open data. Citizens created "fix my city" type apps. 43 webapps created, $2.3 EST value, $50k cost, 5000% roi. Huge success.
A few examples:
- areyousafedc iphone app - a tachometer as you walk, green = safe, red = danger. Pulls data from open city sources, crime reports etc. Very simple interface, pretty cool
- wethepeoplewiki.com - structured wiki, real-time crime data. I didn't get this.
- park it dc - very cool parking meter app. People report broken meters, displays broken meters on a google map mashup. City found their contractors were fixing their meters in avg of 7 days but their SLA was 24 hours. Broken meters not cities fault, app helped DC discover the real problem.
- iPhone demo at DC311 - http://victorshillo.com/dc311/2/
Really good presentation. Peter is a cool guy. Nice, technical and well connected. Peter did another awesome presentation called No one cares about your crappy webapp at an Ignite Baltimore conference. I tried to tell him how awesome that was but it's hard to put into words.
Jonathan Blocksom - OpenGL
@jblocksom
http://www.gollygee.com/weblogs/jblocksom
Jonathan works at google. He had an android shirt on. It was pretty funny. I seriously think he was there to convert some people. :P He was really nice and I enjoyed talking to him about gamedev (even if most of my stuff has been in Java). He did a really nice overview of OpenGL, computer graphics and his game Bubbles. His game has been on the app store since the beginning of the app store opening.
- Z buffering is checking if a pixel is behind another, won't render.
- Use the iPhone boilerplate template to learn
- Overview of the various buffers that the template creates.
- You can use the bullet SDK, collada to import 3d models etc
- You can use the Texture2D class to easily import textures from the apple Lunar lander sample code
- You can use the touch fighter sample code. It shows how to overlay a high score list over opengl view
- Don't mix OpenGL and cocoa views together for performance reasons
- He gave an overview of his sales history which was interesting.
A lot of people showed their sales tapering off after an initial burst of sales. Sometimes press coverage or even competing apps would create another bust of sales.
Leon Palm - Computer Vision
Leon also works at Google (not that anyone is judging people based on their day job. Hey, google is a cool company (currently). He was a really smart and nice guy. Easy to talk to. Had a cool Sudoku solver app to demo. I thought I had seen his app covered in the press but that turned out to be a competing one (oops!). His presentation walked through how the app works. Some parts are super confusing and hard but he did a good job in breaking it down.
How his app works:
- Evolution algorithm
- RANSAC to find the line
- Walk the intersection of the lines
- Find 8x8 inliers in checkers, 7x8 in connect four
- Have lines, apply transform matrix to rectify image
- Get pieces is easy
- Sample region at expected center, create int array for piece config
- Use open source solver etc
Drawing the results back.
We have: piece colors, positions, sizes and warp matrix. Derectify image and draw over solution.
Conclusion: easy to do if task is broken down. Use existing knowledge (whitepapers). Filtering/tweaking is the most important part. You have to tweak it to work with cameras lighting and make it accurate. He said tweaking and adjusting took the most time. I believe it.
I have done some test type stuff with OpenCV but Leon had really taken this all the way to the finish line. It was a really in-depth talk that was academically the most complicated of all the talks.
Kiril - Working w Designers from Imagini Studios
Kiril is the artist that worked on Harbor Master. It's a "line drawing" game similar to Flight Control. Apparently it's doing very well on the app store. These guys were super pro. They had a great presentation, super personalities and they had found success being an indie game dev shop. I was really green but then I hadn't put in the hours etc.
Kiril talked about his mock ups, how he worked with the developers (2 of them) and showed his different iterative art pieces. He mentioned ffffound for art inspiration. And his most important advice to developers: don't think that mockups are the final product. He said many people can't make the jump from concept to final product.
Christopher Brown - App Store Data!
Christopher runs an analytics company called Tap Metrics. They had a super slick web app that scrapes data from the app store (I imagine only a few people can do this). He had run many reports and shared some interesting trends:
- Most people that buy an app stay in that category and buy again
- 94% of apps are in English, meaning German/English counts. Germany only counts wouldn't count. All -> EN -> DE, FR, JP
- 1% conversion freemium rate free->pro. Meaning 1M free downloads.
1.99 better segment, .99 is saturated
If I was on the store, I'd talk to Chris about metrics. I can't imagine anyone else having something similar in polish. I hope he gets some traction (if he hasn't already) on his work. It was impressive.
Dave Smith - Audio on the iPhone
Dave had a presentation that I really enjoyed having worked with various audio APIs. I asked the most questions on this one. He walked through his audiobook app (which was really neat). He was friendly to talk to (for further notice ... everyone was nice). He gave a good overview of real code and a real working audiobook app he works on. The app displays the text version of the audiobook while it plays and stays in sync. It's very polished.
Some random notes (I wrote as fast as I could):
- AVAudioPlayer level above openAL
- mp3 format is hw decompression, good for batt/performance
- To get started, add AVFoundation, AudioToolbox frameworks to project
- Make a pointer: AVAudioPlayer* player
- - (IBAction)play:(id)sender; // methods for button actions etc
- In interface builder, mapping actions using touchUpInside is the best option to capture user button push
- Useful command line utility in OSX: /usr/bin/afconvert -iaf4 (convert aiff to compressed formats, pre-compress best for iphone optimization)
- UInt32 category = kAudioSessionCategory_MediaPlayback // kAudioSessionCategory_* has many diff options
He always released his memory correctly. :)
[player pause]
[player release]
player = nil // nice GC technique
His start method created the player and played at the same time. Pause destroyed it. This might seem odd but he said, "don't keep player instances around for a long time, non deterministic things can start happening."
Sze Wong - $1M app
Sze asked the question "what would a $1M iphone app look like?". He also talked about enterprise development and asked if the iPhone could be a serious contender. He has a metric ton of experience doing enterprise and mobile development. He seems to like the iPhone (hey a lot of us are sick of doing J2EE) as a refreshing platform.
Sze had a really nice presentation that didn't materialize for me until he showed his demo. I can only describe it as Oracle Forms for the iPhone. He has a slick web ui that can generate custom forms for many different uses. His forms could even include a signature box that the iPhone can use to create a UPS type delivery board. It was pretty compelling and he had a lot of nice backend stuff (like JSON, RSS, XLS exporters) created in the web ui.
Other topics
Things wound down and at the end they had a panel of the experts there give answers to various questions by Dave Mark. It was really neat to see an improvised conference.
- A lot of people mentioned the importance of Touch Arcade.
- Someone mentioned nsfetchrequest for nstableviews?
- Ad hoc distribution for beta testers? I need to research that.
- Imangi Studios mentioned getsatisfaction, a customer support portal to outsource support
Fun conference. I hope to see them next year or sooner. I think ruby dcamp is next for me.
Better tetris collision detection

As I said in the TODO part of the Making Tetris post, a better way to do collision detection is to have the blocks on the field be bits. This is typically what I saw in academic assignments and student presentations. This is probably the right way to do it in other words. It's more efficient and it's more simple (KISS).
Even though this isn't how I did it in the game, I still wanted to play around with the concept so I made a little prototype that demonstrates the basic gist. Instead of a piece, it's a single block. Instead of a tetris grid of finished blocks, it's random blocks. It's really the same thing, it just looks and plays with different shapes.
So here it is. Space randomizes the grid and the arrow keys move. Play It!



