Skip to content

Instantly share code, notes, and snippets.

View christopherhill's full-sized avatar

Christopher Hill christopherhill

View GitHub Profile
@jogilvyt
jogilvyt / App.js
Created January 19, 2021 15:53
A React counter app with localStorage
import { useState, useEffect } from "react";
function App() {
const key = "count";
const [count, setCount] = useState(() => {
const persistedValue = window.localStorage.getItem(key);
return persistedValue !== null ? JSON.parse(persistedValue) : 0;
});
@grncdr
grncdr / data.csv
Created June 17, 2015 22:29
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@BinaryMuse
BinaryMuse / restful.js
Last active March 17, 2019 08:22
Express API with Async/Await
import express from "express";
/**
* Takes a route handling function and returns a function
* that wraps it after first checking that the strings in
* `reserved` are not part of `req.body`. Used for ensuring
* create and update requests do not overwrite server-generated
* values.
*/
function checkReservedParams(routeHandler, ...reserved) {