Skip to content

Instantly share code, notes, and snippets.

View MartinThoma's full-sized avatar

Martin Thoma MartinThoma

View GitHub Profile
from dataclasses import dataclass
@dataclass
class Point:
x: float
y: float
@dataclass
class Line:
from PIL import Image, ImageDraw # pip install pillow for PIL
# Define the canvas size
width = 1500
height = 500
im = Image.new("RGB", (width, height), (255, 255, 255))
draw = ImageDraw.Draw(im)
# Draw a single line
x1, y1 = 10, 20
.github/workflows/build.yml
00_Alternate_Languages/41_Guess/rust/Cargo.toml
00_Alternate_Languages/48_High_IQ/d/highiq.d
00_Alternate_Languages/57_Literature_Quiz/javascript/literature-quiz-node.mjs
00_Alternate_Languages/59_Lunar_LEM_Rocket/rust/rocket/Cargo.toml
00_Alternate_Languages/60_Mastermind/rust/Cargo.toml
00_Alternate_Languages/65_Nim/rust/Cargo.toml
00_Alternate_Languages/66_Number/rust/Cargo.toml
00_Alternate_Languages/72_Queen/python/.flake8
00_Alternate_Languages/74_Rock_Scissors_Paper/rust/Cargo.toml
from rich.panel import Panel
from textual.app import App
from textual.reactive import Reactive
from textual.widget import Widget
class Hover(Widget):
mouse_over = Reactive(False)
@MartinThoma
MartinThoma / .vimrc
Created April 9, 2013 14:25
My current .vimrc file.
syntax on " enable syntax highlighting
filetype on " enable file type detection
" Set some nice character listings, then activate list
set list listchars=tab:⟶\ ,trail:·,extends:>,precedes:<,nbsp:%
set list
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
from rich.prompt import Prompt, Confirm
is_correct = False
while not is_correct:
name = Prompt.ask("Enter your name", default="Martin")
is_correct = Confirm.ask(f"Is your name '{name}'?")
age = Prompt.ask(
"What is your age group",
choices=["<18", "18-25", "25-35", ">35"],
from rich.tree import Tree
from rich import print
tree = Tree("Life")
prokaryota = tree.add("Prokaryota")
prokaryota.add("Eubacteria")
prokaryota.add("Archaebacteria")
eukaryota = tree.add("Eukaryota")
import typer
from pathlib import Path
from rich.console import Console
from rich.syntax import Syntax
def app(filepath: Path = typer.Option(..., exists=True)):
"""Print a python file."""
with open(filepath, "r") as f:
code = f.read()
import time
from rich.progress import Progress
with Progress() as progress:
task1 = progress.add_task("[red]Downloading...", total=1000)
task2 = progress.add_task("[green]Processing...", total=1000)
task3 = progress.add_task("[cyan]Cooking...", total=1000)
from rich.console import Console
from rich.table import Table
table = Table(title="Star Wars Movies")
table.add_column("Released", justify="right", style="cyan", no_wrap=True)
table.add_column("Title", style="magenta")
table.add_column("Box Office", justify="right", style="green")
table.add_row("Dec 20, 2019", "Star Wars: The Rise of Skywalker", "$952,110,690")