Skip to content

Instantly share code, notes, and snippets.

View 2silver's full-sized avatar

Michael Graf 2silver

  • @fhstp University of Applied Sciences Sankt Pölten
  • St. Pölten, Austria
View GitHub Profile
@2silver
2silver / fixblobs.py
Created January 11, 2023 20:05 — forked from macagua/fixblobs.py
A Zope command line script to delete content with missing BLOB in Plone
"""
A Zope command line script to delete content with missing BLOB in Plone, causing
POSKeyErrors when content is being accessed or during portal_catalog rebuild.
Tested on Plone 4.1 + Dexterity 1.1.
http://stackoverflow.com/questions/8655675/cleaning-up-poskeyerror-no-blob-file-content-from-plone-site
Also see:
@2silver
2silver / psql_useful_stat_queries.sql
Created November 27, 2019 11:48 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
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
@2silver
2silver / copy_and_restore.py
Created November 8, 2018 13:03 — forked from MatthewWilkes/copy_and_restore.py
A custom ZODB recovery script for ZODB
# ZODB recovery script that 'rebases' transactions onto an older copy of the same
# FileStorage. This is useful in the case where a FileStorage is lightly corrupted
# but that is not detected and it remains in production, garnering new transactions.
#
# The corruption in the storage may have prevented various transactions for completing
# and prevents packing or incremental backups, so backup taken before the corruption
# happened is used as a graft for the newer transactions. This only works if all
# the corruption happens to transactions covered by the backup, corruption that affects
# the transactions being appended is not recoverable in this fashion.
#
@2silver
2silver / js-micro.js
Created June 26, 2017 09:02 — forked from yuval-a/js-micro.js
Javascript micro-optimizations
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
var obj = {};
// property === undefined is faster than hasOwnProperty(property)
// Note: don't use this in cases where 'undefined' is a possible value for your properties
@2silver
2silver / printview.py
Created February 18, 2016 13:46 — forked from djay/printview.py
Return a pdf from a BrowserView in Plone with plone.subrequest
from StringIO import StringIO
from DateTime import DateTime
from plone.subrequest import subrequest
from urllib import unquote
from ho.pisa import pisaDocument
from pyPdf import PdfFileWriter, PdfFileReader
from Products.Five import BrowserView
@2silver
2silver / prltools_ubuntu.md
Last active November 22, 2015 22:02 — forked from magnetikonline/README.md
Install OSX Parallels v10 tools under Ubuntu server guest.

Install OSX Parallels v10 tools under Ubuntu server guest

  • Create Ubuntu server instance under Parallels (obviously).

  • Start VM, goto Actions - Install Parallels Tools... to mount the ISO image.

  • From the terminal, run the following commands:

     $ sudo su
     $ apt-get install gcc make
     $ mkdir -p /media/cdrom
     $ mount /dev/cdrom /media/cdrom