Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <subdirectory>"
exit 1
fi
SUBDIR="$1"
GIT_ROOT=$(git rev-parse --show-toplevel)
@andrew8088
andrew8088 / mapPromises.js
Created February 15, 2024 14:56
Managing Promise Concurrency in JavaScript
function mapPromises(args, callback, concurrency = 3) {
const { promise, resolve } = Promise.withResolvers();
const results = [];
let cursor = 0;
function next() {
if (cursor < args.length) {
const index = cursor++;
void callback(...args[index]).then(value => {
@andrew8088
andrew8088 / learn-typescript.ts
Created June 3, 2023 22:50
how i learn typescript
type Tables = {
person: {
id: number;
first_name: string;
},
product: {
id: string;
name: string;
createdAt: Date
}
@andrew8088
andrew8088 / fizzbuzz.css
Last active July 5, 2022 13:59
FizzBuzz in CSS! Meant to style a bunch of sibling <div>s.
div {
counter-increment: fizzbuzz;
}
div::before {
content: counter(fizzbuzz);
}
div:nth-of-type(3n)::before {
content: 'fizz';
@andrew8088
andrew8088 / api.test.ts
Created June 6, 2022 00:56
Building your own custom jest matchers
import * as api from './api';
const TOKEN_REGEX = /^app-0.\d+$/;
expect.extend({
toBeValidSession(session: api.Session, userId: string, expectedTTL: number) {
const messages: string[] = [];
const validToken = TOKEN_REGEX.test(session.token);
@andrew8088
andrew8088 / Progress.test.tsx
Created May 21, 2022 14:16
Testing Promise Race Conditions with fast-check
import { cleanup, render, screen, fireEvent, act } from '@testing-library/react';
import Progress from './Progress';
import * as fc from 'fast-check';
test('renders learn react link', async () => {
await fc.assert(
fc.asyncProperty(fc.scheduler(), async (s) => {
let number = 0;
const mockGetProgress = s.scheduleFunction(async () => number += 10);
@andrew8088
andrew8088 / number-map.js
Created October 14, 2021 21:53
Romain Numeral Addition
const map = {
1: "I",
2: "II",
3: "III",
4: "IV",
5: "V",
6: "VI",
7: "VII",
8: "VIII",
9: "IX",
@andrew8088
andrew8088 / systems-design-assignment.md
Last active May 4, 2021 19:54
Systems Design Assignment

Summary

The university has decided to invest in a revamp of their library’s digital service, moving it from a legacy system that’s hosted on premise, to a modern, cloud-native system that’s built atop a Platform as a Service like AWS.

Create a searchable system for storing the library’s catalogue, that library members can use to find and check out books.

Requirements

Must Have

  • Store the library’s catalogue of books
@andrew8088
andrew8088 / full-stack-assignment.md
Last active April 22, 2021 13:22
Full Stack Assignment

Task

Create a simple web application to fetch and display weather information.

Requirements

Below are the requirements for this mini-project. Beyond these requirements, you can do whatever you'd like! Please push your final application to GitHub, and include a README.md that gives instructions on how to run it.

You can spend as much or as little time as you'd like on this project. Feel free to put more time/effort into the parts that will show off your skills the best!

@andrew8088
andrew8088 / isProperlyNested.js
Last active April 20, 2021 15:47
isProperlyNested interview question
function isProperlyNested(input) {
}
test("{}", true);
test("(()", false);
test("()[]", true);
test("(([{]))", false);
test("[(())]{}()", true);
test("[(()){}()", false);