Skip to content

Instantly share code, notes, and snippets.

View PabloLION's full-sized avatar
🏠
Working from home

Pablo LION PabloLION

🏠
Working from home
  • Barcelona, Spain
View GitHub Profile
# 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
@PabloLION
PabloLION / refactor-pattern.py
Created March 1, 2023 06:20
Refactor python double while True loop
def foo(a,b):
pass
def edit_d(a):
pass
l = 0
d= {}
# before refactor
while d:
@PabloLION
PabloLION / dendron-import-bug.md
Created October 29, 2022 23:56
Only to show how dendron import files in github issue

-- :: -- :: # #- #- # # # #- #- -- :: -- :: # # # # -- :: -- :: # # # # # # # #. \ ://./-/----/ '
-- :: -- :: # #- # #- ,
-- :: -- :: # # # # # # # # -- :: -- :: # # #- #/ # # #/ #- -- :: -- :: # # # # # # # # -- :: -- :: # # #/ # # #/ -- :: -- :: # # #- # # # # # # #- -- :: -- :: #- #- # #- # #-

@PabloLION
PabloLION / array-push-with-proxy-set.ts
Created January 4, 2022 10:07
`array.push` will not trigger "set" method of proxy
/* 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: [] };
@PabloLION
PabloLION / TS-example-writing-produces-intersection.ts
Last active January 4, 2022 09:55
Writing produces type intersection in TS.
// 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: '',
};
@PabloLION
PabloLION / propdiff.js
Last active November 26, 2021 20:36 — forked from albertorestifo/propdiff.js
Logs change with git diff style between current and previous object
// 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}