Skip to content

Instantly share code, notes, and snippets.

I'm nitpicky!

Yangshun Tay yangshun

I'm nitpicky!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am yangshun on github.
  • I am yangshun ( on keybase.
  • I have a public key ASALzkiMtwtQ1tT2loY5YKoN54yysqWWF7TLUB8ai024BAo

To claim this, I am signing this object:

View useInputValue.js
'use strict';
const {useCallback, useState} = require('React');
const nullthrows = require('nullthrows');
type InputValue<T> = {|
// Whether the input value has changed since it was initialized.
changed: boolean,
// A string key to uniquely identify the value.
yangshun /
Last active Feb 26, 2021
How to add the "Copy" button to code blocks in Docusaurus

Adding "Copy" (to Clipboard) Button

If you would like to add a button to your fenced code blocks so that users may copy the code, you can do so in Docusaurus. You will have to add some code to your Docusaurus project, as seen below.

Under static/js, create a file called code-block-buttons.js with the following:

// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
window.addEventListener('load', function() {
View babel-plugin-export-private.js
module.exports = (babel) => {
const { types: t } = babel;
const GLOBAL_EXPOSURE_IDENTIFIER = 'babelPluginExportPrivates';
const HOIST_PRAGMA = 'babel-plugin-export-privates';
const identifiers = new Set();
function attachToGlobalObject(path, identifierName) {
// Attach to global object to be exposed for exporting later.
View leetcode-questions-list.js
let res = '';
$('#question_list tbody tr').each(function () {
const $td = $(this).find('td');
const $link = $($td[2]).find('a').first();
res += `[${$($td[1]).text().trim()} - ${$link.text()}](${$link.attr('href')})\n`;
yangshun /
Last active Sep 18, 2017
Converts mp4 to mp3 format.
# Place the ffmpeg binary in the same directory.
for video_file in *.mp4
if [ -f "$audio_file" ]; then
echo "$audio_file exists."
echo "Converting $video_file to $audio_file."
./ffmpeg -i "$video_file" -vn -sn -c:a mp3 -ab 192k "$audio_file"
yangshun /
Last active Apr 11, 2021
Some resources for the job hunting season

Tech Job Hunting

Mock Interview Sites

Would advise you all to practice just for fun. I know a lot of students don't get much practice for interviews.

  • - Allows you to have mock interviews with engineers from the bay area (so they say, but I am an interviewer on the platform too). I personally like this platform a lot and used it both as an interviewee and an interviewer.
  • Pramp - Peer-to-peer mock interviews. You get matched with another person, get assigned questions and take turns to be interviewer/interviewee. I personally dislike this platform a lot because I had a horrible experience being matched with some guy who didn't know shit about regular expressions, gave me a wrong test case, and led me down the wrong path of solving the question.