Skip to content

Instantly share code, notes, and snippets.

View jone's full-sized avatar

Jonas Baumann jone

View GitHub Profile
2017-12-12T15:07:46 ERROR plone.app.viewletmanager rendering of plone.htmlhead.links in plone.links.RSS fails: 'dict' object is not callable
- Expression: "view/rsslinks"
- Filename: ... ayout-2.3.12-py2.7.egg/plone/app/layout/links/rsslink.pt
- Location: (line 1: col 28)
- Source: ... tal:feeds tal:repeat="link view/rsslinks">
^^^^^^^^^^^^^
- Arguments: repeat: {...} (0)
template: <ViewPageTemplateFile - at 0x7f6925ce4e10>
views: <ViewMapper - at 0x7f6919a99790>
@jone
jone / remove_versions_of_deleted_objects.py
Last active August 29, 2015 14:19
Plone: Remove versions of deleted objects
from AccessControl.SecurityManagement import newSecurityManager
from pprint import pprint
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Testing.makerequest import makerequest
from zope.app.component.hooks import setSite
app = globals()['app']
user = None
@jone
jone / deploy__after_push
Created February 20, 2015 15:56
git-deploy with Plone
#!/usr/bin/env bash
set -e
oldrev=$1
newrev=$2
run() {
[ -x $1 ] && $1 $oldrev $newrev
}
echo files changed: $(git diff $oldrev $newrev --diff-filter=ACDMR --name-only | wc -l)
@jone
jone / MS-WORD.java
Created March 14, 2014 10:46
Tika traceback for password protected files.
Exception in thread "main" org.apache.tika.exception.TikaException: Unexpected RuntimeException from org.apache.tika.parser.microsoft.OfficeParser@7c6572b
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:244)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)
at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:120)
at org.apache.tika.cli.TikaCLI$OutputType.process(TikaCLI.java:141)
at org.apache.tika.cli.TikaCLI.process(TikaCLI.java:417)
at org.apache.tika.cli.TikaCLI.main(TikaCLI.java:111)
Caused by: java.lang.NullPointerException
at org.apache.poi.poifs.crypt.Decryptor.hashPassword(Decryptor.java:102)
at org.apache.poi.poifs.crypt.AgileDecryptor.verifyPassword(AgileDecryptor.java:66)
@jone
jone / strip_diacritics.py
Created January 7, 2014 10:48
Strip diacricits
import unicodedata
def strip_diacricits(text):
if isinstance(text, str):
text = text.decode('utf-8')
normalized = unicodedata.normalize('NFKD', text)
text = u''.join([c for c in normalized if not unicodedata.combining(c)])
text = text.encode('utf-8')
return text
@jone
jone / magit-cl.el
Created August 8, 2013 07:34
With Emacs 24.2 / magit master
Debugger entered--Lisp error: (file-error "Cannot open load file" "cl-lib")
require(cl-lib)
eval-buffer(#<buffer *load*<4>> nil "/Users/jone/projects/cabbage/vendor/magit/magit.el" nil t) ; Reading at buffer position 2337
load-with-code-conversion("/Users/jone/projects/cabbage/vendor/magit/magit.el" "/Users/jone/projects/cabbage/vendor/magit/magit.el" nil t)
require(magit)
(progn (add-to-list (quote load-path) library-dir) (require library))
(if (and library-dir (file-directory-p library-dir)) (progn (add-to-list (quote load-path) library-dir) (require library)))
(when (and library-dir (file-directory-p library-dir)) (add-to-list (quote load-path) library-dir) (require library))
(let* ((library-dir (cabbage-vendor-library-dir library))) (when (and library-dir (file-directory-p library-dir)) (add-to-list (quote load-path) library-dir) (require library)))
cabbage-vendor(magit)
@jone
jone / diacritics-insentive-sorting.py
Last active December 19, 2015 13:39
Sorting strings diacritics insensitive and case insensitive. Diacritics are combined characters such as ^,¨,`
import unicodedata
def make_sortable(text):
"""Converts a string to a sortable string by lowercasing
it and removing diacritics.
"""
if isinstance(text, str):
text = text.decode('utf-8')
if not isinstance(text, unicode):
return text
from memoize import memoize
import re
import shlex
import subprocess
def runcmd_get_exitcode(command, cwd=None):
return runcmd(command, cwd=cwd)[0]
def runcmd_get_stdout(command, cwd=None):
@jone
jone / 1097d1cd7b9682a31cf449b08e89f915
Last active December 18, 2015 03:48
zope extends cache
# cache of http://download.zope.org/zopetoolkit/index/1.0.8/ztk-versions.cfg
[versions]
# ZTK
zope.annotation = 3.5.0
zope.applicationcontrol = 3.5.5
zope.authentication = 3.7.1
zope.broken = 3.6.0
zope.browser = 1.3
zope.browsermenu = 3.9.1
@jone
jone / eventhandlers.py
Created February 28, 2013 13:12
Plone: Setup dashboard on login
from Products.Archetypes.interfaces.field import IImageField
from plone.app.blob.interfaces import IBlobImageField
from ftw.dashboard.portlets.postit.browser import postit
from ftw.dashboard.portlets.recentlymodified.browser import recentlymodified
from ftw.favorite.portlets import favorites
from plone.portlets.interfaces import IPortletManager
from zope.component import queryUtility
from zope.app.container.interfaces import INameChooser
from plone.portlets.constants import USER_CATEGORY
from plone.app.portlets.storage import UserPortletAssignmentMapping