Thomas Lextrait

Sr iOS Developer at Square

Page 2

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 →

Boston to New York: The True Cost of Driving

It is no secret that I love to drive. It may sound insane to many but I actually enjoy my 30-minute morning commute to work. For me it’s a privileged time when I’m alone, comfortable and can catch-up on podcasts and audio books. Anyhow this post isn’t about that, it’s about the true cost of road trips.

I have flown, taken the train, taken the bus and driven to New York many times. No surprise there: driving is my favorite because it’s the mode of transport that provides the most freedom. So what does it really cost to drive from Boston to New York and back?



Let’s assume you own an average German car that’s worth $25,000 and has 15,000 miles. It doesn’t matter what brand or what options it has. We know that when it reaches 30,000 miles it will be worth $20,000 (Edmunds). That’s essentially a depreciation of 30 cents per mile. I know it’s not linear but let’s assume it is...

Continue reading →

Displaying Custom Pins on MKMapView for iOS

Please forgive minor inaccuracies since this is my very first iOS development post! email me with your suggestions. Also, this should work with at least iOS 7 and 8.


I have found a few articles on the web that explain how to customize map pins but it turns out that a few issues arise when one does. Additionally an important use-case that I haven’t read a lot about is when pins need to contain dynamic elements such as text, which would be unique to one pin. I thought that I’d consolidate all this information in one post.

First, when designing custom UI elements I always prefer implementing a separate class. Therefore I recommend sub-classing either MKAnnotationView or MKPinAnnotationView in order to represent a pin. Just as a note, MKPinAnnotationView is a child of MKAnnotationView that allows customizing the color of the pin if using Apple’s default pins, as well as choosing whether...

Continue reading →

Marriage in Vietnam

Thanks to my wife Nhi for helping me write this post

 Traditional Wedding Ceremony (“Lễ Vu Quy”), December 31, 2014

This winter I got married in Vietnam and did a traditional ceremony. It was fun and I wanted to share some of the details and intricacies such a wedding entails.


On the day of the ceremony, the groom organizes a procession that travels from his house to the bride’s – Obviously I don’t live in Vietnam so we used a hotel in Saigon. The procession is led by two representatives: a married elder couple who is chosen to help organize and respect the traditions. They are followed by the groom, the groom’s parents and family, and the groom’s friends.

 Procession, Gifts & Significance

In the procession, the groom, his family and friends bear decorated boxes covered in red cloth. These boxes contain gifts representing the wealth that the groom’s family will bring to the bride’s...

Continue reading →

Building a Drone With Arduino (p1)

There’s a few things I’ve always wanted to do but never had the time to. One of them is to play with an Arduino. The Arduino is a piece of hardware designed by a team in Italy (the blue board in the picture below).



This little board is truly disruptive because it breaks down several barriers that existed in the hardware world. I’ll illustrate this with an example: in order to develop a hardware product (a drone, a smart thermostat, a phone…) one could buy an ARM processor on a board and program it except…

  • That board costs a lot of money
  • The documentation is very complex and meant for professionals working in big firms that integrate this into consumer products
  • It requires proprietary software and cables in order to load applications into the board

Arduino solves all these issues. First the Arduino UNO costs just $25 from the official store, or much less if bought from a...

Continue reading →

UPC Database

I spent some time trying to find a UPC database. Essentially it is a database that associates bar codes to products and company names. Usually you would pay money to purchase such a database from a company that keeps one updated. However it turns out there is one available for free, right here:

I could be mistaken but I believe it dates back to 2010.

View →

Prime Numbers

Prime numbers are fun and it’s even more fun to come up with ways of finding them. People interested in prime numbers are usually interested in these areas of research:

  • Finding algorithms and formulas that yield a lot of prime numbers
  • Discovering the largest prime number possible
  • Designing algorithms that can evaluate a prime number as fast as possible

In this post I’m just interested in coming up with a very efficient way of finding all the prime numbers up to X. To achieve this, I designed a simple C program that applies a well known algorithm.

 The Algorithm

First, a prime number is a positive and integer number that can be divided only by itself and 1. Such numbers are:

1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29...

Whether 1 is a prime number or not is up to discussion…

The obvious way to find these numbers is to follow the prime number definition and figure out if each and every...

Continue reading →

Of Web Apps & Architecture

In the recent months I have been asked several times what I think about the architecture of web apps, so I’ve decided to write this post. The architecture of web applications has been changing over the years and in this post I’d like to talk about where things are now and where I think they should be going.

 MVC & Web Stacks

The Model View Controller design pattern and its derivatives (such as MVVM) have been the ubiquitous choice for user-facing applications since a while. This has given us web applications usually designed in two to four business layers (depending on what we define as a layer).

Several elements go into the design of an architecture: design pattern, protocol of communication between layers, choice of different paradigms for data storage… Here I’ll only focus on the protocol because it has been big a topic of discussion lately. I’ll start by presenting a few different...

Continue reading →

HTML and CSS for Beginners

If you’re reading this, then you’re probably thinking of building your very first website though you probably already have a domain name and hosting. In this short guide I’ll only focus on the essentials for writing the code to build a couple web pages.

 Get a Text Editor

The first thing you need, is to choose a text editor. You will be writing HTML source code and therefore you need to choose an editor that’s appropriate, Microsoft Word isn’t going to work for this. There’s a million choices and software engineers can get defensive and are often religious about their favorite code editors.

Screen Shot 2014-05-15 at 3.54.43 PM.png

 For Windows

  • Sublime (free to try, unlimited)
  • Notepad++ (free)
  • More…

 For Mac

  • Sublime (free to try, unlimited)
  • TextMate (free to try)
  • Coda ($75)
  • Vim, Emacs…

 Get Started

Let’s dive in, write something and see what happens. Just write:

Hello World

Save this to a new file called index....

Continue reading →

Get Started with LaTeX


LaTeX, originally TeX is the name of a markup language as well as the piece of software that renders it. It was created by Don Knuth and later extended by Leslie Lamport. You can read more about LaTeX on Wikipedia and the LaTeX project website, but essentially it’s an application that allows you to produce documents.

 Why LaTeX


Unlike Microsoft Word, LaTeX is not WYSIWYG (it’s not “what you see is what you get”). This means you’ll write text, press a button and then the application will turn that text into your final document and look amazing. There’s a huge and not-so-obvious advantage to this. When you write text in Word or Pages, you will spend a lot of time tweaking spaces, font sizes, line heights and such in order to obtain the visuals you want. What you want is things to line up properly, spacing to be even and pages and paragraphs to break at the right spot...

Continue reading →