Skip to content

Instantly share code, notes, and snippets.

View benderham's full-sized avatar
:octocat:

Ben Derham benderham

:octocat:
View GitHub Profile
@benderham
benderham / FormilkAutoSave.js
Created February 3, 2020 01:51
Formik Auto Save Component
const AutoSave = ({ debounceMs }) => {
const formik = useFormikContext();
const [lastSaved, setLastSaved] = React.useState(null);
const debouncedSubmit = React.useCallback(
debounce(
() =>
formik.submitForm().then(() => setLastSaved(new Date().toISOString())),
debounceMs
),
@benderham
benderham / cobalt2.zsh-theme
Last active December 30, 2019 06:54
Cobalt2 ZSH Theme w/Node Version
#
# Cobalt2 Theme - https://github.com/wesbos/Cobalt2-iterm
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
##
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
@benderham
benderham / App.js
Created October 20, 2019 08:26
SheCodes React - JavaScript Fetch API
import React, { Component } from 'react';
import './App.css';
import PostPerson from './PostPerson';
const API_URL = 'http://jsonplaceholder.typicode.com/users/';
class App extends Component {
state = {
users: []
};
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@benderham
benderham / calc.js
Last active September 25, 2023 04:54
Very Basic NodeJS Calculator
var readline = require('readline-sync');
var Calculation = function(num1, num2, op) {
this.x = parseInt(num1);
this.y = parseInt(num2);
this.op = op;
this.result = function() {
var x = this.x;
var y = this.y;