Skip to content

Instantly share code, notes, and snippets.

View SuperSuperDev's full-sized avatar
🎯
Focusing

Steven Saunders SuperSuperDev

🎯
Focusing
View GitHub Profile
@SuperSuperDev
SuperSuperDev / useForm.js
Created September 8, 2022 09:31
React-Hooks
import React from 'react';
export default function useForm(initialState) {
const [formdata, setFormdata] = React.useState(initialState);
const [formErrors, setFormErrors] = React.useState(initialState);
const handleChange = (event) => {
setFormdata({ ...formdata, [event.target.name]: event.target.value });
setFormErrors({ ...formErrors, [event.target.name]: '' });
};

Add or connect a database with WSL | Microsoft Docs

Install MongoDB

To install MongoDB (version 5.0) on WSL (Ubuntu 20.04):

  1. Open your WSL terminal (ie. Ubuntu) and go to your home directory: cd ~
  2. Update your Ubuntu packages: sudo apt update
  3. Import the public key used by the MongoDB package management system: wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
  4. Create a list file for MongoDB: echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

Python Commands

Python Shell

Venv

$ python3 -m venv venv
$ source venv/bin/activate
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m pip install -r requirements.txt
@SuperSuperDev
SuperSuperDev / .zshrc
Last active January 21, 2022 13:43
zshrc alias
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@SuperSuperDev
SuperSuperDev / wagtail-import-data.md
Created October 5, 2021 22:17 — forked from tomdyson/wagtail-import-data.md
Create 35k Wagtail pages of Wikipedia film plots

Create Wagtail pages programmatically

This short recipe demonstrates how to create Wagtail pages programmatically. It may also be useful for testing Wagtail development against a reasonable volume of page data (about 35,000 film plots, from English Wikipedia).

Instructions

In a virtualenv:

@SuperSuperDev
SuperSuperDev / geoDjangoSeed.md
Last active October 11, 2021 16:12
geoDjango Commands

Seed geoDjango with SHapefiles

Inspect the shapefiles

ogrinfo -so ./thailand/data/tha_adm_rtsd_itos_20190221_SHP_PART_1/tha_admbnda_adm1_rtsd_20190221.shp tha_admbnda_adm1_rtsd_20190221
import ogr
@SuperSuperDev
SuperSuperDev / postgreSQLShellCommands.md
Last active October 6, 2021 22:56
PostgreSQL Shell Commands

PostgreSQL Commands

Install PostgreSQL (Ubuntu)

Update the apt package index

sudo apt-get update

ogr2ogr th-adm-0.geojson -f "GeoJSON" -lco id_field=ADM0_PCODE -t_srs "EPSG:4326" tha_admbnda_adm0_rtsd_20190221.shp