Skip to content

Instantly share code, notes, and snippets.

@awan1
awan1 / pokemon_toos_to_md.py
Created December 11, 2020 10:37
Python code for converting Daystar Eld's "Pokemon: The Origin of Species" to Markdown
# You'll need to `pip install html2text`
import urllib.request
import html2text
def get_text_from_url(url):
fp = urllib.request.urlopen(url)
url_bytes = fp.read()
url_str = url_bytes.decode("utf8")
@awan1
awan1 / ls_with_ignore_and_print
Last active August 23, 2016 02:56
An improved ls command that can exclude files matching given globs and shows how many of each file were excluded.
###########
## Notes ##
###########
## This shows you how to configure your ls command to not show certain files,
## and tell you how many of those files were omitted. This declutters your ls output.
## To use this, add it to whatever .{profile, alias, rc} file you put your aliases in.
## The ls and find functions here are the GNU variants: the flags needed are not in
## the BSD variant, which is the OSX default.
## So on OSX, you'll need to install GNU ls and GNU find (see http://goo.gl/bDO0ga),
@awan1
awan1 / ask_user_for_selection.py
Last active October 30, 2015 00:08
Ask user to choose from a list of choices via command line
"""
Allows choice of options via command line.
Author: awan1
Date: 20151029
"""
import numpy as np
def ask_user_for_selection(choices, choice_text='options'):
@awan1
awan1 / path_join_check.py
Last active October 30, 2015 00:07
Flexibly check that the result of os.path.join is of a given type.
"""
Wrapper call to os.path.join and os.path.expanduser that checks whether the
returned path is of a given type.
Author: awan1
Date: 20151029
"""
import os