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
@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.
@yangshun
yangshun / python-sort-stability.py
Last active July 11, 2023 22:33
Sort then reverse vs Sort(reverse=True)
# We want to sort a list by its second element in descending order.
# The example illustrates the difference in the results of different
# process of sorting in descending order.
# Sort in ascending order, then use list reverse
>>> a = [('A', 1), ('C', 5), ('A', 2), ('B', 3), ('B', 5)]
>>> a.sort(key=lambda x: x[1])
>>> print(a)
[('A', 1), ('A', 2), ('B', 3), ('C', 5), ('B', 5)]
>>> a.reverse()
@yangshun
yangshun / youtube-vimeo-url-parser.js
Last active June 14, 2023 22:27
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551
@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() {
@yangshun
yangshun / using-eslint-with-prettier.md
Last active March 22, 2023 13:50
Comparison between tools that allow you to use ESLint and Prettier together.
prettier-eslint eslint-plugin-prettier eslint-config-prettier
What it is A JavaScript module exporting a single function. An ESLint plugin. An ESLint configuration.
What it does Runs the code (string) through prettier then eslint --fix. The output is also a string. Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb.
How to use it Either calling the function in your code or via [prettier-eslint-cli](https://github.co
@yangshun
yangshun / emoticon-emoji.json
Created January 17, 2017 07:07
Mapping of common emoticons to their respective emojis
{
":)": "🙂",
":-)": "🙂",
"(:": "🙂",
":D": "😄",
":-D": "😄",
"=D": "😃",
"=-D": "😃",
":')": "😂",
":'-)": "😂",
@yangshun
yangshun / arrayToCSV.js
Last active January 18, 2021 15:22
Converts a 2D array into a CSV file
function arrayToCSV (twoDiArray) {
// Modified from: http://stackoverflow.com/questions/17836273/
// export-javascript-data-to-csv-file-without-server-interaction
var csvRows = [];
for (var i = 0; i < twoDiArray.length; ++i) {
for (var j = 0; j < twoDiArray[i].length; ++j) {
twoDiArray[i][j] = '\"' + twoDiArray[i][j] + '\"'; // Handle elements that contain commas
}
csvRows.push(twoDiArray[i].join(','));
}

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: