April 27th, 2011
I think I’ve finally settled on the architecture that makes the most sense for data collection types of applications for the iPhone. I just do them in HTML and use the webkit control everywhere.
Of course I need access to sqlite and so I’ve found I can add new subclasses of NSURLProtocol to provide handlers to access different parts the local machine’s resources.
The first and most useful one I did works with urls of the format sqlite://database/table?a=&b=&c= where a,b, and c are field names. If this is used with a form that has its method set to POST, then a table that can hold all those fields are created and an insert statement is generated to save the record. The response is a JSON dictionary of the resulting record (done to provide the generated primary key back as well as any set default values).
If it is used with a form whose method is set to GET, then all the mentioned fields are fetched, and the ones that have values are used as filters. The response is again a JSON array of dictionaries. This makes a quickie search form easy, however I also look for a field named sql and if that is present, I just execute that as the query instead. Sometimes only SQL will do.
If the form method is DELETE, then the matching records are deleted. Since responses are JSON, using jquery is a no-brainer.
The entire NSURLProtocol subclass is about two pages of code and works with RAILS style form serialization naming conventions to allow saving/retrieval of hierarchies. It also uses ActiveRecord naming conventions and requires a primary key field of id on each table. The primary key is generated as a guid.
Works great. Dead simple. Don’t even need a server. I will be exploring this architecture more.
February 3rd, 2011
Its been a year? Yeah – pretty sad. But now I have something worth saying.
For the past year I’ve been doing iPhone apps that talk to a server back end. I started with Three20. Seemed like it offered some useful UI widgetry. However eventually I found it was easier to whip up fancy UI using UIWebView so I gave up on the Three20 widgets. I did keep the network piece. But as of today I dumped that too.
The Three20 developers are slow to respond to fixes and the network portion assumes it is always doing http or it has a couple hacks to reference the documents or bundle directories using urls with schemes bundle: and documents:. This might be OK but the way it is done is a hack and general file: urls still don’t work. Plus the TTURLRequest has bugs in generating post bodies that I’ve fixed in my copy but haven’t been adopted despite offering them back.
So that’s enough – ASIHttpRequest seems both lighter in weight and more powerful. It is nearly a drop-in replacement and so far I’m impressed.
January 3rd, 2010
Far and away the most painful thing I’ve done with a computer since dropping PDP-11 on my foot.
It was a simple idea. Create a new empty Centos 5.3 image and start installing goodies until it works. Three days later and I’m almost there but wow. First off – yum package manager – love the concept – wonderful when it works. Sadly, many useful things are not yum packages and many yum packages are out of date. yum install apache – fab. yum install postgresql went pretty well. Efforts to install the latest postgis from source – utter failure. It then took me about six hours to successfully eradicate the failed install bits that were messing me up and get the yum install working. Ultimately it required me to create symbolic links in odd places for the GEOS library, but I won in the end. Then there’s the issue of running the sql to create a database. This confounded me for a couple hours until I learned that this copy of postgresql shipped with very strange and restrictive pg_hba.conf. I’ve installed PostgreSQL at least a dozen times and this is the first time I’ve encountered this annoyance. The linked file is the best tutorial on use of this file I have found.
The primary annoyance being that, working as root to install PostGIS, I was not allowed to run the sql files as postgres user (ident failed), but as postgres user, I was not allowed to run sql files owned by root. pg_hba.conf file edited to sane defaults and voila PostGIS installed.
Getting a modern python and mod_wsgi installed was made easy using this tutorial. But getting mod_wsgi configured with virtualenv took forever, largely because I kept running into weird permissions problems with apache. It took the use of a big chmod/chown hammer to finally get it to work and I still don’t understand why setting apache to use a directory in my virtualenv as document root for static content doesn’t work, nor does putting a symlink to the directory in apache’s usual doc root.
Getting git installed and setup was straightforward and mostly works thanks to this handy guide. I haven’t set up the auth bit but I can at least sync my project to my development area on my laptop.
Python’s easy_install has been awesome for getting TurboGears2.1 and friends installed – most trouble free part of the whole thing. Finally, I need php for one little utility that generates labeled map pins like we find on Google maps. It is really cool, but it uses the gd support in php and all of the pre-built packages are compiled using –without_gd. So I had to build php from scratch and download dev versions of a whole lot of graphics processing goodies including libpng and freetype. Getting the build done wasn’t bad. Figuring out why it didn’t work in the first place was a drag though.
Probably one more day to get git auth working, sort out the static file permissions, and configure the git repos to know where origin is and I’ll be ready to actually build some software. That’ll be a nice change.
January 1st, 2010
I need a new web app platform. I have to build a system that is geographically aware which points to using PostGIS as my database. The GIS crowd likes python. There are a bunch of nifty frameworks like MapFish and FeatureServer for building geographically aware applications. They are all built on top of Pylons which is more like a box of parts you can use to build web applications in python than a full on framework like Ruby on Rails.
There is also Django and a GIS extension called GeoDjango. I spent over a month futzing with Django before concluding it was a poor fit for application development. Django comes from the publishing world and is about building web sites. I need an application. There is no ajax integration out of the box, the template system is weak and clumsy to extend. While they claim you can swap it for another one, if you do none of the zillions of extensions that are out there work anymore. I clung to it a little longer than I should have because I thought that zillion extensions would save me a lot of time. Turns out, most of those extensions are half baked, unpolished, and more or less undocuented – thus worthless. I also liked The Admin and thought it would save me a lot of effort. But not enough. So – au revoir Django. You’re no replacement for Rails even if The Admin is a bit better than ActiveScaffold.
Pylons, OTOH, tries to maximize choices and make everything swappable. Choose your template system, database layer, url routing layer….. One gets the idea that the developers have seen Trainspotting one too many times. Anyhow, I don’t want to choose every little piece of the application architecture. I don’t want to design a url scheme. I don’t care that it works with 9 databases – just mine. I just want a cohesive framework that I can build in. Enter TurboGears, a Pylons based framework that tries to choose the best of everything and make it work together. I’m sold. It also has a CRUD based admin layer that is pretty sweet.
Now I just need to figure out how to build a stack for deployment on Centos 5.3.
September 25th, 2009
After updating to Snow Leopard, apache stopped working. The console was full of:
9/25/09 8:53:15 PM org.apache.httpd Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
9/25/09 8:53:15 PM org.apache.httpd Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
9/25/09 8:53:15 PM org.apache.httpd Syntax error on line 99 of /private/etc/apache2/extra/httpd-ssl.conf:
9/25/09 8:53:15 PM org.apache.httpd SSLCertificateFile: file '/private/etc/apache2/server.crt' does not exist or is empty
9/25/09 8:53:15 PM com.apple.launchd (org.apache.httpd) Exited with exit code: 1
9/25/09 8:53:15 PM com.apple.launchd (org.apache.httpd) Throttling respawn: Will start in 10 seconds
Apparently, Apple decided to blow away my very custom apache2 config and replace it with a generic one. Not cool. As a developer of many web sites, I have a virtual host for every project of the form localhost.domain.tld. These were all gone.
Also, the php was broken. The fix included first downgrading php which required downloading and recompiling every single open source library I had (dozens) because of the new 64 bit object file format.
Then, finally I got the above error and using Time Machine recovered my old httpd.conf and extras folders from my pre-Snow Leopard backup and its all working again.
September 15th, 2009
Updating to Snow Leopard broke my mysql install. Pro-tip: back up your databases before updating to Snow Leopard.
I didn’t do this. To get the data back – recreate the /usr/local/mysql -> /usr/local/mysql_versionbuilddatanumberstuff symbolic link. This gets broken in the install.
I then clobbered the /Library/LaunchDaemons mysql item, and the /Library/StartupItems one. Now mysqld will not launch by default.
sudo cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
Now I am able to run
mysqldump -u root -A > saved.sql
to dump the databases. Now I downloaded the Mac OS X 64 bit mysql package and run the installer then reboot.
Now load my data into the new server using
mysql -u root < saved.sql
And I'm off to the races.
September 7th, 2009
last night. The glitches I encountered were
1) PACE license code needed updating
2) MIDI and Firewire Audio drivers needed updating
3) MOTU Ethno component needed to be removed from MAS folder
4) Virtual String Machine’s font got clobbered and had to be downloaded (found it through support FAQ)
Otherwise it all went great.
September 1st, 2009
Not really a service pak. Just no eye candy.
In other news, people doing audio production have found SL to be much more responsive and a whole bunch of glitchy behavior just vanished. I’d buy that for $30.
Just waiting for the UPS guy with the disk…
August 30th, 2009
and while I don’t have my copy yet, I’ve been getting the betas and I know what’s in it. There’s a lot there, but its not visible to the average user or non-programming so-called technology “pundit”. This is unfortunate. They are tossing it off as a “service pack” but its more like having your car detailed and the tiny single cylinder engine replaced with a fuel injected turbo V8. It looks like the same car – but it can go many times faster. As applications get updated, it will get even faster. How?
The core OS has been restructured to allow it to take advantage of all those cores in newer computers. So while we have the same body, it is all new under the hood.
The truth is that 3GHz is about the theoretical limit for clock speeds for the Intel x86 family. They’re not going to get faster. They are getting cheaper though. So now, instead of getting a processor that’s twice as fast every cycle, you get twice as many 3GHz processors. That’s all well and good, but much of the core OS has been built assuming one processor. So even though I’ve got a dual quad with 8 processors in the box, most of them are idle most of the time. That power is wasted.
Enter Snow Leopard. It restructures the way the OS divides and schedules tasks and supplies new apis for applications to parallelize logic to much improve processing throughput. Besides letting programmers take advantage of all of the Intel cores – OpenCL makes it easier to offload vector processing to the graphics processor – a largely underutilized resource most of the time.
The average non-technical user won’t see much change and that’s no surprise – but if this were “just a service pack” there wouldn’t be so many broken programs that need updating. The change is substantial and at this point, most application updates going forward are going to require Snow Leopard. Its not practical to build apps that take advantage of Snow Leopard and still work on older releases so this is the line in the sand.
Fortunately, Apple realized this and Snow Leopard is priced “almost free”. I’m not one to push people to upgrade working systems without a compelling reason.
However, eventually an update or a new application will come out that you’ll want and it will require Snow Leopard and this is why it is good that Apple made the barrier to updating very low. Certainly a forthcoming update to Jambalaya is going to be Snow Leopard only.
August 11th, 2009
Well its taken a long time, but I’ve finally gotten around to figuring out why permalinks were broken (it involves getting apache mod_rewrite and various file permissions sorted out).
So maybe the blog is fixed and I’ll start using it again.
OTOH, I’m not super happy with WP lately. It seems like it is collapsing under its own weight. I need to set up something for Musical Freak Show and I’m thinking about trying out Chyrp.
Meanwhile, I’ve got my YouTube channel up and running and have posted my first video. So I’m gradually figuring it out.