Skip to content

Instantly share code, notes, and snippets.

@ralfstx
ralfstx / README.md
Created October 8, 2020 07:19
Python cProfile to CSV function
@ralfstx
ralfstx / asciitable
Created December 18, 2020 10:50
Python script to print an ASCII table to the console
#!/usr/bin/python3
header="DEC HEX CHR"
spacer=" " * 5
def row(i):
return f"{i:3} {i:02x} {chr(i)} "
if __name__ == "__main__":
print(spacer.join((header for _ in range(6))))
@ralfstx
ralfstx / react-context.js
Last active February 21, 2021 13:49
Example of a React app with complex state.
/* eslint-disable no-console */
import React, { createContext, useContext, useMemo, useReducer } from 'react';
import ReactDOM from 'react-dom';
// Example of a React app with complex state.
// Use separate context to avoid unnecessary renders.
// ## ContextProvider
const FooContext = createContext();