Skip to content

Instantly share code, notes, and snippets.

@lamchau
lamchau / onemedical.js
Created May 7, 2019 22:05
OneMedical Phone Screen (Refactoring Exercise)
const Mocha = require('mocha');
const expect = require('chai').expect;
const mocha = new Mocha();
/**
Welcome to the One Medical Lab! We have a number of items in stock to make sure
we can keep our patients happy and healthy.
In our lab, our items degrade in quality as they approach their expiration
date. In order to keep track of this, we have a service that updates our

Keybase proof

I hereby claim:

  • I am lamchau on github.
  • I am lamchau (https://keybase.io/lamchau) on keybase.
  • I have a public key ASBoE71vaOJxbOm7RBqhXpHGK3SGQG-EaLeJbenoei77Owo

To claim this, I am signing this object:

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@lamchau
lamchau / FindAlertRanges.java
Created July 14, 2018 07:19
samsara on-site
package com.samsara;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
public class FindAlertRanges {
@lamchau
lamchau / tserv
Created July 7, 2018 07:31 — forked from jiffyclub/tserv
Start a Tornado static file server in a given directory. To start the server in the current directory: `tserv .`. Then go to `http://localhost:8000` to browse the directory.
#!/usr/bin/env python
"""
Starts a Tornado static file server in a given directory.
To start the server in the current directory:
tserv .
Then go to http://localhost:8000 to browse the directory.
Use the --prefix option to add a prefix to the served URL,
const WORDS_MAP = Object.freeze({
0: 'zero',
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
@lamchau
lamchau / _prompt.js
Last active June 18, 2018 04:58
code.org phone screen
/*
Justify a string
Given an input string of words and spaces, and a desired line length n which is greater than or equal
to the length of the input string, output a string that differs only in whitespace from the original
string which meets the following requirements:
- the new string has length n
- no spaces before the first word
- no spaces after the last word
- the number of spaces between a pair of consecutive words differs by no more than 1 from the
class Solution {
public static List<List<Integer>> prettyPrint(int A) {
List<List<Integer>> list = new ArrayList<>();
// rows/columns (nxn)
final int columns = A + (A - 1);
final int midpoint = columns / 2;
// track current layer
int layer = 1;
@lamchau
lamchau / The Technical Interview Cheat Sheet.md
Last active April 7, 2018 07:22 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

Array

Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
const bowser = require('bowser');
const FULL_SEMVER = /^(\d+)\.(\d+)\.(\d+)[\+|\-]?(.*)?$/;
const MAJOR_MINOR_VERSION = /^(\d+)\.(\d+)[\+|\-]?(.*)?$/;
const ANY_DIGIT = /^(\d+)$/;
function parseVersion(str) {
const [, major, minor, patch, metadata] =
FULL_SEMVER.exec(str) ||
MAJOR_MINOR_VERSION.exec(str) ||