Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
bradtraversy / eslint_prettier_airbnb.md
Created July 19, 2019 17:54
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: May 20, 2019 at 06:28 PM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
import Maybe from 'crocks/Maybe'
import Star from 'crocks/Star'
import prop from 'crocks/Maybe/prop'
import propOr from 'crocks/helpers/propOr'
import resultToMaybe from 'crocks/Maybe/resultToMaybe'
import tryCatch from 'crocks/Result/tryCatch'
const MaybeStar =
Star(Maybe)
@killants
killants / findPaths.js
Last active November 10, 2022 04:34
Sharing knowledge
/**
* searches deep into an object recursively...
* @param {Object} obj object to be searched
* @param {any} searchValue the value/key to search for
* @param {Object} [options]
* @param {boolean} options.[searchKeys] whether to search object keys as well as values. Defaults to `true` if `serchValue` is a string, `false` otherwise.
* @param {number} options.[maxDepth=20] maximum recursion depth (to avoid "Maximum call stack size exceeded")
* @returns {string[]} Paths on the object to the matching results
*/
const findPaths = (
@ryyppy
ryyppy / Button.re
Last active January 18, 2019 16:01
Button Variant with Reason
open Util;
module Secondary = {
let component = ReasonReact.statelessComponent(__MODULE__);
type active = {
href: string,
target: string,
};
type kind =
@francisrstokes
francisrstokes / FullParser.js
Created December 26, 2018 12:37
Arcsecond Article
const {
between,
many,
choice,
sequenceOf,
char,
whitespace,
anythingExcept,
possibly,
regex,
@busypeoples
busypeoples / ExplicitStatesInReact.md
Last active June 22, 2019 18:02
Making unrepresentable UI representations unrepresentable!

Making Unrepresentable UI Representations Unrepresentable!

When building components, we mostly start out with a minimal API, as we mostly have a clear initial idea of what the Component should do. But as requirements start to change, our API might start to evolve a long the way too. We start adding more props to cover conditional or special cases etc. Sometimes we use optional props, as in not required, or we might start using flags, as in boolean props or enums, to handle variants. Let's take a closer look at optional props and what effects these can have on our UI representation.

Optional props

@jserrao
jserrao / gatsby-node.js
Last active November 25, 2018 03:17
gatsby-node.js with DOM Parsing
// Give Node access to path
const path = require('path')
const fs = require('fs')
// Setup parser for taking apart the HTML Description hack stuff from Shopify
const DomParser = require('dom-parser')
const shopifyDescParser = new DomParser()
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
@masaeedu
masaeedu / recursion_schemes.js
Last active April 3, 2019 01:53
Recursion schemes for JS
// Consider a type consisting of either no values or two values (of distinct types)
// :: type TwoOrNone a b =
// :: { label: 'nil', values: () }
// :: | { label: 'cons', values: (a, b) }
// For convenience, we can write some constructors for values of this type,
// and a "destructor" to help us tell the different cases apart
// :: TwoOrNone a b
/**
* This method sequences an array of Monads, chaining each one into the next.
* The result will be one Monad of a list of each unwrapped value.
*/
function sequenceM(Type) {
return ms => {
function doIt(mArr, restMs) {
if(restMs.length === 0) {
return mArr;
} else {