Skip to content

Instantly share code, notes, and snippets.

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

Richard Neumann conqp

🦀
תאמין שיש בך עוצמה לשנות
View GitHub Profile
@conqp
conqp / color_code.py
Created November 3, 2022 10:37
Encode arbitrary strings with ANSI background coloring
#! /usr/bin/env python3
"""Encode arbitrary strings with ANSI background coloring."""
from argparse import ArgumentParser, Namespace
from sys import stdin, stdout
RESET = '\x1b[0m'
@conqp
conqp / hangman.py
Last active September 1, 2022 09:38
Simple hangman game
#! /usr/bin/env python3
"""Hangman game."""
from os import linesep
from string import ascii_letters
from sys import exit, stderr
from typing import Iterator
class GameOver(Exception):
@conqp
conqp / loop_else_detect.py
Last active September 2, 2022 14:02
Find for- and while-loops with else clauses
#!/usr/bin/env python
"""Find for- and while-loops with else clauses."""
from ast import For, Module, While, parse, walk
from logging import getLogger
from pathlib import Path
from typing import Iterator
LOGGER = getLogger(__file__)
@conqp
conqp / generator-generator.py
Last active May 7, 2022 12:56
Generator of generators demo
#! /usr/bin/env python3
"""Generator of generators demo."""
from typing import Iterator, Sequence
def npowers(numbers: Sequence[int]) -> Iterator[Iterator[int]]:
"""Yield n generators of the n-power of
numbers with n being the amount of numbers.
@conqp
conqp / dzservers.json
Created February 4, 2022 13:58
DayZ Server Config
{
"dayz": {
"app_id": 1042420,
"base_dir": "/srv/dayz",
"params": {
"profiles_dir": "profiles",
"no_file_patching": false
},
"mods": [
{
@conqp
conqp / 0001-Add-aint-keyword-as-alternative-to-is-not.patch
Created January 18, 2022 17:52
Add keyword "aint" to Python as alternative to "is not"
From 57c73151fe6d8600bb9bc6862781f63541f28cd8 Mon Sep 17 00:00:00 2001
From: Richard Neumann <r.neumann@homeinfo.de>
Date: Tue, 18 Jan 2022 18:50:33 +0100
Subject: [PATCH] Add "aint" keyword as alternative to "is not"
---
Grammar/python.gram | 4 +-
Parser/parser.c | 294 ++++++++++++++++++++++++--------------------
2 files changed, 164 insertions(+), 134 deletions(-)
@conqp
conqp / distributions.py
Last active December 30, 2021 17:56
check random subset size distributions
from collections import defaultdict
from functools import partial
from json import dumps
from random import *
l = [5, 1, 2, 7, 4]
f = lambda x: [i for _, i in sample(list(enumerate(x)),k=randrange(len(x))+1)]
def g(a):
@conqp
conqp / kdiff.py
Created November 19, 2021 12:55
Check whether your running kernel is equal to the installed kernel.
#! /usr/bin/env python3
"""Check whether the running kernel equals the installed kernel package."""
from argparse import ArgumentParser, Namespace
from logging import INFO, WARNING, basicConfig, getLogger
from subprocess import check_output
from sys import exit # pylint: disable=W0622
from typing import NamedTuple, Optional
@conqp
conqp / pjdb.py
Created October 19, 2021 17:14
JSON-ify pacman databases
#! /usr/bin/env python3
#
# pjdb.py - JSON-ify pacman databases.
#
# (C) 2021 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, version 3.
#
@conqp
conqp / async.cpp
Created August 17, 2021 09:57
Async types
#include <chrono>
using std::chrono::duration;
using std::chrono::system_clock;
#include <future>
using std::async;
using std::launch;
#include <iostream>
using std::cout;