Skip to content

Instantly share code, notes, and snippets.

View jone's full-sized avatar

Jonas Baumann jone

View GitHub Profile
[
{
"_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)
@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"
/>
@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 / 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 / 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 ()
from z3c.saconfig import named_scoped_session
Session = named_scoped_session('name_of_session')
Sesion()
from htmlentitydefs import name2codepoint as n2cp
from htmlentitydefs import codepoint2name as cp2n
import re
def decode_htmlentities(string):
"""
Decodes htmlentities or xmlentities
>>> decode_htmlentities('&quot;X&gt;Y&quot;')
u'"X>Y"'
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.'