TDD with Firestore functions emulator

Having spent time running tests inside and outside Firestore’s emulator, I learned that using the emulator is more than 50% faster.

Here is the latest flow we are using at Circuit. If you know of a simpler way, please let me know at gus [at] getcircuit [dot] com.

Basic version

firebase emulators:exec --only firestore 'jest'

You can replace jest with the runner of your choice.

Abstract the emulator call

Install scripty:

yarn add scripty

Add an entry to package.json:

{
  …
  "scripts": {
    …
    "test": "scripty"
  }
  …
}

Create a directory called scripts in the root of your project.

Create a file with path and name scripts/test:

#!/usr/bin/env sh

str="$*"
firebase emulators:exec --only firestore "yarn jest $str"

Allow computer to run this file:

chmod 644 scripts/test

Now you can run yarn test and add anything you would add to the command, like yarn test --watch, yarn test /path/to/test.file.

Enable connecting with a browser’s debugger

Add an entry to package.json:

{
  …
  "scripts": {
    …
    "debug": "scripty"
  }
  …
}

Create a file with path and name script/debug:

#!/usr/bin/env sh

str="$*"
firebase emulators:exec --only firestore "node --inspect node_modules/.bin/jest --watch --runInBand $str"

Allow computer to run this file:

chmod 644 scripts/debug

Add debugger to any line of your Firestore code.

Run yarn debug — you can also pass a filename to focus on it right away.

Open your browers’s developer tools.

Click on the green cube (Node’s logo):

This will open the debugger and you’re ready to step debug your code.

Simple tips for applying for a new development job

For several years, recruiting has been a part of my job in software. A few times I’ve been on the other side, looking for a job myself.

There are many low-hanging-fruit-type tips that can really make a difference when we look for a job. By making mistakes myself, seeing them made while recruiting, and by talking to colleagues, it’s now possible for me to list a few. Some may seem obvious to you — if you haven’t yet recruited, you’re in for a surprise over how common they are, and how much they affect the chances of someone getting a great job.

Learn about the company first

Before starting your application, spend no less than an hour attentively studying the company. Go to YouTube, try to watch videos involving top leadership. Read articles and learn about the people there.

Apply only to companies you care about

If you are in full application mode, apply to no more than 3 companies per day. Ideally 1 company.

If the company’s purpose doesn’t resonate with you, recognize the fact and move on.

Look at companies’ careers pages

Several companies, often the best ones, don’t advertise open jobs. They have their own careers pages and, relying on their reputations, will wait for applications.

For people who like to work remotely, Remotive’s company list has been helpful to a few people I know: https://remotive.io/remote-companies.

Don’t wait to apply

Once you’ve learned about a company and feel enthusiastic about it, apply immediately. In the global development market, good companies receive hundreds of applications on the first day or two after they post a job.

Apply to many jobs

While not applying to just any open job, do apply to as many of them as you truly like. Statistically, odds are low that you will be called for one given opportunity.

Start early

If I am suggesting you do not apply to too many positions each day, but to apply to many positions, by consequence I am suggesting you start early in your job search. Maybe practicing going through recruiting processes even before you need or want to do it can be ideal.

No spelling or grammar errors

Make it perfect in the language the company operates in. Pay someone, or a service, if needed. Great companies will quickly screen out applications that have language mistakes. By writing minimally well, expect to go to the top 10% of all applications.

Add a Github link to your CV

This is a huge differential. Prefer Gitlab or Bitbucket? Great, use your favorite. Don’t have public repos? Add repos of things you study, it’s perfectly fine. Make sure you add very good READMEs enabling visitors to run and test your repos.

Nothing like relationships

All the above may not be necessary if you have good relationships with former colleagues. You may be sought out before you need to look for a job. For this to happen, it is not enough to be very proficient at the technical part, people have to like spending time with you.

Git basics while typing less

Very short git commands

As computer programmers evolve in their craft, they increasingly identify repetitive tasks at all levels. One of the most basic levels is typing on the keyboard. Some programmers choose to invest effort and minimize typing. I am one of those people.

Git commands are among the ones I use the most, as listed in decreasing order with the number of times for each:

1241 gc
637 gco
583 v
419 git
373 cd
368 rm
316 mv
302 yarn
299 gb
247 gto
215 ga
213 c
191 gst
160
136 bundle
124 ©
115 mkdir
114 cp
106 npm
106 gt

If you’d like to see yours, you can run the following on the terminal: history | awk 'BEGIN {FS="[ \t]+|\|"} {print $3}' | sort | uniq -c | sort -nr | head -n 20

Please note that the number 20 at the end is the number of results to retrieve.

Back to my own history, you can see that:

  1. I use a lot of aliases
  2. Most of them are git-related, and that’s why they start with a g; gc is git commit, gco is git checkout and so on.

Recently I have taken this to the extreme, and so far the results have been excellent. Below are the commands I am able to run:

c (git commit or git commit -m, depending on the args passed)

p (git push)

a. (git add .)

b (git checkout -b)

The c function works for the following cases:

  1. c (will open the text editor for a long commit message)
  2. c “Your commit message” (acts as an alias for git commit -m
  3. c Your commit message (the one I love as you just type c plus the message, and it works)

While p and a. are calls with no args, with b you must simply add a branch name.

These are extremely simple improvements to the flow, and together with many others that I created or that I use from libraries, they make the path from brain to computer shorter and more pleasant.

To see how these are implemented, please visit this gist: https://gist.github.com/gusaiani/70736c970c2b2d4020006eb7dd31bc40

The commands in the gist which are not defined in this file come from oh-my-zsh plugins.

My Year in: Tech

I started the year of 2019 as a front-end developer at Toptal’s core team. Just a few days later, I was invited to be Team Lead for a brand new team.

My emphasis turned, again, to working with people. That was a delight and I fully embraced the opportunity to help build a team. We had a few company veterans enlisted to start the new team, all of whom I had not worked with before, and we needed to hire two more front-end engineers.

The first recruitment process was for an excellent React engineer. It was done very deliberately and unhurriedly, to make sure we raised the overall level of the team on the React stack. It took us a little over 2 months until we found a great guy, who has contributed a lot this year.

The second engineer was a gift to us, as he was initially hired for another team. Happy to say he’s also doing tremendously well.

We quickly became a real team. It seems we did a few things that helped: communicating a lot, admitting mistakes and ignorance openly and quickly, and being real human beings.

One teammate brought along the Personal Questions call from his previous team. This call has a simple structure: one team member asks one or two questions, personal as the name says, to everyone on the team.

The questions are as simple as “What was the best trip you ever took?”, or “What is your favorite dish?”. It’s up to the team to let this call become just a little window on who they are, or a huge gateway to people’s souls. Yes, it’s possible to cry while listening to someone tell you about their favorite food once they tell you the story behind it. The bond I felt with the team was immense.

Dedicating at least one or two hours per week of each team member’s time to building rapport makes a big difference, particularly in new teams. Next year I will work to learn more ways of doing that.

I made my share of mistakes. The one that comes strongest to mind is about having patience before giving feedback to people you may like personally but don’t think are doing a good job — especially when they are not reporting to you. Convincing people to change is hard enough as it is, doing it without mutual trust and knowing their motivations is likely to backfire.

Another lesson I was reminded of by a mistake of mine is the “no surprises rule”. It’s often hard to know, in advance, how sensitive some task or decision may turn out to be. Next time something I do starts to deviate too much from what was agreed-upon, I should remember to share that early on, and avoid surprises, because the surprise itself may make people react negatively to something fundamentally desirable, or I may have the wrong assumptions or decisions and other points of view will help me see that.

I stayed with the team for a total of 9 months, we launched a good chunk of the new application we were developing, and then I was enlisted to start a new team from scratch: to recruit every single engineer, and help recruit designer and product manager.

It was painful to say goodbye to a team I loved so much.

Soon it was back to recruiting, this time a few weeks of full-time effort, and we are still at it. We seem to be close to hiring two people, and have one more front-end and one more QA person to bring onboard on the engineering side.

This recent team switch gave me time to study programming after a several-month hiatus. I am focusing on new React APIs, from Hooks to Context and Suspense, as well as testing, TypeScript and, soon, Apollo.

I did continue to study the Elixir language source, something I’ve done for maybe 3 years now. This year I did relatively little of it. I love Elixir just as much as always, and am thankful for having learned so much from its community.

I plan to go multi-team as soon as I have a chance, be it in an Engineering Manager or CTO role. Thus I dedicated more time than ever to reading about leadership, management and communication, often with a big emphasis on tech. Especially for people who are new to management, I recommend The Making of a Manager by Julie Zhou.

A personal take on interviewing programmers

A few months ago some members of the team I lead at Toptal’s core team started interviewing programmers.

The fundamental questions that popped up were simple and deep: What should I look for in the interviewee? How do I know I should pass or fail the person?

I really like the priorities my own former supervisor, Timo Roessner, advocates: to look for—in decreasing order of importance—a team player, a good communicator, and a technically excellent person.

The person should ideally be very good at all 3 requisites. The main point, however, is deemphasizing technical wizardry in favor of interpersonal skills.

How to assess team-playing chops in a 90-minute interview with a coding challenge

Team-playing chops and communication chops seem intermingled, and in fact I believe one potentializes the other, but they can be assessed quite separately in software engineers.

As you facilitate a coding challenge or nearly pair-program with the interviewee, try to make it as close to the interviewee’s normal workflow as you can. Don’t use CodePens, have the interviewee use the editor or IDE of her preference. Apart from the technical things you need to evaluate her on, encourage her to use her favorite tools and procedures.

What you need to evaluate the candidate on is up to the needs of your company or team, but in general I prefer to give the candidate a wide-open small project instead of some algorithmic or procedural task. The reason is you will get a chance to role-play being the customer or Product Manager, and you can talk to the interviewee as such and see if she is able to conduct a dialog like this.

Calibrate, as you go along and get a sense of the candidate, how high-level or low-level it’s better to be. That is, is this person more concerned about the coding nitty-gritty or about what the entire project should do? Both are fine and necessary programmer inclinations, but the quicker you spot the candidate’s preferences, the quicker you can develop a rapport.

As the coding challenge starts, pay attention to the questions and shared thoughts. It should be clear to you, given some experience, if the candidate has mileage or a willingness to openly express thoughts. If they don’t say anything at all, probably this person will behave the same way at work.

Avoid, or delay, “helping” the candidate. Generally, in a coding challenge lasting 1 hour, I may interfere 1 to 3 times. But when you do, try to make it very meaningful and make it so that the proposed change of course really takes things in a different direction.

For example you propose the programmer develop a simple game. She starts by crafting the algorithm that will define if the game is over. As the interview goes past half its allotted time, and if the candidate has shown a good direction regarding the solution, propose she create the UI (if she is a frontend developer), or suggest creating a way to store a leaderboard (if she is a backend developer).

The way the candidate reacts to such proposals can be telling of a team player.

Also, very often candidates will do or say things that you don’t know anything about. Tell them you don’t know anything about that and see how they react. Do they explain it to you? Are they surprised? Do they convey a sense that they respect you less for that? But don’t pretend you don’t know something you know—you don’t need any trickery to interview people well.

How to assess communication chops

Assessing communication skills is a bit easier than assessing team-player inclinations. Start with the basics: can you even understand what the interviewee is saying? Often that is not the case. If and when you don’t, tell them that in a gentle way. This happens particularly often in international interviewing when spoken languages are not native to you or the candidate.

The opposite can happen: the candidate does not understand you. You should, of course, try your best to communicate clearly, and if the candidate still has a hard time getting what you are saying or asking, notice if they have the energy to ask you to clarify. If so, that is a good sign.

Being able to listen deeply is what differentiates an ok communicator from a good or great one. Does the candidate flow from what you are saying? In other words, can you notice them using and reshaping pieces of your discourse? Repeating things back to you transformed? Those are good signs. If they just respond things that seem unrelated to what you have been saying, then clearly this is a minus. More often things fall around the middle, and with time you will develop a feel for how good the candidate seems to be, plus the courage to use your intuition when the decision is not clear-cut.

How to assess programming chops

This is the easiest part if you yourself are a programmer, but it’s still challenging sometimes. Granted, it’s easy to reach a conclusion in extreme cases: if the candidate did really poorly or just brilliantly in the coding part.

When things fall more in the middle, which is by far the most typical, your skill can make a huge difference in the decision to say Yes or No to a candidate.

I always like it when a candidate writes, in human language, something like a list of things that need to happen in the program. For example, if the proposed task is to build a search user interface: to jot down that the screen has an input and a submit button, the user will type a string in that input, then press the submit button, and so on. This helps the candidate “think like a computer”, it allows her to expose her thought process to the interviewer and, if her assumptions are off-base, to know early. The worst that can happen is to end up with a little algorithm of what to code.

TDD, or anything similar to that, is a huge positive differential. It is a kind of planning ahead.

I must say it’s very rare that anyone uses TDD in interviews I run, and I’ve run a few hundred of them at the very least. It has never ever happened that a candidate wrote down point by point what should happen in the application.

Finally, good code architecture early on is one of the strongest signs that the candidate is good. If they refactor continuously, improve variable names often, and order things in their codebase without losing their train of thought, you are looking at a hire. And that’s why giving people much harder tasks than they will face in their work is typically not a good idea: you need to see how they can make code understandable to fellow programmers.

So if they start one file and fill it up with disorganized, commented out code and huge blocks of attempts, unless you asked them to do something too hard, in general consider this as a potential flag. But don’t get stuck to this: it’s not uncommon for great developers to seem quite sloppy the first 15 minutes in, and 10 minutes before the hour, to start deleting code and apply a final layer of improvements that leaves the code looking quite wonderful.

If you give the candidate a project that is larger than the hour you have to interview, something I support you do—as long as you set the right expectations, otherwise you will have a frozen person in front of you—, and you enabled the candidate to own the code in her machine, the bonus point is them continuing the project on their own. Until recently I sometimes suggested they do it. Nowadays I don’t even suggest that. If they have a way to reach me, they can do it if they want. I certainly take it as the strongest sign of interest in the part of the candidate if, hours or even a couple of days later, they get in touch with the completed project.

Participating in Daily Standups



Purpose of Daily Standups


You should leave a daily standup:

  1. More energized than you entered it.
  2. Aligned to be in contact after the daily with anyone if your or their main task needs discussion.
  3. Remembering everyone’s update.

Things outside of Daily Standups that can ruin Daily Standups

  1. If team communicates 1-to-1 a lot and not on shared channels.
  2. If people are tackling too many things at the same time.
  3. All basic management deficiencies.

How to prepare for a Daily Standup

Half an hour before the Daily Standup, stop for 5 minutes and:

  1. Decide what is the one initiative you will mention.
  2. Write it down in your own words.
  3. Edit that down to 280 characters.
  4. Include expected time to finish task at the end.
  5. Say it aloud.
  6. Improve the wording or delivery until you have a clear and memorable update.

How to decide what to mention in a Daily Standup

By decreasing order:

  1. Task you are doing that is most problematic.
  2. Task you are doing that you know someone can help you with.
  3. Task that is going well.

How to listen well in Daily Standups

  1. Keep a log of Daily Standups and make notes of every update.
  2. Come back to that log half an hour after the daily and read it again.

Trusting the Scrum Master in Daily Standups

If each team member delivers their update clearly, nicely and concisely, the Scrum Master will have time to:

  1. Ask about important items that were not selected by the team.
  2. Raise questions.
  3. Ask about extraordinary additions to people’s update.
  4. Align people for pairing on issues raised.
  5. Use the extra time for having a bit of fun and enjoying the team before it gets back to work.

My Year in: Software Development

The year of 2018 has been a wild ride for me. It started at EmCasa.com, the startup I described a year ago. We were in the process of putting out a successful MVP, engaging clients, becoming accelerated by Harvard University and closing out an excellent seed round with important investors. All this in just a few months.

Very quickly my job morphed from do-it-all (think product and CTO duties, plus co-founder responsibilities) to team-building. This was a highlight as I was lucky to bring in great people like Gabriela Seabra, Nathan Queija and Rodrigo Nonose, each respectively owning mobile, web frontend and backend. On the design side, Plau.co did great work.

For the first time I felt fully ready to create a digital company in style. The Elixir-React stack worked beautifully, we rolled out features fast and the development team became a cohesive unit very quickly.

Towards the middle of the year, as the company reached 14 people, it had become clear to me that there wasn’t a good cultural fit among the founders. It was one of those very painful decisions but ultimately not difficult to make when visions don’t intersect well enough: we parted ways amicably at the end of July and I went looking for a new job.

That month was tense for me. I knew I had a deadline to basically stop getting paid, my wife was 6 months pregnant with twins and I had nothing lined up as far as work.

I am part of Toptal’s network of freelancers and that was one of the main ways I tried to find the next thing. I found something that really interested me: they had posted an opening to join their Core Team. I applied, passed, and joined the team as a freelancer in August. 

The first few weeks were hard in a sense: I and two other developers coming from Toptal’s talent network had a kind of secondary status, without access to many tools. Luckily our teammates were extremely helpful and welcoming. In a few weeks we became official team members and got access to what the other engineers see.

My team works on Toptal’s public pages, from home to skill pages, basically everything a logged out user can access in the website. 

It’s been a tremendous experience for me so far, as it’s the largest organization I’ve been a part of in technology. Toptal is in fact the largest fully distributed company in the world today. As such, I work with people from all over the world, and that’s the part I like best. To do it from home is the cherry on the cake as my children are very young and being close to the family is priceless at this moment.

At my team I’ve experienced the most well-developed set of processes I’ve ever come across. The firm has reached a level of maturity that allows for very well written task tickets, a proper retrospective at the end of each sprint, interesting strategic discussions among executives, and work that has large-scale, immediate impact. On the other hand, I am very far from top strategic decisions and information, and this feels weird to me having run my own company for so many years.

To a very large extent, this was the year when, for me, technical concerns became secondary to human concerns. Sure, if you’re starting a product alongside just one other person, what tech stack exactly to choose is of paramount importance. In a team of 200 that’s much less important, as each person can focus on a narrower part of the work, and the human interactions can catalyze or hinder progress.

Thus, I gave myself the chance of observing all the teams in the organization: dialogs, processes and rituals. Whatever was visible to me, I tried to learn from. It wasn’t long before I got the opportunity to onboard newcomers, help interview candidates, conduct daily standups and interface with other companies. That’s not to say I didn’t study programming this year: I continued my deep-dive into the Elixir codebase, studied GraphQL, some more Elm, algorithms, some Python and a little bit of Natural Language Processing.

It’s much easier to paste some code or links to a framework and illustrate what goes on as a programmer. Human interactions seem to me much harder to communicate. A book that does a great job of explaining management applied to software is The Manager’s Path, by Camille Fournier. I read it this year and it very neatly sums up many things we learn the hard way, plus many others I simply did not know.

So this year was one in which I started out as CTO and ended-up as an individual contributor. But each experience has taught me a lot about management and leadership, which will be my way forward in technology.

 

Naive Investor, Episode 400

Today Naive Investor has hit episode 400.

If anything, a good excuse to post about it here.

Initially I went for posting every single episode in this blog, but pretty quickly the blog would become just a mirror of the YouTube channel.

A lot of learning has indeed taken place. That was the main goal. Along the way, people have sent me corrections, suggestions and encouraging messages.

At year end I will publish the update to the little (but growing) investing partnership I’ve been running rather informally for now, and which incorporates the knowledge gathered from the Naive Investor videos.

If you don’t yet subscribe to the channel, please consider doing so: https://www.youtube.com/c/NaiveInvestor

And here’s the 400th episode:

On Learning How to Learn

These past few weeks I took Coursera’s Learning How to Learn, thanks to Toptal’s advancement program.

My main takeaways from this course were the Memory Palace technique and the Hard Start-Jump to Easy technique.

The course is about much more than just those two tips, but I should admit that to a large extent I already knew and practiced them: chunking, diffuse and focused modes of studying, using visual analogies for memorization, the importance of sleep in learning, how apparently unrelated interests help propel deep learning, motivation-procrastination-blocks, focus on process rather than final product. If anything, it was nice to get something of a more scientific basis for things that we learn in life by trial-and-error or by imitation.

The Memory Palace Technique is useful for when we need to memorize unrelated items, for example a shopping list. It’s a seemingly bizarre strategy: you mentally place each item in, say, rooms in your home. Cheese goes on top of the fridge, detergent goes inside the oven, toilet paper on your bed, and somehow, they say, your visual brain helps you recall the items much better.

I was not aware of this technique, and so far I used it for small lists of things, and they seemed to work. We’ll see for challenging, longer lists. And also it remains to be seen in what situations this is better than just writing it down.

The Hard Start-Jump to Easy technique is a test-taking approach I was also unaware of. My best strategy when taking exams and tests was to find the easiest questions and tackle those first, leaving the hard ones for later. The course offers another idea: you start by taking a hard question. Once you feel you got stuck in it and can’t progress, you leave it unfinished and then move to the easy questions. The rationale is this warms up your brain, or sets it in focus, so you gain some performance. 

I seldom take tests these days but I can suppose this is applicable to our own day: start by tackling a hard task, use it to jumpstart our focus, and then move on to easy tasks. Maybe some fine-tuning on this idea can improve performance. I do know that I start my day, whenever possible, by studying, usually things with very long-term goals.

I wish the course went in deeper with practical examples instead of overvarnishing each concept. Still it was enjoyable and it seems likely that it’s going to add to my repertoire for learning.