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
/* Declare shortcuts and types */ | |
const fieldMap = { | |
a: { | |
name: 'address', | |
type: String | |
}, | |
s: { | |
name: 'approved', | |
type: Boolean, | |
relation: { |
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
@font-face { | |
font-family: 'Karmilla'; | |
src: local('Karmilla'), url('./fonts/karmilla-bold-016-webfont.woff2') format('woff2'); | |
font-weight: 700; | |
font-style: normal; | |
} | |
@font-face { | |
font-family: 'Karmilla'; | |
src: local('Karmilla'), url('./fonts/karmilla-regular-016-webfont.woff2') format('woff2'); |
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 getSumOfTaxPerPerson = ({ rate, peopleCount, primary, secondary}) => ((primary / (primary + secondary)) * 300 * peopleCount * rate) | |
const getDeductableNotFika = ({ | |
peopleCount, | |
tax12, | |
tax25, | |
}) => { | |
const tax12_exVat = tax12 / 1.12; | |
const tax25_exVat = tax25 / 1.25; |
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
function useLocalStorage() { | |
const get = key => localStorage.getItem(key); | |
const set = (key, value) = localStorage.setItem(key, value); | |
return [get, set]; | |
} | |
const Example = () => { | |
const [getLocalStorage, setLocalStorage] = useLocalStorage(); |
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
/* | |
Guven an island with the shape of this: | |
__ | |
__|__| __ | |
__ |__|__| __ __|__| | |
|__| __|__|__|__|__| |__|__|__ | |
|__|__|__|__|__|__|__|__ __ |__|__|__|__ | |
__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__| | |
[0, 3, 1, 2, 4, 5, 2, 3, 1, 0, 1, 0, 3, 4, 2, 1] => 18 |
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, { useCallback, useEffect, useRef, useState } from 'react' | |
// Types to be shared with frontend and backend | |
interface ApiResponseInfo { | |
code: number | |
message: string | |
[key: string]: unknown | |
} | |
interface ApiResponseCommon { |
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 matrix_multiplication(a, b): | |
if len(b) == 0 or len(a) == 0: | |
return [] | |
c = [] | |
for i in range(len(a)): | |
c.append([]) | |
for j in range(len(b[0])): | |
c[-1].append(0.0) |
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 { act, renderHook } from "@testing-library/react-hooks"; | |
import { useArray } from "./useArray"; | |
describe("useArray", () => { | |
describe("props", () => { | |
it("should have initial state", () => { | |
const { result } = renderHook(() => | |
useArray({ | |
initialState: ["a", "b", "c"], |
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
class InternalError extends Error {} | |
type Predicate<T> = (item: T) => boolean; | |
function single<T>(array: T[], predicate?: Predicate<T>) { | |
const items = predicate ? array.filter(predicate) : array; | |
if (items.length !== 1) { | |
throw new InternalError("Array does not contain exactly one item"); | |
} |
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
export enum TextInputTypes { | |
Raw, | |
Parameter, | |
} | |
export type Primitive = string | number | boolean; | |
export interface TextInputObject<Type extends TextInputTypes> { | |
type: Type; | |
value: Primitive; |
OlderNewer