This file contains 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
#!/bin/env python | |
# expects python3 | |
################################################################################ | |
import argparse | |
import socket | |
import sys | |
################################################################################ |
This file contains 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
################################################################################ | |
# Example usage: | |
# $ python | |
# >>> import Progress | |
# >>> total = 100 | |
# >>> message = 'Doing this task ' | |
# >>> with Progress.Bar(total, message) as bar: | |
# ... for n in range(total): | |
# ... time.sleep(0.1) | |
# ... bar.update() |
This file contains 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
############################################################################### | |
# $Author: [email protected] | |
# $Expects: Python version 3.4.3 | |
############################################################################### | |
"""Crawls a given URL and presents a simple sitemap based upon which | |
webpages are found. Each page is given as an individual WebResource | |
with a URL, a title and a list of links within the page. | |
From the command line: |
This file contains 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
''' | |
Basic functions for clearing stdin by checking whether a | |
read will block. | |
''' | |
import select | |
import sys | |
def has_unread_input(stream=sys.stdin, timeout=0): | |
''' |
This file contains 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/python | |
"""Print a swatch using all 256 colors of 256-color-capable terminals.""" | |
__author__ = "Marius Gedminas <[email protected]>" | |
__url__ = "https://gist.github.com/mgedmin/2762225" | |
__version__ = '2.0' | |
def hrun(start, width, padding=0): |
This file contains 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
''' | |
Basic REPL using coroutines. Change the operator or initial state to | |
modify behaviour. Currently input is just accumulated and the whole | |
is printed out each time. | |
Tested on Python 3.4 and higher. Not expected to work with Python 2. | |
Of course, this entire thing could just be replaced with something | |
much less interesting: |
This file contains 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
''' | |
Advent of Code 2023, Day Two, Task 1 | |
See: https://adventofcode.com/2023/day/2 | |
Run: python task.py < input.txt | |
''' | |
from collections import namedtuple | |
import sys | |
This file contains 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 | |
''' | |
schema.py - Generate a schema from a YAML file (or from stdin.) | |
Required: | |
pip install PyYAML | |
Usage: | |
python3 schema.py < PATH | |
python3 schema.py PATH [PATH ...] |