Skip to content

Instantly share code, notes, and snippets.

View davidhuser's full-sized avatar

David Huser davidhuser

  • Lucerne University of Applied Sciences
  • Switzerland
  • 06:48 (UTC +01:00)
View GitHub Profile
import requests, json
base_url = "https://play.dhis2.org/dev"
username = "admin"
password = "district"
programs = [
"kla3mAPgvCH"
]
@davidhuser
davidhuser / events-deleter.py
Created March 29, 2018 17:55
DHIS2 events deletion
import requests
events = [
"xmqrawVQZez",
"I7yG1WFoZxF"
]
url = "https://play.dhis2.org/2.28"
username = "admin"
password = "district"
#!/bin/bash
find . -type f -name '*.flac' | while read fn; do
echo "$fn"
flac -ds --force-aiff-format --delete-input-file "$fn"
done;
@davidhuser
davidhuser / flac-to-wav.sh
Last active July 15, 2017 16:14
Flac to WAV, recursive, unpacking ZIPs
#!/bin/bash
# Flac to WAV with option recursive, unpack zips first
echo "$PWD"
read -rp "Recursive? y/n - " recursive
for f in $(find . -type f -name '*.zip')
do
#!/bin/bash
# Flac to MP3 with option recursive, unpack zips first
echo "$PWD"
read -rp "Recursive? y/n - " recursive
for f in $(find . -type f -name '*.zip')
do
@davidhuser
davidhuser / indicator-regexes.py
Created March 23, 2017 09:58
dhis2 indicator UID regexes
def find_dataelements(definition):
out = re.compile('[a-zA-Z]{1}[a-zA-Z0-9]{10}\.').findall(definition)
return [e[:-1] for e in out]
def find_catcombos(definition):
out = re.compile('\.[a-zA-Z]{1}[a-zA-Z0-9]{10}\}').findall(definition)
return [e[:-1][1:] for e in out]
def find_oug(definition):
out = re.compile('\OUG{[a-zA-Z]{1}[a-zA-Z0-9]{10}\}').findall(definition)
@davidhuser
davidhuser / swiss_esr_checkdigit_calculation.js
Created November 4, 2016 11:10
Swiss ESR Checkdigit calculation (Prüfziffer)
// calculates the checkdigit number of Swiss Invoice codes
function calc_digit(number) {
var table = [0, 9, 4, 6, 8, 2, 7, 1, 3, 5];
var uebertrag = 0;
for (var i = 0; i < number.length; i++) {
c = parseInt(number.substring(i, i + 1), 10);
index = (uebertrag + c) % 10;
@davidhuser
davidhuser / XML_breaker.py
Created June 16, 2016 14:52 — forked from nicwolff/XML_breaker.py
Python script to break large XML files
import os
import sys
from xml.sax import parse
from xml.sax.saxutils import XMLGenerator
class CycleFile(object):
def __init__(self, filename):
self.basename, self.ext = os.path.splitext(filename)
self.index = 0
@davidhuser
davidhuser / log_test12.py
Created January 22, 2016 13:10 — forked from asfaltboy/log_test12.py
Test harness for the logging module. Tests BufferingSMTPHandler, an alternative implementation SMTPHandler. This fork includes credential and secure support (as implemented in newer versions of logging library). Additionaly a flood check is implemented to make sure not more than capacity per minute is sent, otherwise the capacity (buffer) is rai…
#!/usr/bin/env python
#
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution