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"))
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 / 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
@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
[
{
"_path": "private",
"_type": "ftw.topics.Topic",
"title": "Private"
},
{
"_path": "private/00054",
@jone
jone / get_free_port.py
Last active December 12, 2015 07:58
sauce jenkins
import socket
# Sauce only tunnels certain ports, so we need to pick one of those ports and it should be
# not used.
# See port list at: https://saucelabs.com/docs/connect#localhost
PORTS = [2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8080, 8888, 9000, 9001, 9080, 9090, 9999, 4502, 4503, 8003, 8031]
def get_free_port():
for port in PORTS:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)