This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef, useState, Dispatch, SetStateAction } from "react"; | |
/* originally via: | |
https://gist.github.com/AlpacaGoesCrazy/25e3a15fcd4e57fb8ccd408d488554d7 | |
*/ | |
const useStateSafe = function<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>] { | |
const isMounted = useRef(false); // useRef to memorize if the component is mounted between renders | |
const [state, setState] = useState<T>(initialValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function<TValue>( | |
value: TValue | null | undefined | |
): value is TValue { | |
return value !== null && value !== undefined | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
interface IState { | |
isLoading: boolean | |
error?: Error | |
} | |
interface IErrorProps { | |
error: Error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useMemo } from 'react' | |
import { useInput } from 'react-hanger' // form binding hooks | |
import { usePromise } from 'react-hook-utils' // fetch/promise binding hooks | |
import { getJSON, postJSON } from './fetch-json' | |
const ExampleForm = ({ userId }) => { | |
// hooks! | |
const [user, errorLoadingUser, isLoadingUser] = usePromise(useMemo( | |
() => getJSON(`/api/users/${userId}`), | |
[userId] // memo-ize on userId; only re-fetch when the userId prop changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { useInput } from 'react-hanger' | |
const DEFAULT_NAME_VALUE = 'Troy' | |
const DEFAULT_EMAIL_VALUE = 'troygoode@gmail.com' | |
const ExampleForm = () => { | |
const name = useInput(DEFAULT_NAME_VALUE) | |
const email = useInput(DEFAULT_EMAIL_VALUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useMemo } from 'react' | |
import { usePromise } from 'react-hook-utils' | |
import useMessages from './use-messages' | |
import Loading fom './loading' | |
import Oops fom './oops' | |
const fetchMessages = async () => { | |
return fetch('/api/messages') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: lanetix-resizer | |
labels: | |
app: lanetix-resizer | |
spec: | |
type: LoadBalancer | |
selector: | |
app: lanetix-resizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml | |
kubectl apply -f https://gist.githubusercontent.com/troygoode/102596f2ebc4211ccbdaf7c738cea7e5/raw/3d2870329af018efcce27d7da8ed8048af90fbf7/eks-admin-service-account.yaml | |
kubectl apply -f https://gist.githubusercontent.com/troygoode/102596f2ebc4211ccbdaf7c738cea7e5/raw/3d2870329af018efcce27d7da8ed8048af90fbf7/eks-admin-cluster-role-binding.yaml | |
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: eks-admin | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: cluster-admin | |
subjects: | |
- kind: ServiceAccount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.record-field > span > div { | |
background-color: #f5f5f5; | |
padding: 1em; | |
border-radius: 4px; | |
margin-top: .5em; | |
} | |
.record-field > span > div hr { | |
margin: 1em 0 !important; | |
border: 0 !important; |
NewerOlder