This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| dbus-send --session --dest=com.example.HelloService \ | |
| --type=method_call --print-reply \ | |
| /com/example/HelloService org.freedesktop.DBus.Introspectable.Introspect | |
| dbus-send --session --dest=com.example.HelloService \ | |
| --type=method_call --print-reply \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, request, jsonify | |
| from datetime import datetime | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def root(): | |
| return jsonify({ | |
| 'message': 'Welcome to the Hello Service', | |
| 'endpoints': { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import curses | |
| import time | |
| def main(stdscr): | |
| # Turn off cursor blinking | |
| curses.curs_set(0) | |
| # Color pair definitions | |
| curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) | |
| curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from http.server import BaseHTTPRequestHandler, HTTPServer | |
| import urllib.parse | |
| class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): | |
| def do_GET(self): | |
| # Parse the query parameters from the URL | |
| parsed_path = urllib.parse.urlparse(self.path) | |
| query_params = urllib.parse.parse_qs(parsed_path.query) | |
| # Extract the 'code' parameter if it exists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| def application(environ, start_response): | |
| # Get the wsgi.input stream | |
| input_stream = environ['wsgi.input'] | |
| # Create a subprocess | |
| process = subprocess.Popen( | |
| ['some_command'], # Replace with your command | |
| stdin=subprocess.PIPE, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def extended_euclidean(a, b): | |
| if a == 0: | |
| return b, 0, 1 | |
| else: | |
| g, x, y = extended_euclidean(b % a, a) | |
| return g, y - (b // a) * x, x | |
| def chinese_remainder(n, a): | |
| sum = 0 | |
| prod = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import xml.etree.ElementTree as ET | |
| from typing import List, Dict, Tuple | |
| import sys | |
| class OSMtoSVGConverter: | |
| def __init__(self): | |
| self.nodes: Dict[str, Tuple] = {} | |
| self.ways: List[List[Tuple]] = [] | |
| self.min_lat = float('inf') | |
| self.max_lat = float('-inf') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # cleans bash history | |
| # generated with Claude on March 2025 | |
| # does not work out of the box | |
| import os | |
| import re | |
| import shutil | |
| import argparse | |
| from datetime import datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| # resolve names over DNS-over-HTTPS port 443 (google server by default) | |
| import requests | |
| import json | |
| import sys | |
| def resolve_dns_over_https(domain, dns_type="A"): | |
| """ | |
| Perform DNS resolution using Google's DNS-over-HTTPS service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| # small python script to concatenate pictures as jpg files into a PDF of the same size | |
| # Nov 2024, chatgpt | |
| # pip3 install reportlab | |
| import os | |
| from PIL import Image | |
| from reportlab.pdfgen import canvas | |
| import sys |