Skip to content

Instantly share code, notes, and snippets.

View M0r13n's full-sized avatar
🦔

Leon Morten Richter M0r13n

🦔
View GitHub Profile
@M0r13n
M0r13n / main.py
Created May 17, 2021 10:47
Related mapping examle
#!/usr/bin/python
import json
from enum import Enum
import related
from attr import attrib
from related import to_model, TypedSequence
class Files(Enum):
@M0r13n
M0r13n / doh
Last active August 25, 2025 17:22
Setup Cloudflare as a DoH (DNS over HTTPS) resolver on Mikrotik devices (RouterOS v7.0.2+)
# Temporarily add a normal upstream DNS resolver
/ip dns set servers=1.1.1.1,1.0.0.1
# CA certificates extracted from Mozilla
/tool fetch url=https://curl.se/ca/cacert.pem
# Import the downloaded ca-store (127 certificates)
/certificate import file-name=cacert.pem passphrase=""
# Set the DoH resolver to cloudflare
@M0r13n
M0r13n / capsman.md
Last active April 10, 2022 13:52
Configure Mikrotik CAPsMAN with CHATEAU and Audience

Configure Mikrotik CAPsMAN with CHATEAU and Audience

I am assuming that your Chateau has loaded it's default config. If so:

  • bridge and lte interface are already configured correctly
  • also the DHCP server is already setup (192.168.88.2 - 192.168.88.254)
  • NAT is also already configured

Setup CAPsMAN

@M0r13n
M0r13n / rsa.py
Created April 12, 2022 11:16
RSA implementation in native Python. This is only a toy implementation used to show how RSA works.
from collections import namedtuple
import typing
KeyPair = namedtuple('KeyPair', ['n', 'e', 'd'])
def inverse(x: int, y: int) -> int:
a, b, u = 0, y, 1
while x > 0:
q = b // x
@M0r13n
M0r13n / README.md
Created October 22, 2022 12:16
Ansible playbook to download & install VS Code Server on a remote machine (without internet connection / offline)

Ansible playbook to download & install VS Code Server on a remote machine (without internet connection / offline)

By default VS Code installs its server component on a remote server automatically when using the SSH extension. This does not work when working in an air gapped environment or when working offline.

This playbook downloads the VS Code Server on a remote machine. It also extracts the tarball to the correct location. After running this playbook you can connect to the remote machine using the VS Code SSH extension.

How to run

@M0r13n
M0r13n / csr.sh
Created February 11, 2023 14:37
Bash script to create a certificate signing request (CSR).
#!/usr/bin/env bash
set -e
# ------------------------------------------------------------------------------
# This script will generate a new private key and a Certificate Signing Request
# (CSR) using OpenSSL.
# This script is non-interactive. Instead it uses the variables set at the
# beginning of this script.
# ------------------------------------------------------------------------------
@M0r13n
M0r13n / safe_eval.py
Created March 12, 2023 12:45
Safe evaluation of mathematical expressions in Python.
import ast
import operator as op
DEFINED_OPS = {
ast.Add: op.add,
ast.Sub: op.sub,
ast.Mult: op.mul,
ast.Div: op.truediv,
ast.USub: op.neg,
@M0r13n
M0r13n / eval.py
Last active July 16, 2023 12:40
Read Sparx Enterprise Architect files (.qea) using SQLite and SQLAlchemy
"""
Requires sqlalchemy and sqlalchemy_mixins. Install via pip
"""
import pathlib
import typing
from sqlalchemy import ForeignKey, Text, create_engine, Column, Integer, String
from sqlalchemy.orm import create_session, relationship, declarative_base
from sqlalchemy_mixins import ReprMixin
@M0r13n
M0r13n / missing_positive.py
Created August 12, 2023 09:43
Eif sein Problem
from typing import List
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
return 0
if __name__ == '__main__':
assert Solution().firstMissingPositive([2,1,0]) == 3
@M0r13n
M0r13n / hashcash.py
Last active December 30, 2023 11:28
Yet anonther Hascash implementation in modern Python 3
import base64
import datetime
import hashlib
import string
import random
YYMMDDhhmm = '%y%m%d%H%M'
YYMMDDhhmmss = '%y%m%d%H%M%S'
ASCII_LETTERS = string.ascii_letters