Skip to content

Instantly share code, notes, and snippets.

View jensens's full-sized avatar
🕶️
Available for training, coaching and trouble-shooting (as usual)..

Jens W. Klein jensens

🕶️
Available for training, coaching and trouble-shooting (as usual)..
View GitHub Profile
@jensens
jensens / stmce.rst
Last active July 24, 2017 10:09
sublime multi cursor edit

Multi-Edit in SublimeText2/ Linux

Multicursor Block/ Columns Selection

Keyboard:
  • Ctrl+Alt+[Up, Down] creates multicursor block
  • Ctrl+Alt+[Left, Right] expands as block
@jensens
jensens / svnr_validate.py
Last active September 13, 2022 10:39
Calculate the check digit of an Austrian social insurance number; Berechnen der Prüfziffer einer österreichischen Sozialversicherungsnummer
# -*- coding: utf-8 -*-
"""Calculate the check digit of an Austrian social insurance number
Berechnen der Prüfziffer einer österreichischen Sozialversicherungsnummer
copyright Klein & Partner KG.
License: Gnu Public License 2.0
from https://de.wikipedia.org/wiki/Sozialversicherungsnummer#.C3.96sterreich
@jensens
jensens / imageproxyview.py
Created November 3, 2016 15:12
Plone Image Proxy View
# -*- coding: utf-8 -*-
from plone import api
from plone.namedfile.interfaces import IStableImageScale
from plone.namedfile.scaling import ImageScale
from plone.scale.storage import AnnotationStorage
from Products.Five import BrowserView
from zExceptions import NotFound
from zope.interface import alsoProvides
from zope.interface import implementer
from zope.publisher.interfaces import IPublishTraverse
@jensens
jensens / configure.zcml
Created July 22, 2016 15:47
Cleanup LRF from ordering garbage. Upgrades plone.app.multilingual 2.0a3 to 2.0.1
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">
<browser:page
class=".upgradelrf.Upgrade"
for="plone.app.multilingual.content.lrf.LanguageRootFolder"
name="lp-migrate-lrf"
permission="cmf.ManagePortal"
/>
@jensens
jensens / INSTALL.rst
Last active April 13, 2019 09:43
sentry setup with docker-compose

In order to run this image do: docker-compose up -d to get all up. On first run DB initialization and initial user setup is done like so:

First start a bash in the container: docker-compose exec sentry /bin/bash. Then, inside bash, do sentry upgrade wait until it asks you for an inital user. When finished exit the bash.

When in doubt check with docker-compose ps if all went fine.

# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from bda.aaf.site.testing import BDA_AAF_SITE_FUNCTIONAL_TESTING
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
import unittest
@jensens
jensens / utf8headers.sh
Created April 23, 2016 13:46
Add UTF8 headers to python files if not already in place
find . -name "*.py"|while read fn;do head -n1 "$fn"|grep -qv "^# \-\*\- coding" && sed -i "1i # -*- coding: utf-8 -*-" $fn;done
@jensens
jensens / .bash-slash-git-aware-prompt-slash-colors.sh
Created April 11, 2016 13:53
my colorful git aware prompt with abbreviations for workspace
# Regular
txtblk="$(tput setaf 0 2>/dev/null || echo '\e[0;30m')" # Black
txtred="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')" # Red
txtgrn="$(tput setaf 2 2>/dev/null || echo '\e[0;32m')" # Green
txtylw="$(tput setaf 3 2>/dev/null || echo '\e[0;33m')" # Yellow
txtblu="$(tput setaf 4 2>/dev/null || echo '\e[0;34m')" # Blue
txtpur="$(tput setaf 5 2>/dev/null || echo '\e[0;35m')" # Purple
txtcyn="$(tput setaf 6 2>/dev/null || echo '\e[0;36m')" # Cyan
txtwht="$(tput setaf 7 2>/dev/null || echo '\e[0;37m')" # White
# -*- coding: utf-8 -*-
import csv
import pprint
import memcache
import pylibmc
import random
import string
import time
CYCLES = 10000
@jensens
jensens / make_labels.py
Last active February 21, 2024 17:00
Create a bunch of same labels for each repo of an organization
# -*- coding: utf-8 -*-
"""
This script creates specific labels for all repositories of an organization.
before using it do a ``pip install PyGithub``.
"""
from github import Github
import argparse