Skip to content

Instantly share code, notes, and snippets.

@elbosso
elbosso / setupscreenconkx.sh
Last active February 23, 2023 11:58
This script installs and configures a few applications and services - in particular it sets up gnu screen and conky in a way to provide a nice bottom line complete with tabs for the open windows and some information about system health
#!/bin/bash
######################################################################
# This script sets up gnu screen and conky in a way to provide a nice
# footer line complete with tabs for the open windows and some
# information about the systems health
# (https://elbosso.github.io/gnu_screen_sitzung_wenig_aufgepeppt.html#content)
#
# If run as sudo (or root) it tries to install gnu screen and conky
# (needed) and joe (my own preference) before writing a customized
# version of .screenrc and a customized version of a conky config.
@elbosso
elbosso / bootstrap_gui_container.sh
Last active August 18, 2019 06:39
A script to bootstrap a (LXC) gui container
#!/bin/bash
source config_bootstrap_gui_container.sh
# the file config_bootstrap_gui_container.sh should reside in the directory this script is in
# it should contain the statements for setting the following environment variables:
# CONTAINER_NAME=<container name for new container to be created>
# CONTAINER_USER=<user name for main user inside the new container - has sudoer rights!
# CONTAINER_NAMESERVER=<name server address - just leave it out if you dont need a custom one - but remember to also remove the customization of /etc/resolv.conf further down...>
# or you could just uncomment the above lines and adjust them to your liking and comment out the source statement
lxc-create -t download -n "$CONTAINER_NAME" -- -d ubuntu -r bionic -a amd64
# joe .local/share/lxc/"$CONTAINER_NAME"/config
@elbosso
elbosso / openIssuesByComponent.sh
Last active August 18, 2019 06:37
Shell script for using with telegraf exec input - writing number of open gitlab issues per label
#!/bin/bash
#https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
@elbosso
elbosso / gitlab_issues_intervals.py
Created January 12, 2019 11:34
This is another take on dynamic badges in gitlab - this time it shows ways of counting issues for specific time intervals (see also https://gist.github.com/elbosso/6637702612991bb454d205d936dd04dc and https://gist.github.com/elbosso/cbce113805735478e926c28a9079cede)
from anybadge import Badge
from urlparse import parse_qs
import datetime
import gitlab
def index(req):
#change the next two lines to accomodate your installation
url='http://<gitlab.host>'
token='xxxx-xxxx-xxxxxxxxxx'
args=req.args
@elbosso
elbosso / badges_flask.py
Created January 6, 2019 16:38
This is yet another followup re: dynamic badges in gitlab - its predecessor is here: https://gist.github.com/elbosso/cbce113805735478e926c28a9079cede This time we use flask to be more flexible with more deployment options - also it's fun!
from flask import Flask
from flask import make_response
import requests
from anybadge import Badge
from flask import request
app = Flask(__name__)
@app.route("/open/<int:projid>")
def openIssues(projid):
@elbosso
elbosso / gitlab_issues_request.py
Created January 6, 2019 07:54
This is another followup to the Gist https://gist.github.com/elbosso/4f3bb0fb95dd1dc499cd46db422900bf (the other one can be found here https://gist.github.com/elbosso/e160341d5e00e0a726ff8725af560373): We do want the operation count(items in gitlab) to execute in constant time independently from the actual number of items - we do not want to spa…
from anybadge import Badge
from urlparse import parse_qs
import requests
def index(req):
args=req.args
lbl='n/a'
action='closedissues'
projid=None
if args != None:
@elbosso
elbosso / gitlab_issues_curl.py
Created January 6, 2019 07:27
This is a followup to the Gist https://gist.github.com/elbosso/4f3bb0fb95dd1dc499cd46db422900bf - gitlab-python does not expose the header X:Total when listing items - so the response of this is noticeably slow from about 100 items upward. The shell approach demonstrated here works in constant time - regardless of the number of items queried
from anybadge import Badge
from urlparse import parse_qs
from subprocess import Popen,PIPE,STDOUT,call
def index(req):
args=req.args
lbl='n/a'
action='closedissues'
projid=None
if args != None:
@elbosso
elbosso / gitlab_issues.py
Created January 5, 2019 13:32
This is an inspiration concerning truly dynamic gitlab badges - install it onto an apache2 webserver with mod python and enjoy badges telling how many issues are open/closed right now - accurate with every reload of the page!
from anybadge import Badge
import gitlab
from urlparse import parse_qs
def index(req):
#change the next two lines to accomodate your installation
url='http://myhost'
token='xxxx-xxxx-xxxxxxxxxx'
args=req.args
lbl='n/a'
/*
Copyright (c) 2012-2018.
Juergen Key. Alle Rechte vorbehalten.
Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form,
mit oder ohne Veraenderung, sind unter den folgenden Bedingungen zulaessig:
1. Weiterverbreitete nichtkompilierte Exemplare muessen das obige Copyright,
die Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext
/*
Juergen Key. Alle Rechte vorbehalten.
Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form,
mit oder ohne Veraenderung, sind unter den folgenden Bedingungen zulaessig:
1. Weiterverbreitete nichtkompilierte Exemplare muessen das obige Copyright,
die Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext
enthalten.
2. Weiterverbreitete kompilierte Exemplare muessen das obige Copyright,