Skip to content

Instantly share code, notes, and snippets.

View zeenfaizpy's full-sized avatar

Mohammad Faizal zeenfaizpy

View GitHub Profile
@slikts
slikts / context-vs-redux-2020.md
Last active March 6, 2022 20:41
Up to date answer about when to use React context or Redux (Redux Toolkit)

nelabs.dev

React context vs Redux in 2020

The [React docs][condoc] give some example use cases for context:

Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language.

The common property of these use cases is that data like the current theme doesn't change often and needs to be shared deep down the component tree, which would be cumbersome with "[prop drilling][drill]". Something else that needs to be shared everywhere is the application state when using a "single source of truth" pattern, so it would follow that the context API would help with that as well, but there's a catch: components that use context will rerender every time that the provided value changes, so sharing the whole application state through context would cause excessive render lifecycles.

@luzfcb
luzfcb / installing_pyenv_on_ubuntu_based_distros.md
Last active May 2, 2024 17:51
Quick install pyenv and Python

Tested only on Ubuntu 22.04, KDE Neon User Edition (based on Ubuntu 22.04) and OSX Mojave or higher.

will probably work on other newer versions, with no changes, or with few changes in non-python dependencies (apt-get packages)

NOTE: Don't create a .sh file and run it all at once. It may will not work. Copy, paste, and execute each command below manually. :-)

Ubuntu

# DO NOT RUN THIS AS A ROOT USER
@Ignas
Ignas / postgresql.mk
Created January 25, 2012 13:52
Set up for a local postgresql database using a Makefile
export PGPORT ?= 4488
PG_PATH ?= $(shell if test -d /usr/lib/postgresql/9.1; then echo /usr/lib/postgresql/9.1; else echo /usr/lib/postgresql/8.4; fi)
PG_DIR = ${PWD}/instance/var
PG_DATA = ${PG_DIR}/data
PG_RUN = ${PG_DIR}/run
PG_LOG = ${PG_DIR}/log
PG_SOCKET = ${PG_RUN}/.s.PGSQL.${PGPORT}
PGPARAMS = -D ${PG_DATA} -o "-F -c unix_socket_directory=${PG_RUN} -c custom_variable_classes='busy' -c busy.active_user=0" -l ${PG_LOG}/pg.log