Skip to content

Instantly share code, notes, and snippets.

View tolleiv's full-sized avatar

Tolleiv Nietsch tolleiv

  • Bare.ID Gmbh - an AOE Group company
  • Wiesbaden, Deutschland
View GitHub Profile
@tolleiv
tolleiv / go.mod
Last active October 20, 2023 08:09
Small utility to extract used metrics from promql queries
module prom-stat
go 1.21.1
require github.com/prometheus/prometheus v0.47.2
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dennwc/varint v1.0.0 // indirect
apiVersion: v2
actions:
- name: "Run hey"
events:
- name: "sh.keptn.event.test.triggered"
tasks:
- name: "Run hey smoke tests"
image: "tolleiv/rakyll-hey:v0.1.4" # just the official Dockerfile build
cmd:
- /hey
@tolleiv
tolleiv / gist:3c10fc3249afa70218adaa571a3835b5
Last active April 22, 2021 19:40
Amazon Managed Service for Prometheus price calculation
# What's the cost of keeping the top 25 metrics within Amazon Managed Service for Prometheus
# 1 -> amount of samples per minute
count(topk(25, count by (__name__, job)({__name__=~".+"}))) * 1 * 60 * 24 * 1/10000 * 0.002
# What's the cost of keeping all metrics within Amazon Managed Service for Prometheus
# 1 -> amount of samples per minute
count({__name__=~".+"}) * 1 * 60 * 24 * 1/10000 * 0.002
# * Doesn't take into account that it's geeting cheaper beyond 50 billion samples - you'll figure that out
@tolleiv
tolleiv / py.py
Last active February 1, 2021 19:04
Logarithmic regression with historical data - as seen on https://www.youtube.com/watch?v=gYm6OgeJAuE&ab_channel=sentdex
import pandas as pd
import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import matplotlib.cm as mcm
# data prep
df = pd.read_csv('input.csv')
df = df.iloc[::-1]
df = df[df['Value'] > 0]
import UIKit
class CustomPageViewController: UIPageViewController,UIPageViewControllerDataSource,UIPageViewControllerDelegate {
fileprivate lazy var pages: [UIViewController] = {
return [
self.getViewController(withIdentifier: "firstVc"),
self.getViewController(withIdentifier: "secondVc")
]
}()
@tolleiv
tolleiv / cap.py
Last active April 15, 2018 09:14
Fixed syntax and added documentation for the timelapse script from https://reps.cc/?p=85
#!/usr/bin/env python
import numpy as np
import cv2
from skimage.measure import compare_ssim as ssim
import time
# Pick a source - either a file or a (exiting) device
cap = cv2.VideoCapture('/dev/video0')
@tolleiv
tolleiv / ssh_config
Created January 12, 2018 10:19
SSH Config so "ssh ip.aws" uses the right key with the right settings
Host *.aws
IdentityFile ~/.ssh/super-secret-key.pem
User ubuntu
StrictHostKeyChecking no
ProxyCommand nc $(sed -e "s/.aws$//" <<< "%h") %p
#!/bin/sh
SITE=example.org
openssl s_client -connect $SITE:443 > /tmp/cert (edited)
sudo keytool -storepass changeit -import -alias $SITE -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -file /tmp/cert
@tolleiv
tolleiv / letsencrypt_2017.md
Last active November 3, 2017 08:43 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@tolleiv
tolleiv / abort-jenkins-job.groovy
Created July 25, 2017 09:40
Groovy snippet to abort a build without removing it....
Jenkins.instance.getItemByFullName("JobName").getBuildByNumber(JobNumber).finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));