Skip to content

Instantly share code, notes, and snippets.

@thathurtabit
thathurtabit / useFetchWithAbort.tsx
Created June 29, 2021 09:33
React: Fetch Hook (with AbortController to avoid race conditions and memory leaks)
import { useState, useEffect } from "react";
/* H/T:
Avoiding Race Conditions and Memory Leaks in React useEffect
https://javascript.plainenglish.io/avoiding-race-conditions-and-memory-leaks-in-react-useeffect-2034b8a0a3c7
*/
interface IUseFetchWithAbortResponse {
fetchedData: unknown;
isLoading: boolean;
@jasonbradley
jasonbradley / jsonStorage.lua
Created December 15, 2012 05:28
Lua read/write data in JSON format
-- load the JSON library.
local Json = require("json")
local JsonStorage = {}
-- Function to save a table.  Since game settings need to be saved from session to session, we will
-- use the Documents Directory
JsonStorage.saveTable = function(t, filename)
local path = system.pathForFile( filename, system.DocumentsDirectory)
local file = io.open(path, "w")