Skip to content

Instantly share code, notes, and snippets.

@sukram42
sukram42 / nifi.executescript.DMCS.py
Last active August 31, 2021 07:17
NiFi Execute Processor -> Access Distributed Map Cache Server
'''
Script to put and get values from a distributed map cache in APACHE NIFI.
Only works when the id of the Distributed map cache client service is put into a property called "clientServiceId".
Sources:
https://www.javadoc.io/doc/org.apache.nifi/nifi-distributed-cache-client-service-api/1.7.0/org/apache/nifi/distributed/cache/client/AtomicDistributedMapCacheClient.html
https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-3/ta-p/249148
'''
import json
@sukram42
sukram42 / custom_font_matplotlib.py
Created April 30, 2021 22:36
[Python] Add Custom Font to Matplotlib
# Import Libraries
import matplotlib.font_manager as font_manager
import urllib.request
from tempfile import NamedTemporaryFile
def download_font(url: str, ttf_file: str, github: bool=True):
# Download the Font
font_url = f"{url}{ttf_file}{'?raw=true' if github else ''}"
urllib.request.urlretrieve(font_url, ttf_file)