Skip to content

Instantly share code, notes, and snippets.

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 Jul 24, 2017
sublime multi cursor edit
View stmce.rst

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 Mar 23, 2017
Calculate the check digit of an Austrian social insurance number; Berechnen der Prüfziffer einer österreichischen Sozialversicherungsnummer
View svnr_validate.py
# -*- 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 Nov 3, 2016
Plone Image Proxy View
View imageproxyview.py
# -*- 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 Jul 22, 2016
Cleanup LRF from ordering garbage. Upgrades plone.app.multilingual 2.0a3 to 2.0.1
View configure.zcml
<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 Apr 13, 2019
sentry setup with docker-compose
View INSTALL.rst

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.

View test_subjects_under_ctx.py
# -*- 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 Apr 23, 2016
Add UTF8 headers to python files if not already in place
View utf8headers.sh
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 Apr 11, 2016
my colorful git aware prompt with abbreviations for workspace
View .bash-slash-git-aware-prompt-slash-colors.sh
# 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
View bench-mc.py
# -*- 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 Aug 29, 2015
Create a bunch of same labels for each repo of an organization
View make_labels.py
# -*- 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