Skip to content

Instantly share code, notes, and snippets.

View yangshun's full-sized avatar
😎
Ruining websites since 2013

Yangshun Tay yangshun

😎
Ruining websites since 2013
View GitHub Profile

Keybase proof

I hereby claim:

  • I am yangshun on github.
  • I am yangshun (https://keybase.io/yangshun) on keybase.
  • I have a public key ASALzkiMtwtQ1tT2loY5YKoN54yysqWWF7TLUB8ai024BAo

To claim this, I am signing this object:

'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
yangshun / docusaurus-copy-button.md
Last active April 4, 2023 07:07
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() {
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) {
identifiers.add(identifierName);
// Attach to global object to be exposed for exporting later.
path.insertAfter(
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()}](https://leetcode.com${$link.attr('href')})\n`;
});
console.log(res);
@yangshun
yangshun / mp4-to-mp3.sh
Last active September 18, 2017 02:21
Converts mp4 to mp3 format.
# Place the ffmpeg binary in the same directory.
for video_file in *.mp4
do
audio_file="${video_file/.mp4/.mp3}"
if [ -f "$audio_file" ]; then
echo "$audio_file exists."
else
echo "Converting $video_file to $audio_file."
./ffmpeg -i "$video_file" -vn -sn -c:a mp3 -ab 192k "$audio_file"
fi
@yangshun
yangshun / job-hunting.md
Last active February 21, 2024 11:45
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.

  • interviewing.io - Allows you to have mock interviews with engineers from the bay area. I personally like this platform a lot and used it as an interviewee.
  • 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.