A Chemist Coding iOs

Husband, Parent, iOs Developer, Chemist, PEN, used to exercise.

Read this first

Poor Misunderstood “Someday/Maybe” List

I’m gonna write this on the fly without fully referring to canonical “Getting Things Done” by David Allen, but I had a helpful realization when I pondered a problem that a friend (I’ll call him Sodmund) and I were having with regards to our GTD task lists.

Basically, Sodmund and I observed that we were typically accomplishing and average of n items on our task list every day, but we were adding n+2 items to our task list. These items were nice, next-action style items that we considered things we really wanted to get done, SOON. But inevitably, our averages stayed fixed. And thus the list of next actions that needed to be combed through, and reviewed on a weekly basis was growing and becoming way too long. (and here is where I need to review what DA would recommend).

My “aha” moment came when I discussed this problem (what to do with the tasks that build up in your task list that are...

Continue reading →


I Can’t Overstate This Enough

Hardly a new sentiment, but I personally will never not need this exhortation to KISS.

And to be clear, when I talk about keeping things simple ( particularly in production code), I will forever mean to keep things conceptually simple. The price of minimalistic elegance can be high and not everyone on your team has paid that price (of advanced language features or category theoretical concepts). In addition to the price of learning that you have personally paid over the years, there is an added you paid while writing the code of your own immediate attention and concentration. Sadly, when you revisit this code, you will need to pay a a good bit of that price again.

The largest downside to the fact that our industry is made up of so many engineers who are learning as they go, is that they express their newfound knowledge in code that others may have to work with for years and don’t...

Continue reading →


Faster build times by leveraging multi-core CPU!

How in the world is this not the default and how have I not heard of this before?!?

Buried in this [helpful blog post][littleThings] about making your XCode life easier, is this tip:

Faster build times by leveraging multi-core CPU ?

defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`

I tested it on my work project. I cleaned, cleaned the build folder and restarted XCode in both cases. Results:

Before After 23.4 s 13.9 s

Considering how often I build this project in a day (>20 times?) that is a great return on investment, even if it is only minutes.

Caveats

  1. I am pretty much just cutting and pasting here. So read more if you want to be safe. Messing with defaults regarding cores like that can definitely impact battery life and other stuff.
  2. I don’t know what the default value was. I don’t know how to restore it. I...

Continue reading →


Facebook Friend Suggestions and Privacy Porosity (via Android IRL Friends?)

A few months ago, my wife came to me asking how Facebook would know to suggest a couple of people that she had spoken to professionally on her phone. I asked if they had been in the same location, or if they were in her contacts, or if you had mutual Facebook friends. “Maybe, yes”, and “No”, and “No” were her replies. I checked her privacy settings, and sure enough the OS privacy settings indicate that , and I think that . We talked it through, and I couldn’t find anything online about how this could be happening, but we also didn’t know the nature of the other people’s phones.

Then just the other day, I got a friend suggestion for a person that I had spoken to on the phone and texted with. We had also been in the same location a number of times. And we don’t have any direct mutual “friends”.

I do know that this person uses an Android phone, and what little research I did do, indicates...

Continue reading →


Finding From Where A Method Is Being Called

The linked SO post has a nice method for logging where an Objective-C method is being called from. Simple but helpful.

    NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1];
    // Example: 1   UIKit                               0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
    NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString  componentsSeparatedByCharactersInSet:separatorSet]];
    [array removeObject:@""];

    NSLog(@"Stack = %@", [array objectAtIndex:0]);
    NSLog(@"Framework = %@", [array objectAtIndex:1]);
    NSLog(@"Memory address = %@", [array objectAtIndex:2]);
    NSLog(@"Class caller = %@", [array objectAtIndex:3]);
    NSLog(@"Function caller = %@", [array objectAtIndex:4]);

Continue reading →


CSV to Multi-Markdown Tables

One person noticed yesterday’s yak-shaving and liked it, which was all the excuse I needed to shave it some more. But I am good to go for now, though this still is still fairly fragile: you have to select only the table lines, there’s no way to escape a comma if you want it in a particular entry, it won’t catch if there are different number of items on each line, etc.

Here is the downloadable workflow .

I cleaned up the code in ways that were useful learning exercises for me and added support for >, <, = as separator indicators

so this:

one, two and a half, three and a quarter
four, five, six

still outputs to this:

|  one | two and a half | three and a quarter |
|  :---: |  :---: |  :---: |  
|  four | five | six | 

but now this:

one, two and a half, three and a quarter
>, =, <
four, five, six

outputs this:

|  one | two and a half | three and a quarter |
| ----: | :---: |
...

Continue reading →


A Quick Swift Script Yak Shave

[Updated Version with downloadable OS X service]
In the process of writing a longer post yesterday, I wanted to add a markdown table, and was once again annoyed at the mild PITA that it is to use pipe characters and then the formatting characters a lá:

|    title    |   title2   |  
| :---------: | :--------: |  
|  entry one  |  entry two |  
| entry three | entry four |  

Being aware of Brett Terpstra’s excellent [Markdown Services][markdownServices] that have a table cleanup function, but actually writing the da** tables is kind of annoying, so I in classic [Yak-Shaving][yakShave] fashion, I decided to write a simple [Swift script][OSXScripts] that would turn the following into the format above. Then make that into an [OS X service][automatorServices].

title, title2
entry one, entry two
entry three, entry four

It really wasn’t that tricky, and probably would have been at least...

Continue reading →


Possible Future macOS Names

Just for funnies. Others have done this as well before

We’ve had:

Maverics
Yosemite
El Capitan
Sierra

Criteria as I see them

  1. In California
  2. Natural Feature or Area
  3. Proper name.
  4. Has to sound good when spoken.
  5. Well known, or famous within a niche

Bad or doesn’t sound right

Death Valley
Long Beach
“Anything” Beach
Silicon Valley, plus, doesn’t meet criteria 2
Lassen
Fresno LOL
Sacramento ROFL

Possibly, but connotation may be wrong:

Malibu - first three seem too fancy
Napa
Sonoma
Cupertino - too self-promoting
Ventura - at least to Californians, this might sound low rent

Possible Bets - vaguely in order

Mojave
Capistrano
Shasta
Calistoga
Sequoia
Point Reyes
Ojai - technically a town, but also a very natural area
a beach name without including “Beach” e.g. Hermosa
Pinnacles
Red Rock
Humboldt
Big Sur
Tahoe
Monterey
Carmel

I may add to this over time.

Continue reading →


Apple Watch Crown Events – Thinking About Discretely Triggered Events

One of the biggest frustration points for me on Apple Watch when working out is that a wet screen does not recognize touches very well. So a workout app that lets me mark a lap, pause the workout, or anything like that is limited, because many times it fails because I sweat a lot [1].

But now, with Apple exposing WKCrownSequencer and its delegate means that apps can receive direct input from the crown. Examples shown include rolling the crown and moving a marker along a plot.

But how does this help for discrete events? It is fairly trivial to create discrete events by triggering something based on a threshold rotationalDelta. Below is the code (not Swift, sorry!) for a quick proof of concept for marking laps by quickly spinning up, and stopping the timer by quickly spinning down.

I’ve only tested on my simulator so far, but when I test on the watch, I’ll try to capture video.

I would...

Continue reading →


There Are A Lot Of Dudes

Every so often, you have a moment when you briefly see something in an entirely new light, and last night I had such a moment.

While cramming into a room for a great panel discussion about some of the Apple announcements, I was just overwhelmed by profound homogeneity of the programming community (sloppily dressed, male, white and asian). This is something I already knew, have talked about, and thought about. But in the moment, I just realized how intimidating at a visceral level it must be at times to enter this profession for anyone that isn’t in the demographic.

And all things considered, this was a SUPER welcoming event, with a panel that was half women, half men, the moderator also introduced the event with fully articulated and affirmed code of conduct. Really friendly. No “bad” behavior present at all.

I don’t have a point, but wow, when you get a few thousand programmers...

Continue reading →