Skip to content

Instantly share code, notes, and snippets.

View consideRatio's full-sized avatar
😍
Open Source

Erik Sundell consideRatio

😍
Open Source
  • Sundell Open Source Consulting AB
  • Sweden
  • X @e_Sundell
View GitHub Profile
# This is a JupyterHub Helm chart (z2jh) configuration file that:
#
# - injects a Python script to /tmp/cleanup-orphaned-pods.py via hub.extraFiles
# - defines a managed JupyterHub service to run the Python script with
# permissions ask the JupyterHub REST API about what users' servers are active
#
# It was developed to help cleanup user server pods that could end up orphaned
# by JupyterHub using KubeSpawner 5.0-6.0 or the z2jh versioned 3.0. For more
# information, visit this forum post:
# https://discourse.jupyter.org/t/how-to-cleanup-orphaned-user-pods-after-bug-in-z2jh-3-0-and-kubespawner-6-0/21677
"""
Check for orphan single-user pods
Compares JupyterHub API list of running servers
to list of running pods in kubernetes
in order to identify discrepancies
see https://github.com/jupyterhub/kubespawner/pull/742
"""
@consideRatio
consideRatio / calculating_profile_list_options.py
Created March 13, 2023 17:20
Script in development used to calculate profile_list request for memory and cpu for `n2-highmem-[4|16|64]` nodes and `r5.[|4|16]xlarge` nodes
"""
This is a basic script that prints shares of CPU/Memory for machines of
different size. The script reads a list of nodes specifications, then prints
node share choices based on how much memory is required.
The mem_guarantee specification is calculated for each node by first subtracting
4 GB of memory for each node. This is to ensure that all nodes retain ~4 GB of
memory.
"""
@consideRatio
consideRatio / feedback.py
Created February 23, 2022 13:28
Feedback på kodexempel
start_over='true'
while start_over == 'true':
print('Mata in')
principle=int(input('Startsumma:'))
rate=float(input('Förmodad ränta per år:'))
time=int(input('Sparhorisont (antal år):'))
real_rate = rate * 0.01
a = 0
@consideRatio
consideRatio / _helpers-randhex.tpl
Last active April 7, 2023 23:06
Helm helper template randHex to generate random hexadecimal (hex, base16) numbers
{{/*
Returns given number of random Hex characters.
In practice, it generates up to 100 randAlphaNum strings
that are filtered from non-hex characters and augmented
to the resulting string that is finally trimmed down.
*/}}
{{- define "jupyterhub.randHex" -}}
{{- $result := "" }}
{{- range $i := until 100 }}
{{- range .Values.netpol.namespaces }}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-egress-to-everything-but-specified-range
namespace: {{ . }}
spec:
# WARNING: targets all pods in the namespace
# If pods were already targetted by a netpol rule, this netpol
@consideRatio
consideRatio / keybase.md
Created April 6, 2018 07:32
keybase.md

Keybase proof

I hereby claim:

  • I am consideratio on github.
  • I am consideratio (https://keybase.io/consideratio) on keybase.
  • I have a public key ASAZwA1TTFukvIa7skAKtmIyz6zKA5b2Fp622Di15dm0ago

To claim this, I am signing this object:

@consideRatio
consideRatio / synonym-api-example.gs
Last active March 26, 2018 12:09
API request example from google sheets
// Use this function from a cell by writing for example getSynonyms("happy")
// TODO: Make the function return the desired amount of available synonyms.
// It is currently being limited, always returning one single synonym.
// Try returning an array of words!
function getSynonyms(word) {
try {
var response = UrlFetchApp.fetch("https://api.datamuse.com/words?rel_syn=" + word);
var data = JSON.parse(response.getContentText());
}
@consideRatio
consideRatio / Lösa idéer
Created April 8, 2015 20:18
Framtida skola
# Läromedel, matte
Växling av språk för matteuppgifterna
Uppläsning av matteuppgifter
Stackoverflow för eleverna kring uppgifterna
Minnesteknisk stöd för översikt
Growth mindset fokus
# UpUnet-S Connectivity script
# 1: Keeps connection alive by continious pinging
# 2: Automatically reconnects to UpUnet-S using provided username/password
# 3: Keep you informed about changes in connectivity to...
# -- Router -> UpUnet-S -> Internet -> DNS Server
# USAGE
# Install coreutils (brew install coreutils)
# Add as a function in your .bash_profile on your UNIX system
# Call by writing: upunet