Category: Uncategorized

Robust sync between Android phone and Linux computer

I already tried quite a few methods to reliably sync data (e.g. backups) between my Android phone and a Linux computer. Most were not good, some were horrible (MTP…). I just tried one that has proven to be the best, by far: installing an SSH server on the phone and then syncing with rsync. I Read More

Django DetailView with pagination for related objects

This is an example of a DetailView of a User that can have a paginated list of Purchases: from django.views.generic.detail import DetailView from django.core import paginator @method_decorator(staff_member_required(login_url=’user_login’), name=’dispatch’) class UserDetailView(DetailView): model = User template_name = “user_detail.html” purchases_paginate_by = 5 def get_context_data(self, **kwargs): context = super(UserDetailView, self).get_context_data(**kwargs) purchases_page = self.request.GET.get(“purchases_page”) purchases = self.object.get_purchases().filter() purchases_paginator = paginator.Paginator(purchases, Read More

Export object_list of a django-filters FilterView to CSV

This is a simple way to allow users to export the data they have just filtered using django-filter as CSV. # Normal View (has a link to export view and keeps GET parameters) @method_decorator(staff_member_required(login_url=’user_login’), name=’dispatch’) class PaymentListView(FilterView): filterset_class = filters.PaymentFilter template_name = “barsys/userarea/payment_list.html” paginate_by = 10 # Export View @method_decorator(staff_member_required(login_url=’user_login’), name=’dispatch’) class PaymentExportView(FilterView): filterset_class = filters.PaymentFilter Read More

Running multiple Django projects on one Apache instance with mod_wsgi

I did not yet find a page with a concise but complete description of how to run multiple Django instances/projects on one server with Apache. This method is similar to the one in the Django docs, but the docs version does not run the Django instance in a daemon process, therefore it does not work Read More

Analytical convolution integral (Analytische Faltung) with Matlab and Maple

With \sigma(t) = Heaviside(t) and \delta(t) = Dirac(t)
Function 1 (e.g. input signal/Eingangssignal):
u(t) = \sigma(t-1) - \sigma(t-4)

Function 2 (e.g. impulse response/Stoßantwort):
g(t) = -\frac{1}{RC}\exp(-\frac{t}{RC})\sigma(t) + \delta(t)

Read More

Automatically convert videos in Powerpoint file (pptx) to a different format

I have been trying to convert a lot of embedded videos in pptx files to a different format lately due to compatibility issues on some systems, but have not found an easy and fast way – so I wrote this bash script.

The goal was to have a pptx with videos that can be played using Powerpoint 2010 or later on Windows as well as OS X without plugins. That seems to only be the case for MPG videos (mpeg1video codec).

To convert videos in a presentation

  1. make sure that ffmpeg and a zip/unzip application is installed (ffmpeg can easily be replaced by avconv, but avconv somehow could not convert some files that were no problem for ffmpeg during my tests)
  2. download the bash file and make it executable
  3. edit the options at the beginning of the file, if you want to (mainly video output format and bitrate)
  4. Change to the directory with the pptx file(s) and start the conversion with /path/to/ myPresentation.pptx
  5. Check if everything worked by looking at myPresentation_converted.pptx  or the logs

Read More

3D printed Arduino Nano case

I put a a practical Arduino Nano case on Thingiverse.

It can be downloaded here:

Read More

Oneplus One touchscreen bug fix

There is a very common touchscreen bug with the Oneplus One that can only be partly/temporarily fixed by a reboot and shows in several ways:

  • Touchscreen less responsive at all times
  • Touches are often not recognized (apparently triggered by heat)
  • Ghost touches (apparently triggered by heat)

Although this seems to be in some way related to the hardware (because I could easily reproduce it by making it warmer), a new touchscreen firmware was published recently in the CyanogenMod 12.1 repository that seems to work arround the problem somehow. I can attest that installing the new firmware fixed the problem on two Oneplus Ones that I tried it on. Battery life is noticably worse though, but this is said to be fixed with some changes that were committed to the CM12.1 repository on June 2.

Read More

Simple LDAP server as authentication back end / Single sign-on on Ubuntu 14.04

I have wanted to create an LDAP server as authentication back end for a small student association that I am in for quite some time, but I did not do it yet because of the administrative chaos that LDAP servers seemed to be. I did not find a good ressource which described the best and simplest solution for a simple use case:

  • Create, change and delete user accounts
  • Have several, easily-managable groups
  • Have easily-integrated interfaces for different services (e.g. Dokuwiki)

Most of the tutorials I found seemed overly-complicated, and I did not want to leave an administrative mess for the next person who has to manage the system.

The following (German) blog post described the process in very easy terms. I set up a working LDAP server with OpenLDAP in under one hour (including some testing I did that was not in the tutorial):

I followed the tutorial until “LDAP Samba Implementierung” and had no problems under a virtualized Ubuntu 14.04 LTS server (not on a Raspberry Pi).

Read More

Automatically reboot TP-Link router WDR4300 / N750 with bash script

I wanted to reboot some TP-Link WDR4300 routers automatically, because the TP-Link firmware is rather buggy and often causes WLAN problems after a few days of use.
Sadly, rebooting those routers with current firmwares is not quite as easy as it used to be (simple and short one-line curl call). You first have to generate a cookie with the name ‘Authorization’ and value

urlencode(Basic base64($admin:md5($password)))

(pseudocode). And then you have to extract some kind of one-time key from the post-login page to get the actual HTTP address of the reboot page (http://$IP/$KEY/userRpm/SysRebootRpm.htm?Reboot=Reboot ). Did I mention you also have to set your HTTP referer to the reboot page?

Read More

1 2 3