Skip to content

Instantly share code, notes, and snippets.

View lin's full-sized avatar

Albert Lin lin

View GitHub Profile
@lin
lin / tutorial.md
Last active February 19, 2021 04:19
Remove a submodule
@lin
lin / animation.js
Last active March 24, 2020 15:02
Basics of Animation
render () {
// how much progress is it?
// from 0 to 1
let progress = time / duration
// apply ease function to the progress
// lots of action is actually based on ease function
// the ease function works like affine transformation matrix
// it can make all kinds of simple transformation to the tween
let ratio = ease(progress)
// https://stackoverflow.com/questions/34371980/multiple-left-hand-assignment-with-javascript-really-right-associative
// assignment == situation 3
let arr = [0, 1]
let pointer = arr
pointer[2] = pointer = pointer[2] || []
console.log(pointer, arr);
// situation 1
let arr = [0, 1]

The first 128 chars are ASCII or Control Chars and Basic Latin, which is the most important part of the Unicode.

Among the first 128, the first 32 are control chars, notably:

10, 0x000A is New Line (NL) \n

13, 0x000D is Carriage Return (CR) \r

Among the first 128, the next 96 are basic latin, notably:

@lin
lin / 1-example.js
Last active June 1, 2019 07:53
What do I mean when I talk about class?
// why we introduce class.
// this is a simple way to encapulate repeated patterns
// which is larger than the functions
// but as we can see that a class is a function underneath
// class = object + a construction function
let Object = require('./Object')
function createUser ( name, age ) { // the name and age is what special about this object
// what actuallly is important is that
var Mixin = {}
Mixin.mix_into_prototype = function() {
for (var i = 0; i < arguments.length; i++) {
let current_object = arguments[i]
for (let key in current_object) {
this[key] = current_object[key]
}
}
return this;
@lin
lin / dot_object_call.js
Last active May 30, 2019 02:57
Understanding by implementing it in another way.
let user = { name: "John" };
let speak = function (price) {
console.log(this.name + ' offers ' + price)
}
function dot_object_call(obj, fun, args){
fun.call(obj, args)
// or:
// fun.bind(obj)(args)
}
@lin
lin / Elements.md
Last active May 29, 2019 02:47
Elements of Abstraction

Elements of Abstraction

1. Definition of Abstration

if (A.checker(a) == true)
  console.log(a.in(A)) // true
// A.checker(a) == true => a \in A
@lin
lin / parsers.md
Last active June 3, 2024 09:15
Simple examples to distinguish LR(0), SLR(1), LR(1), LALR(1), LR(k)
@lin
lin / this.md
Created November 12, 2018 08:45

1, when you define a function, it binds this to the object it might belongs to.

const obj = {
  method: function() {
    // this is obj
  }
};

//otherwise:
function(){