mark cerqueira well-rounded nerd

Half-Baked Cookies in WKWebView

Apple released WKWebView in iOS 8 to replace the problem-ridden UIWebView. NSHipster has a fairly comprehensive diff on the two classes, but the general gist is that WKWebView performs better, is more stable, and has cleaner APIs.

A really useful paradigm for using web views in native apps is to build things on the web, and then have multiple clients (e.g. iOS, Android, Mac, Windows) authenticate a web view and point to that website. It’s pretty efficient: you build things once and reap the rewards across multiple platforms.

But it’s not all sunshine and rainbows! See WebKit bug 140191 - WKWebView provides no access to cookies. The crux of the aforementioned system working relies on being able to authenticate the web view. Not having access to cookies makes authentication much, much more difficult.

Fortunately, while that bug is approaching its 2 year birthday, there are plenty of “solutions” shared on StackOverflow on how to get around this problem. My personal favorite is by user3589213 whose solution intercepts every navigation request, cancels it, and rebuilds the exact request but this time with the cookie inside it. Here’s an Objective-C adaption:

All this said, half-baked things keep engineers employed so I can’t complain too much!

OMG Trailing Swift Closures

I’ve been cheating on Android lately… And messing around with iOS! And by messing around I mean doing iOS at Evernote; I developed the recently released Sign in with Google feature for iOS!

When I left iOS in 2012, Objective-C was king, but now a new challenger has emerged: Swift! The other day while messing around with some Swift I discovered trailing closures. It’s not a huge thing, but the beauty of it totally blew my mind. If you have a function that takes a closure as an argument and the closure is the last argument you can write the closure OUTSIDE the function’s closing parentheses!

Here’s a simple example with a function that takes a closure, calling that function with the closure as a regular argument, and passing the closure as a trailing closure.

It’s pretty minor but I was giddy when my coworker showed me this trick! If you don’t know about trailing closures this looks like black magic so be sure to let all your friends know about this!

Useful Utilities - SteerMouse

I’m really picky about my computer mice and even more picking about how my mouse controls the on-screen cursor. macOS lets you control only Tracking Speed in System Preferences. But that’s not enough for me. I need control. I need precision. I need to make the mouse an extension of myself.

Only one knob of control!?

Enter a very little nifty utility that has satisfied my mouse needs: SteerMouse! SteerMouse lets you customize everything about your mouse, but I mostly stick to the Cursor customization that lets me control both Acceleration and Sensitivity. With the most recent 5.0 update, they’ve even added in top configurations for different types of mice.

I prefer high sensitivity cursoring.

I really only use the Cursor customization of SteerMouse, but SteerMouse lets you configure all aspects of your mouse. While researching for this post I learned that the company behind SteerMouse has a product, CursorSense, that only has cursor customization functionality for half the price ($10) of SteerMouse ($20). The product page for CursorSense has a good explanation about why customizing sensitivity is super important to getting a good feel on cursor movement.

Give it a try! You’d be shocked at how much better the world is when you become one with the cursor on your computer!

First World Phone Disappointment

It’s been a busy month for mobile phones with the announcements of the iPhone 7 and Google Pixel… and exploding Samsung Note 7s! Cell carriers in the US have also become more European with how they do subsidies; the “upgrade every two years because you’re always paying a subsidy price” ideology no longer applies. If that last statement makes no sense to you, check out this TIME article on recent changes to buying a cell phone.

So given all this, do I feel like I need to upgrade from my iPhone 6?

There's only one choice if you like exploding phones!

No. The iPhone 7 and iOS 10 show a lack of creativity on Apple’s part. Siri is a constant source of frustration and Apple seems to be keen only on teaching Siri more jokes instead of making it actually useful and reliable. The Google Pixel is what happens when you copy Apple’s iPhone but forget to copy the most recent version and forget to remove the bezel where the iPhone’s home button goes.

I was most excited for the Google Pixel because I am an Android developer trapped using an iPhone. The complete dearth of powerful Android phones running the stock version of Android is depressing. The Google Pixel is the first step to delivering this but it just doesn’t seem that much better compared to my two year old iPhone. That’s disappointing.

Ultimately I think my aversion is largely driven by the changes to how US cell carriers now handle subsidies. For the pricetag, neither phones make me feel like my iPhone 6 isn’t taking care of all I need from my phone. Guess I’ll just wait for next year… #FirstWorldPhoneProblems

Redesign! Jekyll 3 and Lanyon

When I first started this blog in 2013, I stringed it together with a very basic understanding of Jekyll, Ruby, HTML, CSS, and a bunch of other acronyms I don’t fully understand. Like any well-engineered system, I didn’t know all the internal details but naturally kept adding to the magnificence of this machination.

A few years on, I tried upgrading from Jekyll version 2 to 3 a few times and always ran into deal-breaking issues. Welp! As with any good stacak of technology, don’t upgrade it if it ain’t broke!

In early August I finally bit the bullet all the way and upgraded to Jekyll 3 and updated the theme of the blog to use the popular Lanyon theme. The upgrade to Jekyll 3 let me go back to simply publishing my blog by pushing new commits to GitHub and the Lanyon theme let me cut a large amount of bootstrapping files from my codebase.

There were a few issues to iron out along the way but now, the blog now feels leaner and meaner. It’s a little heavy but feel free to check out the commit that made this transition happen. I love commits with lots of red (i.e. removed code) that still let me keep all the original functionality!

Happy blogging!