Skip to content

Instantly share code, notes, and snippets.

Avatar

Elias Dorneles eliasdorneles

View GitHub Profile
@eliasdorneles
eliasdorneles / example.py
Last active Jan 19, 2022
Stackoverflow Example
View example.py
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 Jun 16, 2020
Alternative Option Parsing for Pudb
View pudb_options_mockup.py
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 Jun 16, 2020
Testing argparse partial parsing
View argparse_test_script.py
#!/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 Jun 1, 2020
Calculate offsets for scrolling piano sheet music
View partoche_calc_offsets.py
#!/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 Sep 11, 2019
Minimal example handling click in the terminal with Urwid
View urwid_click_example.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division
import urwid
PALETTE = [
('bold', 'bold', ''),
]
@eliasdorneles
eliasdorneles / plot_event_times.py
Last active May 27, 2019
Script to plot event times from a log quickly
View plot_event_times.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Plot events over a time axis
"""
# Relies on matplotlib and dateutil
from __future__ import print_function, absolute_import, division
import sys
import dateutil.parser
import datetime
@eliasdorneles
eliasdorneles / urwid_master_detail.py
Last active Sep 4, 2018
Sample implementation of Master-Detail UI problem for the console using urwid, written to answer an SO question: https://stackoverflow.com/a/52174629/149872
View urwid_master_detail.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Sample program demonstrating how to implement widgets for a master-detail UI
for a list of records using the urwid library (http://urwid.org)
"""
from __future__ import print_function, absolute_import, division
from functools import partial
import urwid
View voc-stdlib-support-status.html
<html>
<head>
<title>VOC stdlib modules status</title>
<style>
body {
font: 1.2em "Open Sans", sans-serif;
}
.td {
padding: 2px 0;
border: 1px solid #444;
@eliasdorneles
eliasdorneles / runspider.sh
Last active Apr 20, 2018
Script to run spider, saving log output and stuff
View runspider.sh
#!/bin/bash
set -e
abort() {
echo "$*"; exit 1;
}
usage() {
echo $*
View diff-after-compile-and-run.sh
#!/bin/bash
# This script assumes you're using the directory layout described in the
# documentation at: https://voc.readthedocs.io/en/latest/tutorials/tutorial-0.html
set -e
#set -x
abort() {
echo "$*"; exit 1;
}