Thomas Lextrait

Sr iOS Developer at Square

Read this first

measureBlock: How Does Performance Testing Work In iOS?

I was working on a mini project at Square involving performance unit testing for iOS. Essentially I’m looking into how we could introduce performance unit testing, what our options are and how it would scale on our CI. In this post I’ll just focus on the one tool Apple provides as part of its unit testing suite: the magical measureBlock method. The question was: how does it work? and is this going to work for us and our CI (continuous integration) process?

 What’s measureBlock?

For those who don’t know measureBlock here’s a little background. When you write a unit test in XCTest, a feature allows you to measure how long a block of code takes to execute. It looks like this in Objective-C:

- (void)testMyCodesPerformance
{
    [self measureBlock:^{
        [someClass doSomethingFancy];
    }];
}

Or in Swift:

func testMyCodesPerformance() {
    measureBlock {
...

Continue reading →


USCIS Help

I mostly focus on technical posts but usually when I write I try to write about things I personally struggled to find on the web so that perhaps my own post may help others looking for information in the future.

This will be about the United States Citizenship & Immigration Services (formerly I.N.S.). Plus I feel like immigration is a topic that affects people in technology a decent amount so I guess this should be relevant. Take this article as a list of resources that can help you getting processed by USCIS within your lifetime.

 Me

I’ve dealt with the US immigration and USCIS for over a decade and learned a lot over time. Some of my learnings I really wish I had learned earlier. For those who are citizens: a USCIS office is very much like the DMV with numbered waiting coupons except they have leather chairs. The reality with USCIS though is that if you fall through the cracks and...

Continue reading →


Getting Started With Chrome Extensions

Screen Shot 2018-01-18 at 4.27.30 PM.png

A long time ago, during an internship at Rakuten in Boston, I worked on a Firefox extension. It involved using an obscure markup language called XUL. There was very little documentation on it and it took me about a summer to build an MVP that could make requests to a NodeJS backend. That said, I wasn’t super keen on doing browser extension development again, however an opportunity arose.

At Yelp, all code repositories are stored in git on private servers. There is no UI so how do you do code reviews? Yelp engineers use an antiquated and open source piece of software called Review Board. Yelp is actually a contributor to the code base and maintains its own fork. Long story short… I didn’t like the Review Board UI and decided to fix it. However it was going to be a major pain for me to get access to Yelp’s fork of it and it wasn’t clear Yelp would let me deploy any changes. So I decided...

Continue reading →


Drone Hardware For The Rest Of Us

Coming from a software background I learned a few things about hardware while working on my Arduino drone. Much of what I learned is probably very simple and obvious and often that means it is not discussed much online as it’s considered common knowledge. However the landscape is changing: with Arduino, the barrier of entry has been lowered and people (such as me) who are not electrical engineers or hardcore hobbyists are able to build things. In this post I’ll go over a few things I learned and I hope it can save a few people many hours of research and trial & error.

 CW and CCW propellers

I always knew propellers could be designed to rotate either clockwise or counter clockwise.

FullSizeRender.jpg

However when I bought a set for 4 propellers on Amazon, I didn’t expect half of them to be clockwise and the other counter clockwise. It wasn’t mentioned on the listing at all. It is obvious now, quadcopter...

Continue reading →


Generic UI: Input<T>

Generic User Interface

For quite some time I’ve been bothered by the small use of generics in Apple’s iOS libraries. Third party libraries also typically make little use of generics. Generic typing is a fantastic feature of Objective-C and Swift. It allows developers to write code that is incredibly re-usable. The point of generics is really to write less code yet make it even more robust and less prone to errors.

TL;DR GitHub Generic UI

 What Are Generics? (or skip this to the next part)

For those who don’t use statically-typed languages much or just don’t know about generics, the simplest example is that of the array:

class Array<Element> { ... }

In this example the generic type is Element. The person who created the Array class made it so you can customize it for your own use. You can supply – at compile-time – the type of element the array will store. So if you make an Array<String> you will know...

Continue reading →


Find All Images With Given Attributes

I’m an iOS developer and with the release of Xcode 8 came a little issue. Apple introduced wide-color support on iOS 9. This meant that if you had 16 bit images then you couldn’t target older iOS versions, otherwise you would see something like this:

ERROR ITMS-90682: Invalid Bundle - The asset catalog at ‘Payload/XXXXX/Assets.car’ can’t contain 16-bit or P3 assets if the app supports iOS 8 or earlier.

So this prompted the need for me to easily find 16-bit images. Apple did help with that but it was really Xcode-project specific and I wanted to have something more generic.

 Note For iOS Devs (Others can skip)

For those of you who are finding this page because you’ve had this error, do also check this page: https://forums.developer.apple.com/thread/60919?tstart=0 and note the following:

If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will...

Continue reading →


Source Code Is Only Half the IP

Nowadays every company needs to be making some kind of software. Every company needs a website, a mobile app maybe or more. Because of that most companies, including non-tech companies have either adopted a team of developers or have allocated a budget for outsourced software development.

We have all come to realize that source code becomes stale very quickly if it is not maintained and updated. Libraries, API’s, plugins, smart phones all change and applications that depend on those eventually stop working if they’re not updated. This means we live in a world where you can’t just pay a team of developers to build a website or an app and then it’s just “done”. Software development is a never-ending process.

Because software development is never ending, projects typically last years if not eternity. People rarely stick around for the whole lifespan of a software project. Software...

Continue reading →


The Developer’s Dilemma

Screen Shot 2016-10-18 at 10.53.47 AM.png

I often see developers, team leads, development managers and so on who say they don’t have time for non-programming activities. Because of an aggressive schedule (I don’t know any company that doesn’t have an aggressive software development schedule), there is no time for:

  • Documentation
  • Recruiting
  • Blogging
  • Experimenting with new frameworks and tools
  • Building experimental features
  • Looking into new processes
  • Doing security audits
  • Fixing security issues that nobody knows about
  • the list goes on…

All these things though are crucial in the long term to ensure the success of the project and the company. Many recognize that and often the complaint is: “my boss (who may be a lead, a manager, director, VP Engineering or CEO even) doesn’t give me the time and flexibility I need”.

My theory and of course it’s just my own and I very well may be mistaken, is that when given the choice between...

Continue reading →


Road Trip Calculator Update

Some time ago I created the road trip calculator and wrote a post that went over the calculation of the true cost of driving from Boston to New York City in a $25,000 car.

Today I am making a small update to the calculator. Aaditya Prakash, a good friend of mine who is pursing his PhD in Computer Science at Brandeis pointed out a small flaw in the calculation. Aaditya reminded me that owning a car has a fixed cost and taking a road trip has no impact on that cost. Therefore in order for you to know how much your road trip is costing you, and I mean the road trip alone, then the pro-rated ownership cost needs to be subtracted from the calculator’s result.

 Car Ownership Costs

In order to really focus on the fixed ownership costs – meaning costs that don’t vary based on your driving – let us assume you’re not driving your car at all. What do you need to pay for?

  • Insurance
  • Excise tax –...

Continue reading →


Arduino: Power Consumption Compared

When I first started working on my Arduino drone, I decided I wanted to evaluate, understand and compare components before selecting them. Then I would be able to come up with an optimal combination of components, or if not then at least I would understand where my design is lacking.

Something I thought is fundamental is understanding the power consumption of every component so I could design a drone with a long range. However I couldn’t find a lot of data on the power consumption of the most key component of my drone: the Arduino.

At first I was tempted to just get the “best” Arduino, meaning the one with the best specs and most inputs/outputs. But why base the drone on the Arduino Mega for example, if it could run just fine on an Arduino board that consumes less power? And actually, the real question is: which one will consume the least power versus the specs it provides?

I thought...

Continue reading →