Space Vatican

Ramblings of a curious coder

On Mobile Safari and Iframes

For posterity, in the hope it saves someone a few minutes of that time: Safari on iOS does some really weird shit when it comes to sizing iframes.

Turning on Partial Double Verification

RSpec 3 added the concept of verifying doubles (As an aside the rspec 3 upgrade process was amazing because it treated deprecation as a feature rather than just vomiting untraceable warnings all over the place). Others have written at length about this but in a nutshell it means that things like

1
2
class_double(User, :name => 'Bob')
allow(some_user).to receive(:name).and_return('Bob')

will raise an exception if the User class does not have a name method. When you make a call to the name method on the (partial) double it will also check whether the arguments you pass are compatible with the method signature of the original object/class (including validating mandatory keywords).

Introducing Asset_symlink

Rails 4 made asset pipeline precompiling now lightning fast compared to rails 3.x. There were two reasons (that I am aware of) for the slowness in rails 3:

  • it would regenerate all the assets, each time (you can fix this via the turbo-sprockets-rails3 gem).
  • it used to precompile everything twice: once with the digests (the checksums in the filename) and once without.

The precompilation happened twice because your assets can reference other assets (eg a stylesheet with some image or font urls) so the difference between the digest assets and the non digest assets wasn’t just the filename.

Rickrolling With Ruby and Objective-C

In the session I presented at railsclub I finished off by showing how to use FFI to call into Objective-C (If you weren’t there on then my slides are online – I would recommend browsing through the section on FFI). I didn’t go into any detail because it was the end of what I think was a pretty technically intense session.

This definitely comes under the category of “doing something to prove it can be done” rather than anything more serious, but if you’d like to know how it works then read on!

Selectable Items in NSToolbar

NSToolbar has a mode where the toolbar items are selectable – this is commonly used to create preference windows, each item in the toolbar representing a section. If your delegate responds to toolbarSelectableItemIdentifiers: then the toolbar will allow these items to be selected.

You can do all this in IB (along with the rest of the standard NSToolbarDelegate stuff), since IB allows you to mark items as selectable.

The bit that confused me is that unless you also assign an action to the toolbar item (I’ve got mine pointing at a selectSection: method) then nothing will happen when you click the toolbar items, not even a change of selection state. Nowhere does this seem to be documented. I expected that even though I’d hooked up no actions and the toolbar wouldn’t be useful I would at least be able to play with the selection state. Hopefully this helps anyone else wondering why their toolbar isn’t working.