Skip to content

Instantly share code, notes, and snippets.

View wolkenarchitekt's full-sized avatar

Ingo Weinmann wolkenarchitekt

View GitHub Profile
@wolkenarchitekt
wolkenarchitekt / gist:7755f2386e2d04ffcf8ed49644ce67b0
Last active August 18, 2020 13:48
Bash completion to autocomplete all python tests within current project (using pytest)
# This will allow to autocomplete tests in Terminal like this:
$ pytest tests/test_user_management.py::[TAB]
$ pytest tests/test_user_management.py::TestUserManagement[TAB]
$ pytest tests/test_user_management.py::TestUserManagement::test_user_create
# Add command writing fully qualified names of all test functions to a file
# conftest.py:
def pytest_addoption(parser):
parser.addoption(
"--collect-tests",
@wolkenarchitekt
wolkenarchitekt / pytest_django_class_scoped_fixtures.py
Last active February 27, 2020 09:32
Using class scoped fixtures with pytest-django that need DB access
import pytest
from django.contrib.auth.models import User
from django.urls import reverse
from rest_framework.test import APIClient
@pytest.fixture(scope="class")
def user(django_db_setup, django_db_blocker):
with django_db_blocker.unblock():
@wolkenarchitekt
wolkenarchitekt / popm.py
Created November 28, 2019 17:14
Using popularimeter with mediafile
import collections
import mutagen
import six
from mediafile import StorageStyle, MediaField, MediaFile
Popularimeter = collections.namedtuple('Popularimeter', ['rating', 'count'])
class PopmMediaField(MediaField):
def __init__(self, *styles, **kwargs):
@wolkenarchitekt
wolkenarchitekt / Makefile
Last active March 11, 2020 20:55
Makefile config management
SHELL := /bin/bash
PWD = $(shell pwd)
UNAME := $(shell uname)
ARCH := $(shell uname -m)
USER := $(shell echo $$USER)
USERDIR := $(shell echo $$HOME)
# Synology ignores
ifeq ($(UNAME),Linux)
FOLDER := .SynologyDrive/SynologyDrive.app/conf
@wolkenarchitekt
wolkenarchitekt / window_tiler.py
Last active September 17, 2019 10:38
Move window on Linux systems using Python, xdotool and wmctrl
#!/usr/bin/python3.7
#
# Move and resize window into screen corners.
# works with multiple, horizontally aligned displays.
#
# Requirements:
# * Python3.7 (for dataclass)
# * wmctrl
# * xdotool
# pip: screeninfo, click
@wolkenarchitekt
wolkenarchitekt / mkmf.log
Created June 10, 2018 14:49
mkmf.log output of failing mysql2 gem installation
--------------------
have_const: checking for SSL_MODE_REQUIRED in mysql.h... -------------------- yes
"gcc -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -I/usr/include/mysql -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.3-C6gbp8/ruby2.3-2.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <mysql.h>
@wolkenarchitekt
wolkenarchitekt / Dockerfile
Last active June 10, 2018 13:56
Mysql Docker container fails to install native extensions for Sequel
FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install sequel mysql2 sqlite3
RUN mkdir /temp
WORKDIR /temp
#
# Fetches latest MYSQL dump from radio-browser.info, converts it to SQLite.
# Usage:
# docker build -t radiobrowser-converter .
# docker run -v $PWD:/temp -it --rm radiobrowser-converter
#
FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install sequel mysql2 sqlite3
@wolkenarchitekt
wolkenarchitekt / Dockerfile
Created March 4, 2018 13:23
Dockerfile for wav2png
FROM ubuntu:latest
RUN apt-get update --fix-missing
RUN apt-get install -y git make g++ libsndfile1-dev libpng++-dev libpng12-dev libboost-program-options-dev
RUN apt-get install -y libxvidcore4 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-fluendo-mp3 gstreamer1.0-libav
RUN git clone https://github.com/beschulz/wav2png
WORKDIR /wav2png/build
RUN make all
RUN ln -s /wav2png/bin/Linux/wav2png /usr/bin/wav2png
@wolkenarchitekt
wolkenarchitekt / traktor_rating.py
Last active June 29, 2020 06:58
Get/set popularimeter rating ID3 tag for Traktor
# Gets or sets popularimeter ID3 rating tag for Traktor.
# Needs mutagen for ID3 tag manipulation:
# pip install mutagen
import logging
import os
import sys
import click
import mutagen
import mutagen.id3