Skip to content

Instantly share code, notes, and snippets.

View third774's full-sized avatar

Kevin Kipp third774

View GitHub Profile
{
"cookoff" : {
"complete" : true,
"criteria" : [ {
"name" : "Taste"
}, {
"name" : "Aftertaste"
}, {
"name" : "Aroma"
}, {
@third774
third774 / app.module.ts
Created April 13, 2017 05:30
Implementing global Custom Errors in ng-bootstrap-form-validation
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {NgBootstrapFormValidationModule} from "ng-bootstrap-form-validation";
import {AppComponent} from "./app.component";
import {CUSTOM_ERRORS} from "./custom-errors";
@NgModule({
declarations: [
@third774
third774 / .bash_profile
Created August 27, 2017 14:07
Adding this to .bash_profile updates the tab title when the directory changes
# Adding this to .bash_profile updates the tab title when the directory changes
# can also manually name a tab eg: title FOOBAR
function title {
export TITLE_OVERRIDDEN=1
PROMPT_COMMAND=''
echo -ne "\033]0;"$*"\007"
}
case "$TERM" in
/*
// file should be in ${workspaceRoot}/loaders/
const path = require('path');
webpackConfig = {
resolveLoader: {
modules: [
'node_modules',
path.resolve(__dirname, 'loaders')
@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() {};
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], "")
}
import React, { useReducer, useContext } from "react";
const defaultState = {
todos: [],
addTodoInputText: ""
};
export const StoreContext = React.createContext([defaultState, () => {}]);
export function Store({ children }) {
module List
( MyList
, fromList
, toList
, myMap
, myFilter
, myFoldl
, myReverse
, (+++)
)
// 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
};
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