Skip to content

Instantly share code, notes, and snippets.

View conqp's full-sized avatar
🦀
תאמין שיש בך עוצמה לשנות

Richard Neumann conqp

🦀
תאמין שיש בך עוצמה לשנות
View GitHub Profile
@conqp
conqp / lsimports.py
Last active January 26, 2021 22:40
List imported modules of Python projects
#! /usr/bin/env python3
# lsimports.py - List imported modules of Python projects.
#
# Copyright (C) 2020 Richard Neumann <mail at richard dash neumann period de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@conqp
conqp / coroproperty.py
Last active July 12, 2022 11:21
Coroutine-based two-in-one property.
#! /usr/bin/env python3
# coroproperty.py - Coroutine-based two-in-one properties.
#
# Copyright (C) 2020 Richard Neumann <mail at richard dash neumann period de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@conqp
conqp / ddnssupdate.py
Last active December 26, 2020 14:12
Script to update DynDNS hosts registered at ddnss.de
#! /usr/bin/env python3
# ddnssupdate.py - Script to update DynDNS hosts registered at ddnss.de.
#
# Copyright (C) 2020 Richard Neumann <mail at richard dash neumann period de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@conqp
conqp / db_backup.py
Last active October 10, 2023 07:44
Python 3 script to backup local MySQL databases.
#! /usr/bin/env python3
#
# db_backup - Backup local MySQL databases.
# Copyright (C) 2021 HOMEINFO - Digitale Informationssysteme GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@conqp
conqp / magicfun.py
Created March 29, 2021 14:20
Fun with magic dunder methods
#! /usr/bin/env python3
"""Fun with magic dunder methods."""
from pathlib import Path
class Domain(str):
"""Represents a domain name."""
def __rmatmul__(self, user: str) -> str:
@conqp
conqp / intvec.cpp
Created April 18, 2021 16:03
C++ int vector
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::vector;
int main()
{
vector<int> v = {1,2,3,5,9,7};
@conqp
conqp / checkMarks.cpp
Last active May 4, 2021 12:45
Check whether you passed an exam
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
static unsigned short readMarks(string const & prompt)
{
@conqp
conqp / notify-failed.py
Last active May 18, 2021 17:00
Send emails when systemd units fail
#! /usr/bin/env python3
"""Notify admins about failed services."""
from argparse import ArgumentParser, Namespace
from pathlib import Path
from typing import Iterator, List
from configlib import loadcfg
from emaillib import EMail, Mailer
@conqp
conqp / floatsum.cpp
Last active June 25, 2021 08:28
float sum precision
#include <algorithm>
using std::for_each;
using std::reverse;
#include <cmath>
using std::modf;
#include <iomanip>
using std::left;
using std::setprecision;
@conqp
conqp / PromiseFuture.cpp
Last active July 2, 2021 10:22
Wrapper for a promise and a corresponding future
#include <future>
#include <iostream>
#include <thread>
template <typename T>
class PromiseFuture {
private:
std::promise<T> promise;
std::future<T> future;
public: