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
import datetime | |
class ServiceYear(): | |
''' | |
A year which runs from Sept to Aug. | |
Accepts a year in any format which can be converted to an integer. | |
>>> year = ServiceYear(2021) |
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
import pandas | |
def get_service_year(date): | |
''' | |
Return service year for given date. | |
The service year runs from Sept to Aug and Sept-Dec are in the service year of | |
the following calendar year. In other words, the date 2020-09 will return 2021. | |
Accepts date as an ISO formatted string (for example YYYY-MM), a datetime.date |
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
foo: !ENV FOO | |
bar: !ENV [BAR] | |
baz: !ENV [BAZ, ~] | |
fbb: !ENV [FOO, BAR, BAZ, ~] |
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
# Unforunately, the tag can't be a standalone item by itelf. | |
# After all, the following document is invalid: | |
# foo | |
# a: bar | |
# Therefore the tag needs to fit in with the structure of the document. | |
# I have used a null key and then discard it in the loader | |
# so that it is not in the final output. | |
null: !inherit parent.yml |
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
import markdown | |
src = """ | |
<div><p markdown="1">Hello _World!_</p></div> | |
""" | |
md = markdown.Markdown(extensions=['md_in_html']) | |
print('Doc: ', '\n'.join(md.preprocessors['html_block'].run(src.split('\n')))) | |
print('Stash: ', md.htmlStash.rawHtmlBlocks) | |
md.htmlStash.reset() | |
print('Ouput: ', '\n---------------------\n' + md.convert(src) + '\n---------------------') |
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/local/bin/python3 | |
# <bitbar.title>GitHub Notifier</bitbar.title> | |
# <bitbar.version>v1.0</bitbar.version> | |
# <bitbar.author>Waylan Limberg</bitbar.author> | |
# <bitbar.author.github>waylan</bitbar.author.github> | |
# <bitbar.desc>Display a list of unread GitHub Notifications.</bitbar.desc> | |
# <bitbar.image>https://github.com/primer/octicons</bitbar.image> | |
# <bitbar.dependencies>python,agithub</bitbar.dependencies> | |
# <bitbar.abouturl>http://url-to-about.com/</bitbar.abouturl> |
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
from mistune import create_markdown | |
from mistune.renderers import BaseRenderer | |
import re | |
ESCAPE_CHAR = re.compile(r'(?<!\\)([\\`*_()\[\]#+-])') | |
UL_BULLET = re.compile(r'(?<=^)(\*)( +)', re.MULTILINE) | |
def indent(text, level, tab_length=4): | |
''' Indent block of text by level ''' |
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
try: | |
import HTMLParser as parser | |
except ImportError: | |
from html import parser | |
class TestParser(parser.HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
print ("STAG:", tag) |
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
import pandas as pd | |
# "W-SUN" for Monday to Sunday week. Use "W-SAT" for Sunday to Saturday... | |
date_range = pd.period_range('1/1/2019', '12/31/2019', freq='W-SUN') | |
""" | |
>>> date_range | |
PeriodIndex(['2018-12-31/2019-01-06', '2019-01-07/2019-01-13', | |
'2019-01-14/2019-01-20', '2019-01-21/2019-01-27', | |
... |
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 | |
# From http://www.leancrew.com/all-this/2013/03/combining-python-and-applescript/ | |
# Updated for Python 3 | |
import subprocess | |
def asrun(ascript): | |
"Run the given AppleScript and return the standard output and error." |