This file contains hidden or 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 reportlab.platypus import SimpleDocTemplate, Flowable, Paragraph | |
from reportlab.lib.styles import getSampleStyleSheet | |
style = getSampleStyleSheet()['BodyText'] | |
class TextField(Flowable): | |
def __init__(self, **options): | |
Flowable.__init__(self) |
This file contains hidden or 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 | |
from xhtml2pdf import pisa | |
from datetime import date | |
TEMPLATE = """ | |
<html> | |
<head> | |
<style> | |
@page {{ | |
size: letter portrait; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |