Skip to content

Instantly share code, notes, and snippets.

View eliasdorneles's full-sized avatar

Elias Dorneles eliasdorneles

View GitHub Profile
@eliasdorneles
eliasdorneles / pratt_calc.py
Created August 6, 2024 20:39
Simple calculator demonstrating Pratt parsing
import re
from enum import StrEnum
class TokenType(StrEnum):
PLUS = "PLUS"
MINUS = "MINUS"
MUL = "MUL"
DIV = "DIV"
LPAREN = "LPAREN"
@eliasdorneles
eliasdorneles / awesome_audio_and_music_programmind.md
Last active November 10, 2024 22:22
Awesome Audio and Music Programming Learning Resources
@eliasdorneles
eliasdorneles / pratt_parser.py
Last active July 23, 2024 15:47
A minimal implementation of Pratt parsing
from enum import StrEnum
class TokenType(StrEnum):
PLUS = "PLUS"
MINUS = "MINUS"
MUL = "MUL"
DIV = "DIV"
LPAREN = "LPAREN"
RPAREN = "RPAREN"
@eliasdorneles
eliasdorneles / filter_depth_pyreverse_packages_graph.py
Created January 31, 2024 12:48
Script to filter the packages graph generated by pyreverse on depth
import argparse
import pydot
def should_delete(node_name, max_depth=2):
return node_name.count(".") >= max_depth
def truncate_node_name(node_name, max_depth=2):
return '.'.join(node_name.strip('"').split('.')[:max_depth])
@eliasdorneles
eliasdorneles / sy.md
Created July 4, 2023 16:03 — forked from cornchz/sy.md
Notes from the Mystery Machine Bus - Steve Yegge

Notes from the Mystery Machine Bus

I've spent the past eight years (starting back in June 2004) writing elaborate rants about a bunch of vaguely related software engineering issues.

I was doing all that ranting because I've been genuinely perplexed by a set of "bizarre" world-views held dear by -- as far as I can tell -- about half of all programmers I encounter, whether online or in person.

Last week, after nearly a decade of hurling myself against this problem, I've finally figured it out. I know exactly what's been bothering me.

In today's essay I'm going to present you with a new conceptual framework for thinking about software engineering. This set of ideas I present will be completely obvious to you. You will probably slap yourself for not having thought of it yourself. Or you might slap the person next to you. In fact you probably have thought of it yourself, because it is so blindingly obvious.

@eliasdorneles
eliasdorneles / example.py
Last active January 19, 2022 20:15
Stackoverflow Example
from fastapi import FastAPI, APIRouter, Request
from fastapi.responses import RedirectResponse, HTMLResponse
router = APIRouter()
@router.get('/form')
def form():
return HTMLResponse("""
<html>
@eliasdorneles
eliasdorneles / pudb_options_mockup.py
Created June 16, 2020 22:12
Alternative Option Parsing for Pudb
from __future__ import absolute_import, print_function, division
from collections import namedtuple
import sys
def exit_showing_usage():
print("""Usage: pudb [options] [SCRIPT-TO-RUN|-m MODULE] [ARGUMENTS]
Options:
@eliasdorneles
eliasdorneles / argparse_test_script.py
Created June 16, 2020 20:02
Testing argparse partial parsing
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
def run(options, script_args):
print('options', options, 'script_args', script_args)
@eliasdorneles
eliasdorneles / partoche_calc_offsets.py
Created June 1, 2020 19:37
Calculate offsets for scrolling piano sheet music
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
import itertools
import json
from PIL import Image, ImageFilter
def pairwise(iterable):
@eliasdorneles
eliasdorneles / urwid_click_example.py
Created September 11, 2019 08:29
Minimal example handling click in the terminal with Urwid
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
import urwid
PALETTE = [
('bold', 'bold', ''),
]