Skip to content

Instantly share code, notes, and snippets.

@fnky
fnky / hooks.js
Last active January 7, 2024 12:32
React Hooks: useReducer with actions and selectors (Redux-like)
function useSelectors(reducer, mapStateToSelectors) {
const [state] = reducer;
const selectors = useMemo(() => mapStateToSelectors(state), [state]);
return selectors;
}
function useActions(reducer, mapDispatchToActions) {
const [, dispatch] = reducer;
const actions = useMemo(() => mapDispatchToActions(dispatch), [dispatch]);
return actions;
@ThomasG77
ThomasG77 / five-minutes-pgadmin4-desktop-install-guide.md
Last active October 14, 2024 11:59
5 minutes PgAdmin4 Desktop install guide

5 minutes PgAdmin4 Desktop install guide

Done on Linux (Ubuntu tested)

Virtualenv & install of Python package & its deps

cd $HOME
virtualenv --python=/usr/bin/python2.7 pgadmin4
source pgadmin4/bin/activate
@BretFisher
BretFisher / docker-cli-tips-and-tricks.md
Last active December 6, 2023 19:49
Docker CLI Tips and Tricks
@anaclair
anaclair / shopping_cart.md
Last active March 22, 2023 11:46
Implementing Redis Shopping Cart

What is Redis?
Redis is an open source, advanced in-memory key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

######1. If you're running OS X, install redis in terminal using Homebrew : brew install redis

######2. Add the redis and hiredis gems to the project's Gemfile (remember to bundle install after you do this) :