Skip to main content

Privacy aware webdeveloper in the FOSS universe, part of Starzel.de, founder of Portknox.net (Nextcloud SaaS) and father of a daughter.

Learn more about me. Email me at mail@steffen-lindner.de

starzel.de

portknox.net

gomez

gomezr

 

How to include JS/CSS files from the Create React App into your Nextcloud app

2 min read

React and Nextcloud

I have recently started developing a React app for Nextcloud. After creating the React boilerplate inside my Nextcloud app (in the /src directory) and developing some basic features outside of Nextcloud (just "npm start"), I wanted to get the React part called and included into the Nextcloud app.

As Webpack uses chunk splitting which generates more than one JavaScript file and also adds a hash to the file name for cache resetting, I had problems including it as it is described in the Nextcloud docs. For now my app is not that big so I used this hack to disable chunk splitting in CRA without ejecting.

In the template/index.php i used this PHP code to get the hashed file into app:

/*
 * Uses the manifest file to get the filenames with hash
 * @param  string  $filename
 * @return string
 */
function asset_path($filename) {
	$manifest_path = './apps/portknox_admin/build/asset-manifest.json';
	$ext = pathinfo($filename, PATHINFO_EXTENSION);
	$strip = ($ext == "css") ? -4 : -3;
	if (file_exists($manifest_path)) {
		$manifest = json_decode(file_get_contents($manifest_path), TRUE);
	} else {
		$manifest = [];
	}

	if (array_key_exists($filename, $manifest)) {
		return '../build'. substr($manifest[$filename], 0, $strip);
	}
	return '../build' . substr($filename, 0, $strip);
}


style('portknox_admin', asset_path('main.css'));
script('portknox_admin', asset_path('main.js')); 

Maybe this helps someone, leave a comment if you have improvements or a better way.

 

 

Alben des Jahres 2018

1 min read

  • Florence & The Machine - High as hope
  • Beach House - 7
  • Ben Howard - Noonday Dream
  • Mouse On Mars - Dimensional people
  • Beak> - >>>

 

Portknox Update August

1 min read

I just posted an update on the Portknox blog. If you are a Portknox customer or intressted in Portknox read it over there.

 

Recap of Plonator Sprint

1 min read

I recently joined the Plonator Sprint and helped working on new demosites for Plone. Here is a the german news on plone.de and here you can find the sprint report.

 

I started replacing Supervisor with systemd for Plone sites

1 min read

During the Plonator sprint i have started to replace Supervisor (a process manager) with systemd start/stop scripts.

Right now Supervisor does not work with Python 3 (Supervisor version 4 will work) and it has problems stopping a Zope4 instance (needs more testing).

A systemd script could look like this:

root@xxxy:~# cat /etc/systemd/system/demo-latest.service
[Unit]
Description=demo-latest.plone.de
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/zope/demo-latest.plone.de/
User=zope
Group=zope
ExecStart=/home/zope/demo-latest.plone.de/bin/instance fg

[Install]
WantedBy=multi-user.target

I haven't digged deep into systemd start/stop scripts, but i think i will use it more often. Are you using Supervisor? Is systemd a good replacement?

 

Python Script zum Download der wöchentlichen Zeit.de Epub Ausgabe

2 min read

Seit ich ein 7,8 Zoll PocketBook Inkpad 3 besitze, lese ich auch die Zeit auf diesem Ebook-Reader. Um das wöchentlich erscheinde Epub auf den Reader zu bekommen, habe ich mir ein Download Python Script geschrieben.

Es versucht die Downlaod URL zu generieren und die Datei runterzuladen, im Fehlerfall schickt es mir eine E-Mail. Damit (und mit Hilfe meines alten Bash Scripts) bekomme ich die Zeit per Send-to-PocketBook auf meinen Reader.

Meine jetzige Lösung nutzt leider noch Server von dritten (Email über Sent-to-Pocket). Vielleicht bau ich es noch aus, um die Syncronisation über meine Nextcloud laufen zu lassen. Möglich scheint es zu sein.

 

# -*- coding: utf-8 -*-
"""
"""
import datetime

from email.mime.text import MIMEText
import requests
import smtplib
import sys
import os.path

email = sys.argv[1]
password = sys.argv[2]

def send_mail_to_me():
        msg = MIMEText('nt')
        msg['Subject'] = 'Zeit.de epub url does not exist'
        msg['From'] = email
        msg['To'] = email
        s = smtplib.SMTP('localhost')
        s.sendmail(msg['From'], [msg['To']], msg.as_string())

def download_file(url):
    local_filename = url.split('/')[-1]
    # NOTE the stream=True parameter
    r = requests.get(url, auth=(email, password), stream=True)
    with open(local_filename, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk: # filter out keep-alive new chunks
                f.write(chunk)
    return local_filename


if __name__ == '__main__':
    now = datetime.datetime.now()
    wk = now.isocalendar()[1]
    url = 'https://premium.zeit.de/system/files/{}-{}/epub/die_zeit_2018_{}.epub'.format(now.year, wk, wk+1)
    local_filename = url.split('/')[-1]
    full_script_path = os.path.dirname(os.path.abspath(__file__))
    full_zeit_path = full_script_path + '/' + local_filename
    if not os.path.isfile(full_zeit_path):
        url_exits = requests.get(url, auth=(email, password))
        if url_exits.status_code not in [200, 201]:
            send_mail_to_me()
            sys.exit(1)
        else:
            name = download_file(url)
            print name


 

Github Gist Link

 
 

Überschreiben der Festplatten von Hetzner Servern

1 min read

Nachdem ich es nun das dritte mal rausgesucht habe, schreibe ich es mir hier rein:

  • Boot Hetzner Server in rescue mode
  • Login and start a screen
  • shred -v /dev/sdX /dev/sdY

 

Play MTG Arena on a Android smartphone (PC with Steam needed)

1 min read

Recently Steam published the Steam Link app for Android. Here is what you need to play Magic Arena in the bathroom, bed or maybe in the bus?

  1. Get a MTG Arena access (its in closed beta)
  2. Add MTG Arana to Steam
  3. Install Steam for Android (on your phone)
  4. You are ready to stream it:

Sorry, your browser doesn't support embedded videos, but don't worry, you can download it and watch it with your favorite video player!

I tested it some time within my WLAN and it works great. It plays really well with fingers and on the phone. I haven't tested it on a mobile connections through some kind of VPN, but maybe will.

 

 

10x10 - Erster Spieletausch

1 min read

Als ich die Spiele der 10x10 Herausforderung Ende letzten Jahres zusammenstellte, war mir klar dass, ich  tauschen werde. Mir ist auch klar, dass ich es trotz Tausch nur sehr schwer schaffen werde, aber der Weg ist das Ziel.

Magic Draft (ersetzt Stone Age)

In letzter Zeit spiele ich fast nur noch Magic, das liegt an der tollen Playgroup, die sich jede Woche trifft und an den Magic-Events, die man nicht verpassen darf. Vor kurzem haben wir in der Playgroup ein Draft gespielt (Dominaria), es war mein erstes Draft und mir ist jetzt klar, warum es so beliebt ist. Das nächste Draft (BattleBound) ist schon geplant.

Magic Standard (ersetzt El Grande)

Außerdem haben wir uns die neuen Standard Challenger Decks gekauft und tauchen gerade in dieses Format ein. Ich glaube nicht, dass wir bei diesem rotierenden Format dabei bleiben, aber gerade macht es Laune und passt gut zu den Decks & Spielen in Magic Arena.

Meine 10x10 Fortschrittseite habe ich aktualisiert.