-- :: -- :: # #- #- # # # #- #-
-- :: -- :: # # # #
-- :: -- :: # # # # # # # #. \ ://./-/----/ '
-- :: -- :: # #- # #- ,
-- :: -- :: # # # # # # # #
-- :: -- :: # # #- #/ # # #/ #-
-- :: -- :: # # # # # # # #
-- :: -- :: # # #/ # # #/
-- :: -- :: # # #- # # # # # # #-
-- :: -- :: #- #- # #- # #-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# impl/test of https://www.youtube.com/watch?v=PoSB9HK4kxg&ab_channel=MichaelPenn | |
# m = \sum_{n=0}^{m-1} \sum_{k=0}^{n+1} \frac{(-1)^{k+1}}{n+1} \binom{n+1}{k} (k+1)^m | |
# this is from m=lim_{x->1} mx^{m-1} with the equivalent definition of | |
# derivative: f'(x)=ln(1+\Delta x)f(x) | |
from math import comb | |
from fractions import Fraction | |
from typing import Generator, Protocol | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(a,b): | |
pass | |
def edit_d(a): | |
pass | |
l = 0 | |
d= {} | |
# before refactor | |
while d: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This example is to show that | |
* array.push will not trigger "set" method of proxy | |
* because array is mutable. | |
*/ | |
interface MyObj { | |
arr: number[]; | |
} | |
const myObj: MyObj = { arr: [] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/microsoft/TypeScript/issues/47295 | |
// https://stackoverflow.com/questions/70569105/proxy-property-in-setter-has-never-type | |
// https://www.typescriptlang.org/play?ts=4.6.0-dev.20220103#code/MYewdgzgLgBAtgTwPICMBWMC8MDeBYAKBhjAFc4AuGAWgEYAaQ4gQwCdWqBtBmAJnpgBmALqMiMaBxgByaWIC+AbkKFQkWAAdWIAB4IsJAKYB3GAAVtegBSJUaAfnERDUK1DYBzFwK0gNVAGtDBBAAMxgoBA1DMPhkdAEAN2YAG1JDAEpcJmIYAHoAKhJwQxhYqAALQ2cYYxBWAIgYAryc4jy8mAA1Q1YAOhhaNpgAS3CrXw1RsAjPFyz3Vi8oTknhA2S0w2Vxds6e-r5hxeXV7Q117E30ndz8-d6BwWO5lcmYZiagkPDI6NjbOhLjBrtthh1uo8YAAWYYQYwjKDACowCbnLKOO7EYCfUrSMhwaQUYbY3EySREkm5E4uM5+YGg25Y4goViGZgBJnEeQqXb5IrGCojFKlSrVUp1BpNFrgh6HACscIRSJRaL8GKpOJq+PIlL5dxpb3ODNSNypLLZHK5uS1eIpxP11NedIuG1NYMdFvZnOGPL5EIOAwAbErEcjUZMNY7bTICXrmcRDS6TVtrXdWd60zAACaGULMUgpKAOhOzJa0tZu1PmmAZq2+3l3NlQUisGZQVhm8TyBQZHaqcAQEAivopEAeKzSXx6GBUOQwacIPuEIA | |
const myObj = { | |
num: -1, | |
arr: [1, 2, 3], | |
str: '', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage for React class component. | |
// Can also it for state or non-react JS. | |
componentDidUpdate(prevProps) { | |
logUpdatedDiff(prevProps, this.props) | |
} | |
/** | |
* @param {object} prev: previous to compare | |
* @param {object} current: current to compare | |
* @return {void} |