Author Archives: loufranco

Self Control

Since my computer is factory equipment, I consider its ability to show me news and social media a defect. One easy fix is to edit /etc/hosts to block these sites, but that’s reversible by just re-editing it. A year ago I found an app, SelfControl, that takes these edits out of my hands.

To set it up, you give it a list of blocked sites. Then, when you start it, it will put entries into /etc/hosts that sets their IP addresses to 0.0.0.0. If you remove these entries, it will keep reapplying them. And since it asks for privileges, it can do this in a complex way. You could thwart it if you wanted, but it’s enough of a pain that you probably won’t bother.

After using it for a while I added a few practices that make it more useful.

  1. I use the Due app on my iPhone (and Watch) for simple recurring reminders. I set up a morning reminder to restart SelfControl.
  2. I went into my /etc/hosts and made a copy of the SelfControl section (it’s clearly marked with comments) and made it a permanent part of my hosts file. I italicized permanent because I can edit this part, but it’s there to be a little bit of a deterrent if I try to go to any of these sites in a non-blackout period.
  3. At the end of the week, RescueTime sends me an email with a summary of my productivity. I can easily see if any new distracting sites are taking significant time and add them to SelfControl.
  4. I found an app for iPhone called Zero Willpower that does the best it can to replicate SelfControl on the iPhone. It’s essentially a content-blocker that you can edit and a timer you can set to disallow deleting. On the iPhone there is nothing they can do to stop you from removing the app or disabling its content blocking privileges, so thwarting it is easy if you want. Again, it’s enough of a pain, that it’s enough to keep me off distracting sites.

Introducing 3D-o-Mat

3D-o-Mat is a simple app that creates the type of 3D photos that you view with red/cyan glasses.

I have been writing apps that do this for a while. It was one of the first things I wrote with DotImage back when I joined Atalasoft in 2006 and ported their image processing commands to WPF. Then, I wrote a simple version for iOS that I showed to middle-schoolers when I was a volunteer for DIGITS.

I was recently invited to speak at a Smith College Python programming summer program for HS girls and I decided to make this app more real.

PS: here’s a tweet sized version of the app in Python that I shared with the class the last time I spoke:

This gist shows a better way to do it that preserves the color in the original photos.

GamePlayKit Rule Systems on Smashing

I wrote a 2-part series on GamePlayKit’s Rule Systems framework for Smashing Magazine.

Part 1 is the basic idea and shows how to replace conditional logic that might be strewn around a project into a GamePlayKit rule-system.

In Part 2, I show the support for fuzzy logic rule-systems (logic values ranging from 0.0 to 1.0 instead of strictly true and false). It covers a little more of the features of rule-systems and how to implement NOT, OR, and AND for fuzzy values.

Both articles are supported by Swift Playgrounds in GitHub so that you can play with the concept and try different rules.

NerdSummit 2017 Talk: Introduction to iOS Development through Apps

On March 18th, I’ll be giving a presentation to teach iOS development by looking at completed apps and customizing them.

If you are planning to attend and want help after the talk to set up your machine and get started on the exercises, here’s what you’ll need:

  1. To do the exercises, you need a Mac with Xcode 8.2+ installed. If you don’t have access to a Mac, I think we’ll have enough people with one and can pair you with someone.
  2. We’re going to be forking apps on GitHub, so having a GitHub account already would be good.
  3. You don’t need a device — we’ll be able to use the simulator for all of the examples, but if you want help getting apps on devices, sign up for a free Apple Developer account.

It’s a beginner talk, so anybody with an interest in programming will get something out of it. It will help if you have some programming experience (in any language).

Here’s the plan

  1. Basic Swift (enough to be able to read the apps)
  2. The MVC pattern as implemented in UIKit
  3. Interface Builder (connecting outlets and actions)
  4. Then, we’ll fork an app and make some customizations
  5. Based on the group’s questions, we’ll cover as much iOS Development and Swift as we need.

The idea is that the apps we’ll fork are generally useful apps that people might want a custom version of. All of the code is open-source, and you’ll be able to continue to develop them after the workshop if you wish and release them to the App Store.

I’ll introduce the apps in subsequent blog posts here (I have to make them).

There will be handouts so you can work on your own after the talk.

Deep Work for Programmers

In Deep Work, Cal Newport makes the case for sustained, focused work on hard problems and gives practical advice for helping you do it. The book helped me realize why two practices I had adopted were working so well. They are both related to the mindset I have about my computer and devices:

  1. I think of the computer I program on as factory equipment.
  2. I monitor my usage of it and make it impossible to do anything that interferes with productive work.

Most of the tactics I employ flow from adopting those two practices.

Your computer is factory equipment

To me, it’s a big problem that the same computer I use to write code can also go to Reddit. And Slack. And Gmail.

It’s bad that the phone that I develop apps for also gets text messages, calls, and other notifications.

The typical way to treat these machines is to use them as intended — as a general purpose machine. But programmers are not typical users of computers.

Imagine if Picasso’s paintbrush rang a few times a day. Or if Jane Austen’s notebooks also showed Tweets. Maybe we’re not doing as important work, but coding requires long spans of deep concentration, and we don’t need distractions to be a CMD-Tab away.

Business communication apps like Slack and e-mail are a tougher problem as it’s usually not ok to not run them at all. But even our collaboration apps can be a distraction if we don’t control their use.

If you accept this, it’s logical to take steps to turn this general purpose machine into just a coding computer.

Monitor your productivity

It’s hard to convince most people that they have no idea how productive they are, but you don’t need to trust me. Do this test:

  1. Write down how many hours you think you spend coding, doing business communication, and other work activities during the week.
  2. Go install computer usage monitoring software like RescueTime or Qbserve and let it run for a week.

I have been spending my whole career trying to measure and optimize my productivity. I used to do this more manually — just jotting down the number of hours between programming interruptions (this is a Peopleware suggestion) — but these tools are far more accurate and unforgiving. Even with diligence, I was surprised where my time was going.

But even more important than monitoring your work is doing something to increase the number of contiguous hours you spend programming (and on programming-related activities — code review, testing your work, technical documentation, estimation, etc).

Cal argues that there are two kinds of work we do:

  1. Work that only experts can do
  2. Work that you could train a smart intern to do in an hour

Look through your logs and try to figure out how many hours in a row you are spending doing the things that need your expertise (or expertise you want). You may still need to do the other work, but the time spent should be shrunk and sequestered to not interfere with the work that matters.

This doesn’t even address distractions like social media, time-wasting sites, or non-business communication. I’ll let your logs speak for themselves on whether you have a problem, but they will probably be incomplete since most of these distractions come on your phone, which isn’t as easily monitored.

Since usage monitoring software can’t be installed on an iPhone, I just assume that my phone is a giant distraction and set it up accordingly. Android users can install RescueTime, which I would recommend.

In the coming weeks, I’ll expand on my suggestions and explain my personal setup. If any of this sounds interesting, go read Deep Work, as Cal lays out the fundamental approach and many actionable suggestions.

NOTE: Here is a follow-up to this post with more details on how I use SelfControl.

Habits 3.0.1

Just in time for the New Year, I released a new version of Habits

  • Habit names are multi-line on the home page (finally)
  • Notifications on iOS 10 include your motivating photo
  • There are more controls for when to show the photo on the home page
  • Lots of little bugs have been fixed

Enjoy!

Developer Notes:

Habits most interesting to me as a hobby project — if you are interested,  you can also see my notes from 3.0 where I showed a screenshot of 1.0 — Habits was started almost as soon as the iOS SDK was officially released.

For this version, here are a couple of behind the scenes tidbits:

  • I ran the wonderful Synx on my project to finally align the folder and group structure.
  • I also introduced tailor into my commit procedure to enforce some Swift style.
  • I found my old svn repository for the beginnings of Habits — I am working on restoring that so that it looks like the pre-2.x history for what I have in git now.
  • I used to host my own git server repo, but that was mostly for backup. I decided to change my origin to bitbucket. I am thinking of one day open-sourcing Habits, but for now it’s private.

GitHub Profiles Update

The latest GitHub update includes some nice additions to the profiles page. A few years ago I wrote that you should never link directly to your GitHub profile in your resume or online bios:

GitHub’s public profile isn’t customizable and doesn’t do a good job of describing a person’s contributions. I recommend:

1. Create a page with a simple URL on your own domain (e.g. example.com/github) and write a narrative that takes me through your repositories.

2. Link to that page in your resume and in your GitHub profile.

I played around with my profile and even though it’s more customizable, my recommendation still stands: link to a page where you can put context around your profile.

In addition, I think it’s worth using the repository pinning feature to highlight the projects you would want someone to look at if they should get to your profile page some other way.

 

Handling Pluralizations Correctly in Strings

Earlier this year, Trello launched in 21 languages. I worked on the i18n effort of the iOS apps, and I have been collecting thoughts for a series of blog posts. The first one, about plurals, was published today on the Trello Tech Blog. It begins

On page 52 of my copy of K&R, in a discussion of the ?: operator, is this line of code

printf("You have %d item%s.\n", n, n==1 ? "" : "s");

And thus began my decades-long proliferation of plural-unfriendly strings.

To see why, read the rest of Lessons from Internationalizing Trello, Part I: Plurals on iOS

As a follow-up, I found a Russian translation of K&R. Here is how that line of code is translated

printf("Вы имеете %d элемент%s.\n", n, (n%10==1 && n%100 ! = 11) ?
    " " : ((n%100 < 10 || n%100 > 20) && n%10 >= 2 && n%10 <= 4) ?
    "а" : "ов");

Which is another way to do it, I guess.