Skip to content

Instantly share code, notes, and snippets.

View auvipy's full-sized avatar
🐛
Unofficial Parental leave!

Asif Saif Uddin auvipy

🐛
Unofficial Parental leave!
View GitHub Profile
@auvipy
auvipy / Software RAID 1 setup on Ubuntu Server 20.04.md
Created February 22, 2024 10:37 — forked from fevangelou/Software RAID 1 setup on Ubuntu Server 20.04.md
Software RAID 1 setup on Ubuntu Server 20.04 (or newer)

Looking to create a Software RAID 1 setup for your 2-disk server on Ubuntu Server 20.04?

Screen Shot 2020-06-05 at 20 55 31

Let's start with the basics: the official guide by Ubuntu (https://ubuntu.com/server/docs/install/storage) is outdated/wrong. And as of March 2021 it's possible that there's a bug as well with how the bios_grub partitions are created when using multiple disks.

Now on to the solution:

  • Select "Custom storage layout" when you reach the storage configuration step of the installer.
  • If the disks have existing partitions, click on each disk under AVAILABLE DEVICES and then select REFORMAT. This will (temporarily) wipe out the partitions.
@auvipy
auvipy / yourapp_admin.py
Created January 16, 2024 08:12 — forked from sameerkumar18/yourapp_admin.py
Django Admin: Celery Retry Task by ID
# Add this code in any Django app's admin.py
# Works for all Task Statuses; you can filter them in line 12.
import ast
import importlib
import json
from django.contrib import admin
from django.contrib import messages
from django.utils.safestring import mark_safe
@auvipy
auvipy / django-postgresql-15.md
Created September 17, 2023 06:39 — forked from axelbdt/django-postgresql-15.md
# Django and PostgreSQL 15, the rules have changed

Django and PostgreSQL 15, the rules have changed

Postgres 15 is just out, and while there is a lot to love about this new release, you're in for a surprise if you try to set it up with Django following tutorials like this one.

The reason is stated in the release announcement:

Remove PUBLIC creation permission on the public schema (Noah Misch) The new default is one of the secure schema usage patterns that Section 5.9.6 has recommended...

Provided your web app doesn't access your database as a superuser (it shouldn't) and uses a dedicated user, it is not allowed to use the public schema anymore. You have to create one for this specific user, and the next section will

@auvipy
auvipy / yannakakis.md
Created August 27, 2023 14:51 — forked from pkhuong/yannakakis.md
A minimal version of Yannakakis's algorithm for mostly plain Python
#!/usr/bin/env sed -re s|^|\x20\x20\x20\x20| -e s|^\x20{4}\x23\x23{(.*)$|<details><summary>\1</summary>\n| -e s|^\x20{4}\x23\x23}$|\n</details>| -e s|^\x20{4}\x23\x23\x20?|| -e s|\x0c|\x20|
license, imports
# Yannakakis.py by Paul Khuong
#
# To the extent possible under law, the person who associated CC0 with
# Yannakakis.py has waived all copyright and related or neighboring rights
# to Yannakakis.py.

@auvipy
auvipy / workflows-in-django.md
Created December 8, 2022 07:39 — forked from Nagyman/workflows-in-django.md
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@auvipy
auvipy / compare.py
Created November 11, 2022 08:38 — forked from charettes/compare.py
Django test suite SQL output compare
import argparse
import difflib
import os
import sys
from itertools import chain
import yaml
file_name_format = "{sha}:{vendor}.yml"
@auvipy
auvipy / ingest_postgresq.py
Created June 16, 2022 18:08 — forked from lukecampbell/ingest_postgresq.py
A standalone script ot ingest TSV files into postgres.
#!/usr/bin/env python
import argparse
import psycopg2
import psycopg2.extras
import csv
from getpass import getpass, getuser
def main(args):
'''
Inserts a TSV into table in postgresql
@auvipy
auvipy / InvertBinaryTree.py
Last active August 27, 2020 07:11 — forked from tonybaloney/InvertBinaryTree.py
Invert binary tree in Python
from dataclasses import dataclass
from typing import Any
from xml.etree.ElementTree import Element
@dataclass
class Node():
val: Any
right: "Node"
left: "Node"
@auvipy
auvipy / proposal.rst
Last active February 23, 2017 18:04 — forked from koniiiik/proposal.rst
Google Summer of Code 2013 proposal: Composite Fields, vol. 2

Composite Fields, vol. 2

Abstract

Two years ago, as part of GSoC 2011, I started working on an implementation of composite fields as a means to support multi-column primary keys in models. While the project was successful, the timeframe wasn't sufficient to finish it and get it into a state where it

Install pgAdmin4 with python3 on Ubuntu 16.04

  1. Get source code pgAdmin4

     wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.0/source/pgadmin4-1.0.tar.gz
    
  2. Unpack pgadmin4-1.0.tar.gz in home dir

     tar xvzf pgadmin4-1.0.tar.gz -C ~/