Skip to content

Instantly share code, notes, and snippets.

View jone's full-sized avatar

Jonas Baumann jone

View GitHub Profile
@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 / 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 / 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
(defun find-buildout-root (path)
"Search PATH for a buildout root.
If a buildout root is found return the path, othwise return
nil."
;; find the most top one, not the first one
(let ((dir default-directory)
(previous nil))
(while dir
(let ((dir (find-parent-with-file dir "boostrap.py")))
wtool = getToolByName(task, 'portal_workflow')
review_state = wtool.getInfoFor(task, 'review_state', None)
print 'XXX', review_state
if review_state == from_review_state:
mtool = getToolByName(task, 'portal_membership')
current_user_id = mtool.getAuthenticatedMember().getId()
wf_ids = wtool.getChainFor(task)
def set_workflow_state(self):
state = 'task-state-new-successor'
mtool = getToolByName(self.context, 'portal_membership')
wtool = getToolByName(self.context, 'portal_workflow')
current_user_id = mtool.getAuthenticatedMember().getId()
wf_ids = wtool.getChainFor(self.context)
if wf_ids:
wf_id = wf_ids[0]
comment = 'Created successor.'
from htmlentitydefs import name2codepoint as n2cp
from htmlentitydefs import codepoint2name as cp2n
import re
def decode_htmlentities(string):
"""
Decodes htmlentities or xmlentities
>>> decode_htmlentities('"X>Y"')
u'"X>Y"'
from z3c.saconfig import named_scoped_session
Session = named_scoped_session('name_of_session')
Sesion()
@jone
jone / emacs fullscreen patch
Created February 26, 2011 13:16
temporary fix for the fullscren patch wich does not apply on the current emacs head (copied from https://github.com/downloads/typester/emacs/feature-fullscreen.patch and modified)
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 157b2dd..f3807b7 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -1263,6 +1263,11 @@ the operating system.")
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
@jone
jone / gist:1923002
Created February 27, 2012 10:29
bin/instance run setup
from AccessControl.SecurityManagement import newSecurityManager
from Testing.makerequest import makerequest
from zope.app.component.hooks import setSite
site_name = 'Plone'
# setup request and get plone site
app = makerequest(app)
site = app.unrestrictedTraverse(site_name)