Skip to content

Instantly share code, notes, and snippets.

View lampslave's full-sized avatar

Maksim Iakovlev lampslave

View GitHub Profile

Setup nut and netdata on Ubuntu

In this document, I will explain how to setup nut (Network UPS Tools) on Ubuntu 18.04 and 20.04.

It is basically the next chapter of my previous gist, Upgrade nut on Ubuntu 18.04.

I'll only document USB connected UPS and not the other supported connection modes.

Install required dependencies

@lampslave
lampslave / remove_duplicates.py
Created May 4, 2022 12:55 — forked from victorono/remove_duplicates.py
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)