Skip to content

Instantly share code, notes, and snippets.


Cameron Pitt cpitt

View GitHub Profile
cpitt / documentToMUIComponents.tsx
Created July 24, 2020 17:07
translate conentful document into material-ui components
View documentToMUIComponents.tsx
import {
} from '@contentful/rich-text-react-renderer';
import { Document, BLOCKS, INLINES } from '@contentful/rich-text-types';
import { Typography, Divider, Link } from '@material-ui/core';
* a wrapper around documentToReactComponents that has material-ui component defaults
cpitt / useIdleTimer.test.tsx
Created June 30, 2020 22:07
useIdleTimer React hook
View useIdleTimer.test.tsx
import { renderHook, act } from '@testing-library/react-hooks';
import useIdleTimer from './useIdleTimer';
import { fireEvent } from '@testing-library/react';
describe('useIdleTimer', function() {
it('should start timer when startIdleTimer is called', function() {
const { result } = renderHook(() => useIdleTimer());
cpitt / memoizeLocalStorage.js
Last active January 13, 2020 19:41
Memoize a function using local storage as it's cache
View memoizeLocalStorage.js
* memoizes a function using localStorage as the cache
* @param {function|Promise} fn function or promise you wish to memoize
* @param {Object} [options] additional configuration
* @param {number} [options.ttl=0] time to live in seconds
* @param {Boolean} [options.backgroundRefresh=false] whether the cache should be refreshed asynchronously,
* Note: new results won't resolve until next execution
* @return {Promise} Promise object represents memoized result
function memoizeLocalStorage(
cpitt / Dockerfile
Last active February 23, 2018 05:25
docker java install work around
View Dockerfile
FROM node:9.0
WORKDIR /usr/src/app
RUN echo "===> add webupd8 repository..." && \
echo "deb artful main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src artful main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver --recv-keys EEA14886 && \
apt-get update
RUN echo "===> install Java" && \
cd /var/lib/dpkg/info && \
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
cpitt / main.go
Created January 18, 2018 20:50
k8s go-client in cluster pod creation
View main.go
package main
import (
// "encoding/json"
log ""
metav1 ""

Keybase proof

I hereby claim:

  • I am cpitt on github.
  • I am cpitt ( on keybase.
  • I have a public key whose fingerprint is 8AF3 B1D2 E995 86E7 B32D 6C00 D8CA F5E3 5052 7865

To claim this, I am signing this object:

View .vimrc.before.local
let g:spf13_bundle_groups=['general', 'programming', 'misc', 'writing', 'javascript', 'html', 'ruby', 'youcompleteme' ]
let g:airline_powerline_fonts=1
cpitt / confirmation-directive.html
Created October 10, 2014 06:37
A Simple Directive for Bootstrap confirmation modals using ui-bootstrap
View confirmation-directive.html
<div class="modal-header">
<div class="modal-title">
<div class="modal-body">
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()"> {{cancelText}} </button>
cpitt / bootstrap-validation-directive.js
Last active August 29, 2015 14:02
angular bootstrap validation
View bootstrap-validation-directive.js
angular.module('bootstrap.validation', [])
If you want errors to show up after submit is hit then your submit action needs to
set your form's controller's .submitted value to true
/* example of a custom validation */
.directive('dateValidation', function(){
restrict: 'A',