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
const isPristine = ( | |
fieldName: string | string[], | |
touched: FormikTouched<FormikValues> | |
) => | |
[fieldName] | |
.flatMap((fieldName) => fieldName) | |
.every((fieldName) => !touched[fieldName]); |
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
git branch | grep -v "master" | xargs git branch -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
const is = (it, n = Symbol()) => (it ?? n) !== n; | |
const is = it => (it ?? null) !== null; |
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
import React from "react"; | |
import { Subject } from "rxjs"; | |
export type EventType = "click" | "change" | "focus"; | |
export type Id = string; | |
export type IEvent = [EventType, Id, string | undefined]; | |
export const EventSubject = new Subject<IEvent>(); | |
export const EventWrapper: React.FC<{ id: string }> = (props) => { |
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
const initialState: IState = { | |
input: "", | |
isInStockOnly: false, | |
products: [ | |
{ | |
id: "0", | |
category: "Sporting Goods", | |
price: "$49.99", | |
stocked: true, | |
name: "Football" |
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
expect(reduce(['change', 'input-01', 'ball'], initialState)).toEqual({ | |
input: "ball", | |
isInStockOnly: false, | |
products: [ | |
{ | |
id: "0", | |
category: "Sporting Goods", | |
price: "$49.99", | |
stocked: true, | |
name: "Football", |
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
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 { |
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
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 | |
}; |
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
StateSubject.subscribe((state) => render(<App state={state} />, rootElement)); |
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
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] |