Redux Toolkit Javascript Starter

Install redux toolkit and react-redux 1 pnpm install @reduxjs/toolkit react-redux Create a redux store 1 2 3 4 5 6 //store.js import { configureStore } from '@reduxjs/toolkit' export const store = configureStore({ reducer: {}, }) Provide the redux store to react 1 2 3 4 5 6 7 8 9 10 11 12 13 // pages/_app.js import { store } from "../store/store"; import { Provider } from "react-redux"; function MyApp({ Component, pageProps }) { return ( <Provider store={store}> <Component {.

Django Manual Editing Auto DateTime Fields

TL;DR: use default=timezone.now, editable=False, blank=True to mimic the behavior of auto_now and auto_now_add. Django’s auto_now and auto_now_add fields are built-in django model fields and used to track when a model was modified or created. They are suppose to be readonly fields. But there are times that I want to overwrite these two fields for some model instances. For example: I’d like to change my test data to match exact timestamp each time.

Install Docker and Docker Compose on Linux and post-installation

This is just a curated list of resources of how to install docker and docker compose on linux from docker official documentation. I recently installed docker twice on my centos server so I think it is worth noting it down for future use. Docker installation and post-installation: Install Docker Engine for linux Post-installation steps for linux Docker daemon configuration Daemon configuration Change data-root parameter to a custom path.

Install Python 3.9 on Centos 7 or 8

CentOS has python2.7.5 and python3.6.8 inculded. I’d like to have latest python installed for some new features. Remove default python3 1 yum remove python3 Install prerequisite packages 1 2 3 yum update -y yum groupinstall -y 'Development Tools' yum install -y gcc openssl-devel bzip2-devel libffi-devel Download python source code Pyhon source code can be found here(FTP server). 1 2 3 wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tar.xz tar zxf Python-3.

Install WSL2 on a Non-Default Drive

Enable the Windows Subsystem for Linux Open PowerShell as Administrator and run: 1 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart Enable Virtual Machine feature Open PowerShell as Administrator and run: 1 dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart Restart computer then move to next step. Download the Linux kernel update package Download and run Latest WSL2 Linux kernel update package for x64 machines Set WSL 2 as your default version Open powershell and run:

Enable Hyper-V for Windows 10 Home

It’s a shame that Hyper-V is not available for windows 10 home edition. Here’s a hack to enable it. Create a text file with following content: 1 2 3 4 5 6 pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hv.txt for /f %%i in ('findstr /i . hv.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i" del hv.txt Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL pause Save it as a .

Cargo Config

Additional configs for cargo to solve access issue to creates.io. Change registry to China specific mirror and use the git executable to fetch registry contents instead of built-in git library. First, create a config file under ~/.cargo folder. In Windows, that’s C:\Users\<username>\.cargo\config file. Then add following content to the config file: 1 2 3 4 5 6 7 8 9 10 [source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'ustc' [source.