01 May 2021

Answering coding interview questions

History / Edit / PDF / EPUB / BIB / 1 min read (~123 words)
  • Read the problem statement
  • Look at any provided unit tests
  • Add any unit tests you think might be relevant and not currently covered
  • Order the unit tests from easiest to hardest
  • Ask questions to confirm your understanding of the problem and verify edge cases
  • Think of a possible approach to solve the problem
  • Share your approach with the interviewers and get their buy-in
    • You may do this by writing pseudo-code as you are explaining your thought process
  • Implement your solution
    • If you encounter any difficulties, state them and explain what you are thinking
    • Make use of preconditions/early exit if possible to handle empty cases
  • Run your code frequently, even if it is not fully working
  • Discuss any follow-up questions with the interviewers
21 Apr 2021

Managing your reading

History / Edit / PDF / EPUB / BIB / 3 min read (~529 words)

The process described below attempts to optimize reading quality books and enjoying the reading experience. As such, it promotes book exploration (discovery of new books) and reading books which have a high rating according to your own taste. Books which receive lower ratings (compared to other books) are moved down the reading priority list and will not be read until books that have higher priority (i.e., rating) either are finished reading or their rating decreases such that other books are now high priority.

  • Pick highly read books (use a site like goodreads to identify those books).
  • When reading a book, record the page you start and stop reading on, the time you start and stop reading and emit a rating for what you've read.
    • You can decide to optimize whether you want to optimize per page rating or per duration rating, that is, get the most value per page or by time spent reading.
  • Add new books to your reading list regularly. Those books are considered as having the highest priority and are then added to the prioritized list of books according to its rating.
  • When not reading a new book, read the books in order of priority and by interest at the time of reading.
  • From time to time you may look at your list of prioritized books and decide whether the books with the lowest priority should ever be finished. In some cases it is reasonable to decide that certain books will never be read completely.
  • As an alternative approach, one can use multi-armed bandits algorithms to decide which book to read next. Given that we can convert multi-armed bandits problem into the problem of selecting which book to read next given a sequence of readings and associated rating ("rewards"), the various algorithms (such as Epsilon-greedy or UCB1) will provide us with the next book we should read.
    • Interestingly enough, an algorithm like UCB1 will promote reading books we've never read first over reading books we've already started reading.

  1. Read partially any book for which you haven't given any rating
  2. Rate what you have read on a 1 to 5 scale, 1 being very bad and 5 being very good (see book rating)
  3. Compute the weighted rating of the book (the sum of rating times # of page associated to the reading divided by the total # of pages read so far for the book)
  4. Sort books by weighted rating (descending), then average estimated amount of time left to complete (ascending)
  5. If you have books that you haven't read yet, go back to the first step. If not, then pick the book at the top of the list computed in the previous step, then continue from step 2

  • It's better to read a good book than to finish a bad book

I make extensive use of Laravel Debugbar to track performance of parts of my application. I sprinkle calls to Debugbar::startMeasure and Debugbar::stopMeasure to track the duration of certain segments of my code. However, when this code goes into production, this dependency isn't present. This cause the code to break since it cannot find Debugbar anymore.

To solve this issue, I thought I would create a dummy Debugbar class and have it added as an alias, so that any code depending on Debugbar would still work, but end up as a "no operation". I found the article Dynamic class aliases in package which introduced the necessary piece of information to accomplish this.

<?php

use Illuminate\Foundation\AliasLoader;
use My\SuperPackage\FooBar;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
    public function register()
    {
        $this->app->booting(function() {
            $loader = AliasLoader::getInstance();
            $loader->alias('FooBar', FooBar::class);
        });
    }
}

In my desired use case, I simply implemented the following changes:

In app/Providers/DebugbarServiceProvider.php (a new file)

<?php

namespace App\Providers;

use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider;

class DebugbarServiceProvider extends ServiceProvider
{
    public function register()
    {
        if (!class_exists('Debugbar')) {
            $loader = AliasLoader::getInstance();
            $loader->alias('Debugbar', NullDebugbar::class);
        }
    }
}

class NullDebugbar
{
    public static function __callStatic(string $name, array $arguments)
    {
        // Do nothing
    }
}

In app/config/app.php

    // under the 'providers' key, add
    'providers' => [
        [...]
        // This will take care of loading the service provider defined above
        App\Providers\DebugbarServiceProvider::class,
    ],

With those two changes, it is now possible to make use of Debugbar in most places and have it work even without the Laravel Debugbar dependency installed.

07 Mar 2021

Closing tabs

History / Edit / PDF / EPUB / BIB / 1 min read (~84 words)
browser tabs

  • Want to read but
    • Too long -> Transfer to pocket
  • Want to watch but
    • Too long -> Add to a youtube watchlist (which I'll never watch)
  • I need them open to quickly enter data
  • I want to watch them again and again
    • Download with youtube-dl and watch using VLC
  • Would maybe read one day, but definitely not now (very low priority)
    • Transfer to pocket

  • If a tab is scanned more than 5/10 times, it goes into the backlog bin

The onboarding process described here is specific to a software engineer joining a tech company. While some/most of the items may still apply to any job where you mainly work from a computer, the assumption will be that you develop software as an individual contributor.

  • Setup laptop
  • Access to slack
  • Access to zoom
  • Setup calendar reminders
  • Initial meeting with buddy
  • Access to git central repository
  • Installation of development tools/languages
  • Request software licenses
  • Access to CI/CD
  • Find where task management is done
  • Find the documentation to build projects
  • Connect 1 on 1 with each member of the team
  • Meet with manager 1 on 1
  • Define a 30-60-90 days plan with manager
  • Verify access to various systems (SSO, code repository, insurance company, payroll company, etc.)
  • End of week meeting with buddy

  • Setup and run the one step build process
  • Determine how are features/tasks prioritized, who prioritizes features/tasks
  • Review the team documentation
  • Review team practices/processes documentation (code style, code review, standups, planning, retrospective, demos)
  • Review common vocabulary, terminology, glossary documents
  • First PR + code review
  • Review the career ladder of the position

  • Review user definition, use cases, requirements
  • Read prior team meetings notes

  • Identify how deployments are done
  • Review the team roadmap
  • Determine where I can have the biggest impact
  • Determine a timeline where I'll have reached my 80/20 at the company
  • Determine the maturity of existing projects
  • Determine how fast can we iterate on certain aspects given the team/company composition
  • Identify the core/principal/staff contributors and their contributions
  • Review the architecture of the system
  • Review the database architecture
  • Learn about "how we got to this point"
  • Determine whether the product is a monolith or micro-services
  • Identify which (3rd party) tools are used by the team/company
  • Determine the portfolio of STARS situations of the team/company
  • Determine a rough estimate of the number of people in the different organizations
  • Connect 1 on 1 with important collaborator in other teams
  • End of first month meeting with buddy
  • First month performance review with manager
  • Informal 360-degree review with manager and peers on adaptation
  • Month 1 job satisfaction review

  • Team interaction diagram
  • Month 2 job satisfaction review

  • Month 3 job satisfaction review