I have a facade over an asynchronous network call—that also performs pagination, ie multiple network calls in order to handle very large result sets—along the lines of this but I now want to use it in a context where knowing when it’s finished iterating is important (e.g in an NSOperation):
“less sucky option” because it makes it more obvious that the method returns paginated results.
And I have to say I agree with him on that. The only fly in the oitment however, turns out to be some filtering performed within the API methods which meant that determining if there were more results would have required some fancy look-ahead code.
In the end I went with my last option. It seems to have worked out rather painlessly :)
Further to my previous post, I also added a rake task to my Rakefile that uses rsync to deploy:
1234567891011121314
rsync_delete=falsedeploy_default="local"# snipdesc"Deploy website via local rsync"task:localdoexclude=""ifFile.exists?('./rsync-exclude')exclude="--exclude-from '#{File.expand_path('./rsync-exclude')}'"endputs"## Deploying website via local rsync"ok_failedsystem("rsync -avz #{exclude}#{"--delete"unlessrsync_delete==false}#{public_dir}/ #{deploy_dir}")end
I initally thought it would be pretty neat to work out the local website location in Dropbox but in the end I decided it was simpler to just leave the deploy_dir variable set to the default "_deploy" and have that directory symlinked to the approproprate Dropbox folder.
In the process I also took the opportunity to switch the URLs I was using for blog entries to the Octopress default. This in turn left me needing a bunch of redirects.
Site44 supports redirects via a well-known text file in the root of your website. The text file provides a mapping between source and destination paths. That’s all very well and good but I didn’t much feel like creating 300+ redirect mappings by hand. Besides the tedious nature of the task, the chances I was going to screw one or more of them up in the process were fairly high.
Thankfully, due to a previous blog move, I happened to have a bunch of permalink definitions in the front-matter of most of my blog entries. All I really needed then was a way to turn those into said text file.
A quick Google turned up the Alias Generator plugin for Octopress by Thomas Mango which was very close to, but not quite what I needed.
Hack hack hack on the plugin, a quick rename of all the permalink attributes in my posts to alias, and voila! a new plugin that generates a redirects.site44.txt with all my redirects:
# Site 44 Redirects Text Generator for Posts.## Generates a www.site44.com compatible redirects file pages for posts with aliases set in the YAML Front Matter.## Place the full path of the alias (place to redirect from) inside the# destination post's YAML Front Matter. One or more aliases may be given.## Example Post Configuration:## ---# layout: post# title: "How I Keep Limited Pressing Running"# alias: /post/6301645915/how-i-keep-limited-pressing-running/index.html# ---## Example Post Configuration:## ---# layout: post# title: "How I Keep Limited Pressing Running"# alias: [/first-alias/index.html, /second-alias/index.html]# ---## Author: Simon Harris# Site: http://harukizaemon.commoduleJekyllREDIRECTS_SITE44_TXT_FILE_NAME="redirects.site44.txt"classRedirectsSite44TxtFile<StaticFiledefwrite(dest)beginsuper(dest)rescueendtrueendendclassRedirectsSite44TxtGenerator<Generatordefgenerate(site)unlessFile.exists?(site.dest)FileUtils.mkdir_p(site.dest)endFile.open(File.join(site.dest,REDIRECTS_SITE44_TXT_FILE_NAME),"w")do|file|process_posts(site,file)process_pages(site,file)endsite.static_files<<Jekyll::RedirectsSite44TxtFile.new(site,site.dest,"/",REDIRECTS_SITE44_TXT_FILE_NAME)enddefprocess_posts(site,file)site.posts.eachdo|post|generate_aliases(file,post.url,post.data['alias'])endenddefprocess_pages(site,file)site.pages.eachdo|page|generate_aliases(file,page.destination('').gsub(/index\.(html|htm)$/,''),page.data['alias'])endenddefgenerate_aliases(file,destination_path,aliases)Array(aliases).compact.eachdo|alias_path|file.puts("#{alias_path}#{destination_path}")endendendend
Six days ago, my extraordinary wife Jess gave birth to our third and final (yes, really!) child at home, a beautiful boy with a working title where his name shall shortly, hopefully, be.
Two days ago, I turned 40.
Today, I finally shipped my first iPhone app, Readtime, that I have been working on sporadically for a few months now with Benjamin Birnbaum and Ben Green, and the support of the Cogent folk.
I wish I had something pithy to end with but I don’t. I’m mostly just sitting here, wired, reflecting on what a crazy time it’s been, how utterly fortunate I am to have the life that I do, and hoping that by writing it all down, I might finally get to sleep. I think it’s worked :)