Skip to content

Instantly share code, notes, and snippets.

View sgibson91's full-sized avatar

Sarah Gibson sgibson91

View GitHub Profile
@sgibson91
sgibson91 / .pre-commit-config.yaml
Last active January 3, 2023 16:46
Short Python script to calculate the number of working hours in a month, account for public holidays *in England*. (Could be edited for other locales though(
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: pyupgrade
args:
- "--py36-plus"
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
@sgibson91
sgibson91 / README.md
Last active August 6, 2021 16:06
Testing pytest exposing params

Test pytest exposing params

Running the following command:

pytest -q --secret-input SUPER_SECRET_VALUE

produces the following output

#!/bin/bash
# Get this script's path
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Read config.json and get BinderHub name
configFile="${DIR}/config.json"
AKS_RESOURCE_GROUP=$(jq -r '.azure .res_grp_name' "${configFile}")
RESOURCE_GROUP_LOCATION=$(jq -r '.azure .location' "${configFile}")
BINDERHUB_NAME=$(jq -r '.binderhub .name' "${configFile}")
@sgibson91
sgibson91 / update_pr_base.py
Last active June 25, 2020 21:17
Use the GitHub API to update the base branch of open Pull Requests
"""
Script to pull a list of open Pull Requests for a GitHub repository and change
the base branch using the GitHub API. For this script to run successfully, you
must have write access to the target repository. If the repository belongs to
an organisation, then you must be a member of that organisation with write
access.
This script requires a GitHub Personal Access Token. To update Pull Requests in
public repos, the token only needs the `public_repo` scope. To update Pull
Requests in private repos, the token needs the full `repo` scope.
@sgibson91
sgibson91 / choose_competition_winner.py
Created April 1, 2020 18:10
A python script to generate a competition winner from an input file of entries (one entry per line)
#!/usr/bin/env python
import argparse
import numpy as np
def parse_args():
"""Construct the command line arguments
Returns:
args -- Parsed arguments
{% extends "templates/page.html" %}
{% block login_widget %}{% endblock %}
@sgibson91
sgibson91 / login.html
Created November 28, 2019 21:11
Login template
{% extends "templates/login.html" %}
{% block site %}
<div id="ipython-main-app" class="container">
<h1>Binder inaccessible</h1>
<h2>
You can get a new Binder for this repo by clicking <a href="{{binder_url}}">here</a>.
</h2>
<p>
The shareable URL for this repo is: <tt>{{binder_url}}</tt>
@sgibson91
sgibson91 / _helper.tpl
Created November 28, 2019 21:10
cert-manager helpers file
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "hub23-chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
@sgibson91
sgibson91 / user-configmap.yaml
Created November 28, 2019 21:09
cert-manager user-configmap file
kind: ConfigMap
apiVersion: v1
metadata:
name: user-etc-jupyter
labels:
app: jupyterhub
component: etc-jupyter
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
@sgibson91
sgibson91 / clusterissuer.yaml
Created November 28, 2019 21:08
cert-manager cluster issuer config file
---
apiVersion: certmanager.k8s.io/v1alpha1
kind: ClusterIssuer
metadata:
name: prod
labels:
helm.sh/chart: {{ include "hub23-chart.chart" . }}
app.kubernetes.io/name: {{ include "hub23-chart.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}