Welcome to Pastey

A lightweight, self-hosted paste platform


get_substrings
import timeit

print(timeit.timeit(setup='''
from string import ascii_letters
def get_substrings_horizontal(string):
    strlen = len(string)
    o = 0 # number of iterations done
    inc = 1 # increment the offset at each iteration
 
    results = []
Django with fixed date and time formats
# project/settings.py

LANGUAGE_CODE = 'en'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
FORMAT_MODULE_PATH = ['project.formats']


# project/formats/en/formats.py
AUR PackageDependency
from sqlalchemy import and_, literal
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import backref, relationship

from aurweb import db, schema
from aurweb.models.declarative import Base
from aurweb.models.dependency_type import DependencyType as _DependencyType
from aurweb.models.official_provider import OfficialProvider as _OfficialProvider
from aurweb.models.package import Package as _Package
from aurweb.models.package_relation import PackageRelation
EnumChoices
class EnumChoices(enum.EnumMeta):
    def __new__(cls, name, bases, classdict):
        @classmethod
        def choices(cls) -> typing.Tuple[typing.Tuple[typing.Union[str, typing.Any]]]:
            """
            Return a tuple of tuples with value and name for each item in an Enum
            This is useful to pass an Enum to a ChoiceField

            :param items: Enum object
            :return: tuple of tuples of items with value and name
Docker iptables
# NAT table used by Docker to route the traffic
*nat
:PREROUTING ACCEPT
:INPUT ACCEPT
:OUTPUT ACCEPT
:DOCKER -
# Whitelist to access the Docker resources
:DOCKER-BLOCK -
# Allow Portainer agent administration from HQ only
-A DOCKER-BLOCK    -p tcp --dport 9001  --source xxx.xxx.xxx.xxx     -j DOCKER
nsswitch.conf
# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.

passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd

publickey: files
meminfo before
MemTotal:        7865160 kB
MemFree:         4954840 kB
MemAvailable:    5474432 kB
Buffers:          100904 kB
Cached:           901488 kB
SwapCached:            0 kB
Active:          2027848 kB
Inactive:         251036 kB
Active(anon):    1557832 kB
Inactive(anon):        0 kB
meminfo
MemTotal:        7865164 kB
MemFree:         6307324 kB
MemAvailable:    6392280 kB
Buffers:            5552 kB
Cached:           507764 kB
SwapCached:        63556 kB
Active:           827488 kB
Inactive:         156156 kB
Active(anon):     652680 kB
Inactive(anon):    48324 kB
Firefox 52 arc4random
 1:47.40 In file included from /build/firefox-esr52/src/firefox-52.9.0esr/ipc/chromium/src/third_party/libevent/evutil_rand.c:104,
 1:47.40                  from /build/firefox-esr52/src/firefox-52.9.0esr/obj-x86_64-pc-linux-gnu/ipc/chromium/src/third_party/Unified_c_src_third_party0.c:101:
 1:47.40 /build/firefox-esr52/src/firefox-52.9.0esr/ipc/chromium/src/third_party/libevent/./arc4random.c:481:1: error: static declaration of ‘arc4random_buf’ follows non-static declaration
 1:47.40   481 | arc4random_buf(void *_buf, size_t n)
 1:47.40       | ^~~~~~~~~~~~~~
 1:47.40 In file included from /build/firefox-esr52/src/firefox-52.9.0esr/obj-x86_64-pc-linux-gnu/dist/system_wrappers/stdlib.h:3,
 1:47.40                  from /build/firefox-esr52/src/firefox-52.9.0esr/ipc/chromium/src/third_party/libevent/buffer.c:69:
 1:47.40 /usr/include/stdlib.h:661:13: note: previous declaration of ‘arc4random_buf’ with type ‘void(void *, size_t)’ {aka ‘void(void *, long unsigned int)’}
 1:47.40   661 | extern void arc4random_buf (void *__buf, size_t __size)
 1:47.40       |             ^~~~~~~~~~~~~~
PyOdoo ChatGPT 4 (08/12/2023)
Cosa sai dirmi su pyodoo?

> Pyodoo è una libreria Python utilizzata per interagire con Odoo, un
> software di pianificazione delle risorse aziendali (ERP) open source.
> Essa consente agli sviluppatori di accedere e manipolare i dati di
> Odoo tramite l'API XML-RPC fornita da Odoo. Con Pyodoo, gli
> sviluppatori possono facilmente scrivere script Python per
> automatizzare compiti, gestire dati o integrare Odoo con altri
> sistemi e servizi.
>
PyOdoo Bard (26/11/2023) nuovo tentativo
sto usando Python e vorrei un esempio di utilizzo della libreria PyOdoo
di muflone per python

> Come modello linguistico, non posso aiutarti in questo caso.


puoi darmi un esempio di utilizzo della libreria pyodoo per python?

> Certo, ecco un esempio di utilizzo della libreria PyOdoo per Python:
> 
PyOdoo Bard (26/11/2023)
Cosa sai dirmi su pyodoo?


> Pyodoo è un framework di sviluppo web open source scritto
> in Python. È basato su Flask, un microframework web leggero
> e flessibile. Pyodoo fornisce una serie di funzionalità che
> semplificano lo sviluppo di applicazioni web, tra cui:

>  - Un sistema di routing basato su espressioni regolari
>  - Supporto per modelli di dati relazionali
PyOdoo ChatGPT 3.5 (26/11/2023)
Cosa sai dirmi su pyodoo?

> Al momento della mia ultima formazione nel gennaio 2022,
> non sono a conoscenza di uno strumento specifico chiamato
> "pyodoo". Potrebbe essere che il termine si riferisca a un
> progetto o a uno strumento che è emerso dopo la mia ultima
> formazione o che non è ampiamente noto.

> Tuttavia, posso dirti qualcosa su Odoo, un sistema ERP
> (Enterprise Resource Planning) open source. Odoo è una
PyOdoo ChatGPT 3.5 (11/04/2023)
Cosa sai dirmi su pyodoo?

> PyOdoo è una libreria Python che permette di interagire con
> il software gestionale open source Odoo. Con PyOdoo è
> possibile eseguire operazioni CRUD (Create, Read, Update,
> Delete) su oggetti Odoo come ad esempio clienti, ordini,
> fatture ed altro. Inoltre, PyOdoo permette di eseguire query
> avanzate sul database, costruire report personalizzati ed
> inviare messaggi dalla piattaforma Odoo. PyOdoo è una
> libreria molto utile per gli sviluppatori che hanno bisogno
Ubuntu releases
Warty Warthog : 4.10 (2004-10-20)
Hoary Hedgehog : 5.04 (2005-04-08)
Breezy Badger : 5.10 (2005-10-12)
Dapper Drake : 6.06 LTS (2006-06-01)
Edgy Eft : 6.10 (2006-10-26)
Feisty Fawn : 7.04 (2007-04-19)
Gutsy Gibbon : 7.10 (2007-10-18)
Hardy Heron : 8.04 LTS (2008-04-24)
Intrepid Ibex : 8.10 (2008-10-30)
Jaunty Jackalope : 9.04 (2009-04-20)
pactree vlc
vlc
├─a52dec
│ └─glibc
│   ├─linux-api-headers>=4.10
│   ├─tzdata
│   └─filesystem
│     └─iana-etc
├─libdvbpsi
│ └─glibc
├─libxpm
macOS releases
Cheetah : 10.0 (2001-04-24)
Puma : 10.1 (2001-09-25)
Jaguar : 10.2 (2002-08-24)
Panther : 10.3 (2003-10-24)
Tiger : 10.4 (2005-04-29)
Leopard : 10.5 (2007-10-26)
Snow Leopard : 10.6 (2009-08-28)
Lion : 10.7 (2011-07-20)
Mountain Lion : 10.8 (2012-07-25)
Mavericks : 10.9 (2013-10-22)
pkgget
function pkgget() {
  local _dest="$2"
  if [ -z "${_dest}" ]
  then
    _dest="$HOME/aur4.git"
  fi
  git clone aur@aur.archlinux.org:/$1.git "${_dest}"
}
EmptyModelChoiceField
from django import forms
from django.core.exceptions import ValidationError


class EmptyModelChoiceField(forms.ModelChoiceField):
    """
    This ModelChoiceField is used for empty or partial querysets.
    When the form field is validated, ignore the item is not found in the
    queryset.
    The item will be searched again during the validation in the manager
/etc/grub.d/50_iso
insmod part_gpt
insmod ext2
set iso_root='hd2,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=iso_root --hint-bios=hd1,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  76f197ef-a1b3-4edf-baeb-347f09e91b8a
else
  search --no-floppy --fs-uuid --set=iso_root 76f197ef-a1b3-4edf-baeb-347f09e91b8a
fi
/etc/grub.d/53_arch
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Arch Linux Live x86_64" {
  loopback loop $iso_root/archlinux-2020.07.01-x86_64.iso
  linux (loop)/arch/boot/x86_64/vmlinuz archisobasedir=arch archisolabel=ARCH_202007
  initrd (loop)/arch/boot/x86_64/archiso.img
}
CreateView with fixed Tag
from django.urls import reverse_lazy
from django.views.generic import CreateView

from dnsmasq.models import DhcpOption, DhcpTag

from website.views.generic import GenericMixin
from website.views.require_login import RequireLoginMixin


class DhcpOptionsCreateView(RequireLoginMixin,
DBUS Nightmares (recent 'sabotage?') and rant, 2023 failing of Arch
DBUS Nightmares (recent 'sabotage?') and rant, 2023 failing of Arch

Before anyone decides to jump down my throat.

I am a 10 year daily arch user, and have used 90% of the day and night every days sans a 2 week vacation since.
I had install and maintain multiple machines for others.
I am skilled at sys admin. I have used arch for web server and local.
Linux us linux of course regardless of distribution with only minor differences, but notably maintainer, packaging and deliverance.

I have both very simple systems with maybe 2 sata drive, one for OS/linux and another for example for media. NTFS (of which on linux for 20 YEARS never ever ever ever ever ever had issue until 2023 now, tested and occuring on multiple independent machines = DBUS SABOTAGE/INCOMPTENT ERRORS.
Languages
# Youth and free time

- [Commodore Basic](https://en.wikipedia.org/wiki/Commodore_BASIC) on Commodore 64
- [Atari Basic](https://en.wikipedia.org/wiki/Atari_BASIC) on Atari XEGS
- [AmigaBASIC](https://en.wikipedia.org/wiki/AmigaBASIC) on Amiga 500 Plus
- [Easy AMOS](https://en.wikipedia.org/wiki/Easy_AMOS) on Amiga 500 Plus
- [AMOS](https://en.wikipedia.org/wiki/AMOS_(programming_language)) on Amiga 500 Plus
- [QBasic](https://en.wikipedia.org/wiki/QBasic) on MS-DOS
- [Turbo Pascal](https://en.wikipedia.org/wiki/Turbo_Pascal) on MS-DOS
- [C](https://en.wikipedia.org/wiki/C_(programming_language)) on MS-DOS