Skip to content

Instantly share code, notes, and snippets.

View adjohnston's full-sized avatar
🎓
Learning new things

Adam Johnston adjohnston

🎓
Learning new things
View GitHub Profile
@adjohnston
adjohnston / lift-n-fp-ts.js
Created December 1, 2020 17:09
LiftN using FP-TS + examples
import * as R from 'ramda'
import * as E from 'fp-ts/lib/Either'
import * as O from 'fp-ts/lib/Option'
import { pipe, flow } from 'fp-ts/function'
import { sequenceT } from 'fp-ts/lib/Apply'
R.product([1, 2, 3])
R.product([O.some(1), O.some(2), O.some(3)])
@adjohnston
adjohnston / machine.js
Last active April 19, 2020 13:16
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'floom',
strict: true,
initial: 'initialised',
context: {
timer: 2,
gameId: '',
playerCount: 0,
@adjohnston
adjohnston / r.lens.js
Last active January 10, 2020 21:30
Fun with Ramda lenses
const data = {
a: [{
type: 'a',
value: 0,
name: 'Adam',
}, {
type: 'b',
value: 1,
name: 'Dave',
}],
@adjohnston
adjohnston / combine-reducers
Created May 2, 2019 13:38
A combine reducers function for using with useReducer
export interface Action extends React.ReducerAction<any> {
type: string;
payload?: {};
}
export interface State {
[key: string]: {};
}
export const combineReducers = (
@adjohnston
adjohnston / compose.js
Last active February 6, 2018 13:49
functional learning - compose
// compose : array<func> -> value -> value
const compose = (...fns) => val => fns.reduce((fnA, fnB) => fnA(fnB(val)))
@adjohnston
adjohnston / pipe.js
Last active March 1, 2017 20:55
functional learning - pipe
// _pipe : funcs -> value -> value
const _pipe = (f, g) => (x) => g(f(x))
// pipe : funcs -> value -> func
export const pipe = (...fns) => (x) => fns.reduce(_pipe)
.container {
// styles
&--offset {
margin: 0 -1rem;
}
&__span {
// styles
@adjohnston
adjohnston / flexbox-container-demo.html
Last active March 12, 2016 10:04
A small flexbox container demo used for Medium
<div class="container">
<div class="container__span">
<label class="field">
<span class="field__label">Your Name</span>
<input type="text" class="field__input" placeholder="First name">
</label>
</div>
<div class="container__span">
<label class="field">
@adjohnston
adjohnston / _container.scss
Last active March 27, 2016 09:59
A small flexbox container implementation for fluid layout
.container {
display: flexbox;
flex-wrap: wrap;
padding: 0 .5rem;
// modifiers go here
&__span {
flex: 1 0 100%;
padding: .5rem;
@adjohnston
adjohnston / _modify.scss
Last active December 26, 2015 19:10
Nest Scss element classes within modifiers
@function _block-name($modifier-class) {
$modifier-class: #{$modifier-class}#{''};
@return str-slice($modifier-class, 1, (str-index($modifier-class, '--') - 1));
}
@mixin modify($element-class) {
#{_block-name(&) + $element-class} {
@content;
}