Skip to content

Instantly share code, notes, and snippets.

View data-henrik's full-sized avatar

Henrik Loeser data-henrik

View GitHub Profile
@data-henrik
data-henrik / IBMCloud-AppID-OIDC-Flask.py
Created June 6, 2018 13:16
Use IBM Cloud App ID with OpenID Connect client in Python Flask app
# for full example visit https://github.com/IBM-Cloud/github-traffic-stats/blob/master/backend/ghstats.py
# as part of this tutorial: https://console.bluemix.net/docs/tutorials/serverless-github-traffic-analytics.html
# import all kinds of modules
# this one is needed for the OIDC client
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
# initialize Flask, etc.
@data-henrik
data-henrik / deployToKeyProtect.sh
Created April 6, 2020 10:41
Create new key in IBM Cloud Key Protect from JSON object with credentials
#!/bin/bash
#
# Obtain the necessary credentials from environment, encode them
# as base64 JSON and upload them a new key to IBM Cloud Key Protect
#
# The following software is used:
# - base64
# - ibmcloud: IBM Cloud CLI with Key Protect (kp) plugin
@data-henrik
data-henrik / 0intro.md
Last active November 25, 2022 01:36
SQL statements to dig into COVID-19 data

Introduction

Let's assume a simple schema consisting of two tables.

  1. STATISTICS for COVID-19 daily statistics like confirmed cases, deaths, etc.
  2. DEMOGRAPHICS with addition per-country data like population, area, population density and more

STATISTICS

This table could have columns such as

  • country_id: Identifies the country by ISO code
@data-henrik
data-henrik / download_from_notebook.py
Last active June 6, 2023 12:51
Python snippet to download pandas Data Frame as CSV or Excel from notebook in IBM Watson Studio
# Define functions to download as CSV or Excel
from IPython.display import HTML
import pandas as pd
import base64, io
# Download as CSV: data frame, optional title and filename
def create_download_link_csv(df, title = "Download CSV file", filename = "data.csv"):
# generate in-memory CSV, then base64-encode it
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode())