Skip to content

Instantly share code, notes, and snippets.

View kelvan's full-sized avatar

Florian Schweikert kelvan

View GitHub Profile
From b67bd19f098c5126f6a00fe196b29912392dae4f Mon Sep 17 00:00:00 2001
From: Florian Schweikert <[email protected]>
Date: Wed, 18 Feb 2015 18:14:23 +0100
Subject: [PATCH] Set hvad<1.1 (incompatible)
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
@kelvan
kelvan / logout_deactivated_user.py
Created October 22, 2015 13:10
Logout deactivated users
from django.contrib.auth import logout
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
class LogoutDisabledUserMiddleware:
"""Logout user if it is deactivated
"""
def process_request(self, request):
if request.user.is_authenticated() and not request.user.is_active:
@kelvan
kelvan / convert_vault.sh
Last active July 22, 2016 22:05
Script to convert Jolla1 vault (backup) to JollaC version, either on device or using a Backup.tar
#!/bin/bash
set -e
DATE_STRING=`date -u "+%Y-%m-%dT%H-%M-%SZ"`
TMP_PATH=$HOME/vault_tmp_$DATE_STRING
TARGET_ARCHIVE=$HOME/sailfish_backup_$DATE_STRING.tar
FOLDERS="Accounts Browser Gallery Media Messages Notes People Phone"
if [ -n "$1" ]; then
@kelvan
kelvan / automatic_secret_key_generation.py
Created January 2, 2017 16:02
Some (maybe hackish) approach to generate SECRET_KEY on first run
# Put this code in your settings file
# Saves new secret key to secret.key file in same folder as your settings
import logging
logger = logging.getLogger(__name__)
## Secret key generation functions
secret_key_fn = os.path.join(os.path.dirname(__file__), 'secret.key')
@kelvan
kelvan / copy_xspf_to_folder.py
Created May 16, 2018 11:41
Copy files of xspf playlist (relative paths) to target folder, preserving folder structure
#!/usr/bin/env python3
import argparse
import os
from pathlib import Path
import shutil
import sys
from xml.dom import minidom
parser = argparse.ArgumentParser(description='Copy files of xspf playlist to target folder')
@kelvan
kelvan / maybe_useless_columns.py
Created September 28, 2018 13:49
Check MySQL table for empty/null/"always the same" columns
import argparse
import MySQLdb
parser = argparse.ArgumentParser(description='Check table for empty/null/"always the same" columns')
parser.add_argument('--db', help='Databse name', required=True)
parser.add_argument('--table', help='Table name', required=True)
parser.add_argument('--user', help='DB user', required=True)
parser.add_argument('--password', help='DB password', required=True)
parser.add_argument('--host', help='DB host', default='localhost')
name ring quadrant isNew description
Composer adopt tools TRUE Although the idea of dependency management ...
Canary builds trial techniques FALSE Many projects have external code dependencies ...
Apache Kylin assess platforms TRUE Apache Kylin is an open source analytics solution ...
JSF hold languages & frameworks FALSE We continue to see teams run into trouble using JSF ...
@kelvan
kelvan / async_client.py
Created October 29, 2020 14:35
Async client for apistar
import apistar # type: ignore
import typesystem
from apistar.client.transports import BlockAllCookies, HTTPTransport
from httpx import AsyncClient
class AsyncHTTPTransport(HTTPTransport):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)