Skip to content

Instantly share code, notes, and snippets.

View eliasdorneles's full-sized avatar

Elias Dorneles eliasdorneles

View GitHub Profile
@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 / graph_coloring.py
Last active August 1, 2021 12:44
Basic implementation of graph coloring
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# INSTRUCTIONS:
#
# 1) Install graphviz (http://www.graphviz.org)
# 2) Run on terminal:
# python graph_coloring.py | dot -Tpng -o graph.png
# or, if you have imagemagick installed:
# python graph_coloring.py | dot -Tpng | display
@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 / play_notes.py
Last active May 14, 2020 01:55
Playing notes with sox
import subprocess
import time
def wait(seconds):
time.sleep(seconds)
def play_note(note='C', duration=4, delay=0):
# requires sox to be installed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Cookiecutter PyPackage development tasks
"""
# To add a task, create a function with name starting with 'do_' that
# receives one argument (the parsed cmdline arguments object).
# Use a short docstring to serve as help.
#
# Example:
#
@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', ''),
]