Skip to content

Instantly share code, notes, and snippets.

View niccolomineo's full-sized avatar

Niccolò Mineo niccolomineo

View GitHub Profile
@niccolomineo
niccolomineo / filters.py
Last active August 9, 2023 22:13
Django ArrayField inheritable list filter
"""Django filters."""
from django.contrib.admin import SimpleListFilter
class ArrayFieldListFilter(SimpleListFilter):
"""An admin list filter for ArrayFields."""
def lookups(self, request, model_admin):
"""Return the filtered queryset."""
@niccolomineo
niccolomineo / storages.py
Last active January 15, 2023 17:18
A file system storage with file overwriting capabilities
"""Django storages."""
from django.core.files.storage import FileSystemStorage
class FileSystemOverwriteStorage(FileSystemStorage):
"""A file system storage with file overwriting capabilities."""
def get_available_name(self, name, max_length=None):
"""Return the available name."""
self.delete(name)
@niccolomineo
niccolomineo / text_utils.py
Created January 15, 2023 17:58
A utiliy to strip the Byte Order Mark from UTF-8 text
"""Text utils."""
strip_bom(value):
"""Strip Byte Order Mark from UTF-8 text."""
return value.encode("utf-8").decode("utf-8-sig")
@niccolomineo
niccolomineo / pyproject.toml
Last active August 9, 2023 10:15
A `pyproject.toml` configuration for a Django / Python 3.11 installable package
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"wheel",
]
[project]
name = "Django Project"
version = "0.0.1"
@niccolomineo
niccolomineo / webpack.config.js
Last active April 5, 2024 16:29
A Webpack configuration for obfuscating JavaScript in an Electron.js app
const Path = require('path'),
NodeExternals = require('webpack-node-externals'),
Copy = require('copy-webpack-plugin'),
Obfuscator = require('webpack-obfuscator')
module.exports = {
context: __dirname,
mode: 'production',
target: 'electron-main',
entry: {
@niccolomineo
niccolomineo / reset.css
Created November 14, 2023 14:24
CSS Reset
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
}
body {
line-height: 1.5;