Skip to content

Instantly share code, notes, and snippets.

View jone's full-sized avatar

Jonas Baumann jone

View GitHub Profile
(defun jone-filter (condp lst)
(delq nil
(mapcar (lambda (x) (and (funcall condp x) x)) lst)))
(jone-filter (lambda (e) (string= e "hans")) ("hans" "peter"))
(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")))
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.'
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)
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)
@jone
jone / remove-merged-git-branches.sh
Created October 14, 2012 11:42
Remove branches merged into (local) master
#!/usr/bin/env bash
# Use either in a repository root or in a folder containing repositories (e.g. src)
pwd=`pwd`
if [[ -e ".git" ]]; then
repos=$pwd
else
repos=`find $pwd -name '.git' -maxdepth 2 -exec dirname {} \;`
@jone
jone / configure.zcml
Created December 7, 2012 06:51
ftw.workspace integration of ftw.task
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<browser:page
for="*"
name="tabbedview_view-tasks"
class=".tasks.TasksTab"
permission="zope2.View"
/>