Skip to content

Instantly share code, notes, and snippets.

@lboulard
lboulard / pipx-jupyter.md
Last active March 13, 2024 18:19
pipx and Jupyter Qt console

pipx version

pipx --version
0.16.3

First installation

pipx install --include-deps jupyterlab
pipx inject jupyterlab matplotlib numpy jupyter-console scipy simpy sympy

pipx inject jupyterlab arrow pandas tabulate isort black jupyterlab_code_formatter

@AlexRiina
AlexRiina / noqaer.py
Last active May 11, 2023 00:33
automatically ignore lines from flake8
"""
Add `# noqa: FXXX` comments to all lines with violations from flake8
"""
# MIT License
#
# Copyright (c) 2022 Alex Riina
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@flotwig
flotwig / internet-wg0.conf
Last active November 21, 2021 11:01
WireGuard configuration
[Interface]
# Configuration for the server
# Set the IP subnet that will be used for the WireGuard network.
# 10.222.0.1 - 10.222.0.255 is a memorable preset that is unlikely to conflict.
Address = 10.222.0.1/24
# The port that will be used to listen to connections. 51820 is the default.
ListenPort = 51820
@mrunkel
mrunkel / zfs_cheatsheet.md
Last active October 17, 2024 15:31
My ZFS cheatsheet

ZFS commands cheatsheet

Devices and Pools

List all devices in the server

lsblk -S

List all pools

zpool list

@elalemanyo
elalemanyo / README.md
Last active October 9, 2024 08:47
Debug zsh startup time

Debug zsh startup time

  1. Inject profiling code

    At the beginning of your .zshrc add following: zmodload zsh/zprof

    and at the end add: zprof

    This will load zprof mod and display what your shell was doing durung your initialization.

@hvanderlaan
hvanderlaan / nagiosTelegram.py
Last active November 30, 2021 11:34
Nagios notifications via Telegrambot
#!/usr/bin/env python
# file : nagiosTelegram.py
# purpose : send nagion notifications via Telegram bot
#
# author : harald van der laan
# date : 2017/04/01
# version : v1.0.1
#
# changelog:
@JordanReiter
JordanReiter / management_email_admins.py
Created March 28, 2017 21:08
Use the EmailAdminsOnErrorCommand class instead of BaseCommand so that your Django management commands send error emails to admins
# This file provides a base Command class that handles sending errors via mail_admins
# Make sure to adjust the LOGGING variable in settings
# Credit to Abdulla Diab: https://mpcabd.xyz/make-django-management-commands-send-errors-email-admins/
import sys
import logging
from django.core.management import BaseCommand
logger = logging.getLogger('management.command')
@bmispelon
bmispelon / README.rst
Last active May 8, 2018 10:28
Regionalify: Supercharge your Django Admin with the power of regional character indicators

Regionalify

Make your Django admin prettier with regional indicator characters!

Installation

Put the regionalify directory somewhere on your Python PATH (in your

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

"""
Logical deletion for Django models. Uses is_void flag
to hide discarded items from queries. Overrides delete
methods to set flag and soft-delete instead of removing
rows from the database.
"""
from django.apps import apps
from django.contrib.admin.utils import NestedObjects
from django.db import models
from django.db.models import signals