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
@gaearon
gaearon / slim-redux.js
Last active December 3, 2024 06:34
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@yangshun
yangshun / .eslintrc
Created October 22, 2015 03:44
An eslint configuration that I adhere to
{
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"arrowFunctions": true,
"blockBindings": true,
"generators": true
},
"rules": {
"accessor-pairs": 0,
@vasanthk
vasanthk / System Design.md
Last active May 17, 2025 07:44
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@cuibonobo
cuibonobo / template_engine.js
Created May 10, 2016 21:40
A very simple template engine for Javascript.
/*
A very (*very*) simple templating function taken from
http://krasimirtsonev.com/blog/article/Javascript-template-engine-in-just-20-line
The full function includes support for if statements, for loops and other
control structures, but I stripped those out to keep it as simple and fast as
possible.
You use it like this:
@yangshun
yangshun / deep-dive-into-nusmods.md
Last active November 20, 2018 21:28
An explanation of how the timetabling algorithm of NUSMods works

Deep Dive into NUSMods

Ever wondered how the timetabling algorithm of NUSMods works? Read on to find out.

Firstly start let's define the data representation of a Lesson:

Lesson = {
  ClassNo: string,
 DayText: string,
@yangshun
yangshun / emoticon-emoji.json
Created January 17, 2017 07:07
Mapping of common emoticons to their respective emojis
{
":)": "๐Ÿ™‚",
":-)": "๐Ÿ™‚",
"(:": "๐Ÿ™‚",
":D": "๐Ÿ˜„",
":-D": "๐Ÿ˜„",
"=D": "๐Ÿ˜ƒ",
"=-D": "๐Ÿ˜ƒ",
":')": "๐Ÿ˜‚",
":'-)": "๐Ÿ˜‚",
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 15, 2025 22:49
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@addyosmani
addyosmani / preprocessing.md
Last active January 31, 2025 18:33
JavaScript preprocessing/precompilation

Problem: How can we preprocess JavaScript (at build-time or on the server-side) so engines like V8 don't have to spend as much time in Parse? This is a topic that involves generating either bytecode or a bytecode-like-abstraction that an engine would need to accept. For folks that don't know, modern web apps typically spend a lot longer in Parsing & Compiling JS than you may think.

  • Yoav: This can particularly be an issue on mobile. Same files getting parsed all the time for users. Theoretically if we moved the parsing work to the server-side, we would have to worry about it less.
  • One angle to this problem is we all ship too much JavaScript. That's one perspective. We could also look at preprocessing.
  • We've been talking about this topic over the last few weeks a bit with V8. There were three main options proposed.
    1. Similar to what optimize-js does. Identify IIFEs and mark them as such so the browser and VMs heuristics will catch them and do a better job than today. optimize-js only tackles IIFE bu
@jevakallio
jevakallio / reactiveconf-slam-poetry.md
Last active July 7, 2021 19:57
#ReactiveConf 2017 Lightning Talk Submission: JavaScript Slam Poetry

TL;DR: If you want to see me perform a spoken word poem about JavaScript in front of 1000 people (and on video), please โญ star this gist. If you're on mobile, you'll need to request desktop site.

JavaScript Slam Poetry

Javascript! Slam! Poetry!

@addyosmani
addyosmani / scratchpad.md
Last active October 25, 2017 15:34
Webpack Performance Presets

"We need Webpack presets" and "Webpack and its plugins are too hard to configure correctly" have been the number one cause of developer pain shared with me from large sites adopting Progressive Web Apps and optimising their load performance.

If I was building a Webpack preset pack for performance, I might use the following:

  • Ensure you're using a production build of your framework: new webpack.DefinePlugin({ 'process.env': env })
  • Minify your JS: webpack.optimize.UglifyJsPlugin
  • Compress your resources (GZip): compression-webpack-plugin
  • Split your vendor chunks: CommonsChunkPlugin