Skip to content

Instantly share code, notes, and snippets.

View third774's full-sized avatar

Kevin Kipp third774

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<meta name="description" content="Stream"/>
<title>Stream</title>
<style>
html {
[
{
"Title": "Hobo with a Shotgun",
"Year": "2011",
"Rated": "Not Rated",
"Released": "12 May 2011",
"Runtime": "86 min",
"Genre": "Action, Comedy, Horror, Thriller",
"Director": "Jason Eisener",
"Writer": "John Davies",
@third774
third774 / .block
Created June 30, 2019 19:27
fresh block
license: mit
chk :: Eq b => (a -> b) -> a -> b -> Bool
-- All arguments are present on the left
-- chk fn a b = b == fn a
-- get rid of 'b' param on the left by partially applying (==) operator
-- chk fn a = (== fn a)
-- get rid of 'a' param on the left by composing (==) after fn
-- chk fn = (==) . fn
// The reducer function looks at each action that comes in
// and based on the type generates a new state based on the
// previous state and any additional data the action carried
const reducer = (state, action) => {
switch (action.type) {
case "COUNT_INCREMENT":
return {
...state,
count: state.count + 1
};
module List
( MyList
, fromList
, toList
, myMap
, myFilter
, myFoldl
, myReverse
, (+++)
)
import React, { useReducer, useContext } from "react";
const defaultState = {
todos: [],
addTodoInputText: ""
};
export const StoreContext = React.createContext([defaultState, () => {}]);
export function Store({ children }) {
const format = (strings, ...values) => {
if (values.every(v => typeof v !== "function")) {
return strings.reduce((acc, str, i) => values[i] === undefined ? acc + str : acc + str + values[i], "")
}
return obj => strings.reduce((acc, str, i) => values[i] === undefined ? acc + str :
typeof values[i] === "function" ? acc + str + values[i](obj) : acc + str + values[i], "")
}
@third774
third774 / generics.ts
Last active October 5, 2017 02:37
Typescript generic problems and fixes
class Animal {
name: string;
}
class Dog extends Animal {
bark() {};
}
class Cat extends Animal {
meow() {};
/*
// file should be in ${workspaceRoot}/loaders/
const path = require('path');
webpackConfig = {
resolveLoader: {
modules: [
'node_modules',
path.resolve(__dirname, 'loaders')