Skip to content

Instantly share code, notes, and snippets.

View maethu's full-sized avatar
😎

Mathias Leimgruber maethu

😎
View GitHub Profile
# NGINX CONFIG
upstream plone {
server cms:8080;
}
server {
listen 80;
server_name dev-backend.webcloud7.ch;
from Acquisition import aq_inner
from Acquisition import aq_parent
from bumblebee.file import _
from bumblebee.file.utils import format_filesize
from collective.prettydate.interfaces import IPrettyDate
from ftw.bumblebee.mimetypes import get_mimetype_image_url
from ftw.bumblebee.mimetypes import get_mimetype_title
from ftw.bumblebee.mimetypes import is_mimetype_supported
from ftw.bumblebee.utils import get_fallback_url
from ftw.bumblebee.utils import get_representation_url_by_object
>>> plone = app.platform
>>> from zope.component.hooks import setSite
>>> setSite(plone)
>>> from plone import api
>>> import csv
>>> from StringIO import StringIO
>>> handler = open('user.csv', 'r')
>>> data = handler.read().decode("utf-8-sig").encode("utf-8")
>>> csv_data = csv.DictReader(StringIO(data), delimiter=';')
>>> for item in csv_data:
JPEG_START_BYTE = '\xff\xd8'
JPEG_END_BYTE = '\xff\xd9'
def get_jpeg(stream):
start_pos = None
end_pos = None
while True:
frame_bytes = stream.read(1024)
##############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#!/usr/bin/python
#
# fakemail (Python version)
#
# $Id: fakemail.py,v 1.1 2005/08/29 22:04:55 lastcraft Exp $
#
# usage: fakemail --host=localhost --port=25 --path=./mails --background
import asyncore
import getopt
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title></head>
<body>
<p tal:content="here/getBody_pre | nothing" />
<table style="width:800px; border: 1px solid grey">
<tr tal:repeat="field options/wrappedFields | nothing">
<th tal:content="field/fgField/widget/label" />
@maethu
maethu / uncatalog_if_no_uid.py
Last active February 5, 2019 19:19
uncatalog_if_no_uid.py
def uncatalog_by_rid(_catalog, rid):
data = _catalog.data
paths = _catalog.paths
indexes = _catalog.indexes.keys()
for name in indexes:
x = _catalog.getIndex(name)
if hasattr(x, 'unindex_object'):
x.unindex_object(rid)
del data[rid]
del paths[rid]
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_inner
from Acquisition import aq_parent
from Products.CMFCore.utils import getToolByName
from Testing.makerequest import makerequest
from zope.component.hooks import setSite
import transaction
app = globals()['app']
# we need to get a super user security and a request
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_inner
from Acquisition import aq_parent
from Products.CMFCore.utils import getToolByName
from Testing.makerequest import makerequest
from zope.component.hooks import setSite
import transaction
app = globals()['app']
# we need to get a super user security and a request