Skip to content

Instantly share code, notes, and snippets.

@timhwang21
timhwang21 / renderDoctor.js
Last active February 8, 2019 23:33
Diagnose inefficient renders by identifying "changed" props that are actually equal
import React from "react";
import { isEqual } from "underscore";
/**
* HOC for diagnosing unnecessary renders and identifying faulty selectors
*
* Adds a logger function to a component that lists all changed props
* Also checks if changed props are deeply equal
*
* Usage: Decorate the component you are investigating with renderDoctor:
#!/usr/bin/env bash
brew install cabextract
cd ~/Downloads
mkdir consolas
cd consolas
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
cabextract PowerPointViewer.exe
cabextract ppviewer.cab
open CONSOLA*.TTF
@timhwang21
timhwang21 / conditional-fields.md
Last active July 7, 2022 16:25
Handling conditional field visibility in dynamic forms

Handling conditional field visibility in dynamic forms

This post explores several common ways of handling visibility of conditional fields. Our sample form will have the following schema:

  • foo: always present
  • bar: dependent on form state (value of foo)
  • baz: dependent on other application state (e.g. user permissions)

Below is our form, prior to implementing visibility logic:

@timhwang21
timhwang21 / making-tickets-actionable.md
Last active August 2, 2023 16:43
Making Tickets Actionable

Making Tickets Actionable

Tim Hwang


Roles in Product Development

  • PM identifies 🔎 user requirements
  • UX designs 🎨 them
@timhwang21
timhwang21 / formValidations.hs
Last active May 18, 2018 14:34
Function form validations written in Haskell
{-# LANGUAGE DuplicateRecordFields #-}
module FormValidations where
import Data.Either
import Data.Maybe
import Text.Read
main :: IO ()
main = return ()
@timhwang21
timhwang21 / pubkey.asc
Created October 10, 2018 20:25
PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFu+W6sBCADCDgvAvLN1AzGLL6Dl1b0QCDzt7nlzNt+0kIMQxAL/XEFzRYEY
36hBhnex37Z6ExzKtm74iRCbrucu04dLjjLBUQzCyRX5t8xu4NPS8SlSbvcg1J+X
K9ojwzkWzGkHTBVinFjWWwX3HZc7NVwqUzXdzmkMquF9aKSdbRA70tuuKzj6WgYb
fWnk2IS/fPC5onQuWHTO/84CN6I++xsIsSvZzyaN2gD6fR2cvD5pNiwtTHSAZOYx
o/BXznRyvpSm0iSq0nPDQCvxI6PG0tAATO72gBpOEOaM0Qdb+RWjmcT+stCpTPvc
zzkKFD9jzsjpztMnJXbBnhdCnGMlzC0S0erxABEBAAG0IFRpbSBId2FuZyA8dGlt
aHdhbmcyMUBnbWFpbC5jb20+iQFUBBMBCAA+FiEEJa/GnAohjShOas1PiFYcy+G4
fY4FAlu+W6sCGwMFCQPCZwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQiFYc
@timhwang21
timhwang21 / curry-record.md
Last active January 9, 2023 21:34
Curry unary functions that take a record as an argument

curryRecord

This is an example of a function whose logic lives in the type definition rather than in the function body.

/**
 * @name `curryRecord`
 *
 * Takes a unary function that takes a record as an argument, and makes the
 * record partially applicable. Returns a new function that takes a partial of
@timhwang21
timhwang21 / 1-1-template.md
Created January 9, 2020 22:21
1:1 template

DD/MM/YYYY

Questions to direct report

Tasks

What tasks have you accomplished in the first half of the week?

What tasks do you plan on working on in the second half of the week?

@timhwang21
timhwang21 / combinators.js
Created July 19, 2020 14:16 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@timhwang21
timhwang21 / missing_indexes.sql
Created July 23, 2020 04:05
Spotting missing indexes for MariaDB & MySQL
SELECT
t.TABLE_SCHEMA,
t.TABLE_NAME,
c.COLUMN_NAME,
IFNULL(
kcu.CONSTRAINT_NAME, 'Not indexed'
) AS `Index`
FROM
information_schema.TABLES t
INNER JOIN information_schema.`COLUMNS` c ON c.TABLE_SCHEMA = t.TABLE_SCHEMA