Skip to content

Instantly share code, notes, and snippets.

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

Kirill Novik kino6052

🏠
Working from home
View GitHub Profile
@kino6052
kino6052 / hash-collision-calculator.ts
Created November 17, 2023 06:34
Hash Collision Calculator
// NOTE: This utility is for illustration purposes
// Allows to calculate minimal hash length based on the number of files to consider
// MD5 uses 16 symbols
enum EConstant {
NumberOfSymbols = 16,
HashStringLength = 32, // MD5 hash length
DefaultProbabilityThreshold = 0.01,
BinarySearchFactor = 1.5,
}
Require Import Arith.
(* define the function that calculates t1 and t2 *)
Fixpoint calc_t1 (m: nat) (l: list nat) : nat :=
match l with
| [] => 1
| h :: t => h * calc_t1 m t
end * m - 1.
Fixpoint calc_t2 (m: nat) (l: list nat) : nat :=
const decorateWithNumber = <T>(p: T): T & { num: number } => ({ ...p, num: 10 });
const decorateWithBoolean = <T>(p: T): T & { bool: boolean } => ({ ...p, bool: true });
const decorateWithString = <T>(p: T): T & { str: string } => ({ ...p, str: 'string' });
const removeNumberDecoration = <T>({ num, ...rest }: T & { num?: number }): Omit<T, "num"> => ({ ...rest });
const functions = [decorateWithBoolean, decorateWithNumber, decorateWithString, removeNumberDecoration] as const;
function pipe<A, B>(f1: (a: A) => B): (a: A) => B;
function pipe<A, B, C>(f1: (a: A) => B, f2: (a: B) => C): (a: A) => C;
function pipe<A, B, C, D>(
@kino6052
kino6052 / frontendDevlopmentBookmarks.md
Created July 5, 2022 12:30 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
// Example of how types could be declared using TS interfaces
interface IEpisode {
title: string;
}
interface ICharacter {
name: string;
appearsIn: IEpisode[];
}
@kino6052
kino6052 / inf-primes.v
Created October 13, 2021 00:56 — forked from poizan42/inf-primes.v
Proof of the infinitude of primes
Require Import Coq.ZArith.ZArith.
Require Import Coq.ZArith.Znumtheory.
Require Import Coq.Sets.Ensembles.
Require Import Coq.Sets.Finite_sets.
Require Import Coq.PArith.BinPos.
Definition Z_ens := Ensemble Z.
Print Finite.
Print Empty_set.
Definition is_empty_set U A := forall x, ~(In U A x).
x = np.array([[1, 1],[1, 2],[1, 3]]) ## must contain first column with one for theta bias
y = np.array([[4.5], [5.5], [8.5]])
_x = np.dot(x.T, x)
xI = np.linalg.inv(_x)
n = np.dot(xI,x.T)
theta = np.dot(n, y)
print(theta)
print(theta[0], theta[0][0])
print(x[0], x[0][0])
y1_hat = theta[0][0] + theta[1][0]*x[0][1]
StateSubject.subscribe((state) => render(<App state={state} />, rootElement));
const filterProducts = (event: IEvent, state: IState) => {
const value = event[2] || "";
const filteredProducts = state.products
.filter(({ name }) => name.toLowerCase().includes(value.toLowerCase()))
.map(({ id }) => id);
return {
...state,
input: value,
productsToDisplay: filteredProducts
};
@kino6052
kino6052 / reduce.ts
Last active February 28, 2021 19:11
const reduce = (
event: IEvent,
state: typeof initialState
): typeof initialState => {
if (event[0] === "change" && event[1] === "input-01") {
const value = event[2];
const filteredProducts = state.products
.filter(({ name }) => name.toLowerCase().includes(value.toLowerCase()))
.map(({ id }) => id);
return {