Skip to content

Instantly share code, notes, and snippets.

View metaodi's full-sized avatar

Stefan Oderbolz metaodi

View GitHub Profile
@metaodi
metaodi / oauth_backend.py
Created January 15, 2024 11:02
This script shows how to authenticate with OAuth2 with a backend application (token is saved on disk and then reused)
# This script shows how to authenticate with OAuth2 with a backend application
# The token is saved to disk in $HOME/.osmapi/token.json and can be reused until it's revoked or expired.
# install oauthlib for requests: pip install oauthlib requests-oauthlib
from requests_oauthlib import OAuth2Session
import json
import webbrowser
import osmapi
from dotenv import load_dotenv, find_dotenv
import os
@metaodi
metaodi / E3-Improver.user.js
Last active April 9, 2024 05:37
A user script to improve the E3 experience
// ==UserScript==
// @name E3 Improver
// @namespace https://metaodi.ch
// @version 0.28
// @description Make E3 even better :)
// @author Stefan Oderbolz
// @match https://e3online.prd.szh.loc/
// @icon https://www.google.com/s2/favicons?sz=64&domain=szh.loc
// @grant GM_setValue
// @grant GM_getValue
@metaodi
metaodi / outlier_iqr.sas
Created September 24, 2019 10:57
A SAS program to detect outliers using IQR (interquartile range)
/* Caluculate quartiles to get limits */
proc univariate data=work.ZaehlstelleZeit_&num. noprint;
var AnzFahrzeuge;
output out=work.ZaehlstelleStat_&num. p25=q1 p75=q3;
run;
data work.ZaehlstelleStat_&num.;
set work.ZaehlstelleStat_#
ZSID = "&name";
iqr = q3 - q1;
@metaodi
metaodi / README.md
Created September 27, 2016 13:07
t936

README is empty

@metaodi
metaodi / examples.py
Last active February 5, 2016 12:52
Python Summit 2016
# Named regex groups
import re
sentence = "\"The Hitchhiker's Guide to the Galaxy\" was published in 1979"
regex = "\"([\w ']+)\" was published in (\S+)"
print "find_all: %s"%(re.findall(regex, sentence))
match = re.search("\"(?P<book>[\w ']+)\" was published in (?P<year>\S+)", sentence)
print "match groups: %s"%(str(match.groups()))
print "match group1: %s"%(str(match.group(1)))
@metaodi
metaodi / create_and_apply_dump.sh
Created January 4, 2016 10:16
DB dump of WordPress
# create a new DB dump
mysqldump -u USERNAME -p --skip-extended-insert --skip-quick DB_NAME > dump.sql
# replace the domain name in the dump, this is needed if you plan to use the dump on another domain
sed 's/www\.example\.com/stage.example.com/g' < dump.sql > updated_dump.sql
# optional: re-create the database
mysql -u root -e"show databases;" | grep DB_NAME && mysql -u root -e"drop database DB_NAME;"
mysql -u root -e"create database DB_NAME;"
@metaodi
metaodi / remove-text-rendering.user.js
Last active November 10, 2015 08:29
Remove text-rending to fix Chromium 45 bug
// ==UserScript==
// @name Remove text-rending to fix Chromium 45 bug
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://gitlab.liip.ch
// @grant none
// ==/UserScript==
/* jshint -W097 */
// ==UserScript==
// @name Tabs to spaces for GitLab
// @namespace http://liip.ch/
// @version 0.1
// @description Fix tab bug of GitLab/Chromium 45 (https://gitlab.com/gitlab-org/gitlab-ce/issues/3220)
// @author Odi
// @match https://gitlab.liip.ch/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
@metaodi
metaodi / gist:432f4988974240bad101
Created July 7, 2015 12:53
Story Point Count in Confluence when using the Jira macro
<div id="count-1"></div>
<script>
window.setTimeout(function() {
var sum = 0;
$('table:eq(0) tr[class^="row"]').each(function() {
storyPoint = jQuery(this).find("td:eq(4)");
value = parseInt(storyPoint.text());
if (! isNaN(value)) {
sum += value;
}
@metaodi
metaodi / vagrant-status
Created May 31, 2015 22:05
Status of all local vagrant boxes
#!/bin/bash
root_dir="$HOME"
if [ -n "$1" ] ; then
root_dir=$1
fi
for vdir in `find $root_dir -name .vagrant -type d 2>/dev/null`; do
cd $vdir
cd ..
vtext=`vagrant status 2>/dev/null | awk '{$1=""; print $0}' | sed 's/^ //g' | grep 'virtualbox' | GREP_COLOR="2;32" egrep --color=always "(not created|poweroff)"`
if [ -z "$vtext" ] ; then