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 / 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 / toggle_touchpad.sh
Last active February 7, 2017 11:49
Linux Script to Toggle Thinkpad Touchpad on/off
#!/bin/bash
# together with i3wm i bound this script to the blue thinkvantage button
# using:
# bindsym XF86Launch1 exec /usr/local/bin/toggle_touchpad.sh
# extract device id
DEVICE=`xinput --list|sed -n 's/.*SynPS\/2 Synaptics TouchPad.*id=\([0-9]*\).*/\1/p'`
# check its state
@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 / corneribbon.pt
Created September 19, 2017 13:42
cornerribbon tile Plone
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="bda.aaf.site">
<head>
<style tal:condition="view/show">
/* The ribbons */
.corner-ribbon{
position: fixed;
top: 25px;
left: -50px;
width: 200px;
@jensens
jensens / action.py
Created August 29, 2012 20:10
Plone action menu enable feature by setting marker interface
from zope.interface import Interface
from zope.interface import directlyProvides
from zope.interface import noLongerProvides
from Products.Five.browser import BrowserView
from Products.CMFPlone import PloneMessageFactory as _
class ISomeFeatureTarget(Interface):
pass
class IPossibleSomeFeatureTarget(Interface):
@jensens
jensens / configure.zcml
Created June 19, 2018 06:24
Plone Registry Exporter (parts only)
<configure
i18n_domain="kup.akivdb"
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone">
<!-- ADMIN -->
<browser:page
class=".registryexporter.RegistryExporterView"
for="plone.app.layout.navigation.interfaces.INavigationRoot"
name="plone-export-registry"
@jensens
jensens / calc_test_percentages.py
Created July 2, 2018 14:42
Simple percentage report of end of tests output.
#!./bin/python
"""
Simple percentage report of end of tests output. Copy the line from there and pass to script:
usage: $./calc_test_percentages.py 9372 tests, 180 failures, 324 errors and 266 skipped in 22 minutes 25.188 seconds
output:
green : 91.784%
failures: 1.921%
@jensens
jensens / buildout.cfg
Created August 13, 2018 14:49
Sentry on Docker to monitor Zope (for Andreas)
...
[instance]
...
eggs +=
raven
event-log-custom =
%import raven.contrib.zope
@jensens
jensens / date.pt
Created October 16, 2017 11:52
Show Event Start-End with Zope Content Provider usage
<time class="datum"
datetime="${result/iso}"
tal:define="result python:view.datedict"
tal:condition="result"
i18n:domain="my.fancy.site">
<--
case 1: whole day, same day
Mo, 21.01.2015
@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.