Skip to content

Instantly share code, notes, and snippets.

View waynevanson's full-sized avatar
🥥

Wayne Van Son waynevanson

🥥
View GitHub Profile
import { lighten } from "polished";
import { css } from "styled-components";
export const lightenOnUserInteraction = css<{ color: string }>`
background-color: ${(props) => props.color};
:hover,
:focus {
background-color: ${(props) => lighten(0.13, props.color)};
}
// defined in fp-ts
export interface Functor<F> {
map: <A,B>(f: (a:A) => B) => (fa: HKT<F,A>) => HKT<F,B>
}
// How it looks in an array
export interface FunctorArray extends Functor<"Array"> {
map: <A,B>(f: (a:A) => B) => (fa: Array<A>) => Array<B>
}
@waynevanson
waynevanson / void-rpi4.sh
Last active April 6, 2022 03:05
Builds void-linux for use with rpi4
#!/bin/bash
# DO NOT RUN AS SUDO
# AS XBPS-SRC WILL THROW AN ERROR
DIR="$HOME/void-rpi4"
[ -d "$DIR" ] || mkdir "$DIR"
DIR_PACKAGES="$DIR/void-packages"
[ -d "$DIR_PACKAGES" ] || git clone https://github.com/void-linux/void-packages.git "$DIR_PACKAGES"
/*
FREE TO USE! COPY AND PASTE INTO YOUR PROJECT. TELL YOUR FRIENDS ABOUT MAPPABLE TYPES!
How to use:
install dependencies (tree shakable):
`yarn add fp-ts ts-toolbelt normalizr`
Your schema definitions should look like this:
```sh
DEBUG: +0ms version: 0.6.2
DEBUG: +1ms config used:
{
help: false,
include: [ 'src' ],
version: false,
write: false,
avoidSingleFile: false,
debug: 'dbg.txt'
@waynevanson
waynevanson / match-ts.ts
Created April 12, 2020 10:29
A port of switch-case statements for fp-ts.
/**
* A port of switch-case statements for fp-ts.
*
* This could be broken down further and perhaps extended into a new type-class.
* It does the specific job I needed it to.
*
* If you have an abstraction that might help, i'd love to hear about it!
*/
import { array, either, option } from "fp-ts";

fp-ts

In these examples we'll be using letters to represent any number of variables of any type: a, b ,c, etc.

Functional programming is nice becuase it doesn't discriminate primitives and objects.

The point of all these type containers mentioned below is to provide safer and consitently typed code. Prerequisite is that you know what piping means and does.

null or undefined values

@waynevanson
waynevanson / paper-theme.tsx
Created August 17, 2019 04:29
Paper theme for tsx
// content.tsx
import React, { FC } from 'react'
import { createStyles } from '@material-ui/styles'
import { Paper, AppBar, Toolbar, Grid, TextField, Button, Tooltip, IconButton, Typography, Theme, withStyles } from '@material-ui/core'
import { Search, Refresh } from '@material-ui/icons'
const styles = (theme: Theme) =>
createStyles({
paper: {
wayne@laptop:~/Documents/digital-audio-workstation$ yarn add webaudio-raub
yarn add v1.17.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > easy-peasy@2.6.6" has unmet peer dependency "prop-types@^15.6.2".
warning " > extract-text-webpack-plugin@3.0.2" has incorrect peer dependency "webpack@^3.1.0".
[4/4] Building fresh packages...