Skip to content

Instantly share code, notes, and snippets.

View avoinea's full-sized avatar
🇷🇴
The Sound of Silence

Alin Voinea avoinea

🇷🇴
The Sound of Silence
View GitHub Profile
""" Custom Add/Edit forms
"""
from zope import schema
from zope.component import queryAdapter
from zope.component import provideAdapter
from z3c.form.browser.checkbox import CheckBoxFieldWidget
from z3c.form.browser.radio import RadioFieldWidget
from plone.dexterity.browser import edit
from plone.dexterity.browser import add
from eea.facetednavigation.interfaces import ICriteria
@avoinea
avoinea / fix_zc.async.py
Created July 26, 2019 15:53
# Fix broken zc.async within Data.fs
# Fix broken zc.async within Data.fs
$ bin/instance debug
>>> del app._p_jar.root._root['zc.async']
>>> import transaction
>>> transaction.commit()
@avoinea
avoinea / buildout.cfg
Created September 19, 2017 09:26 — forked from david-batranu/buildout.cfg
plone-wsgi
# Install uwsgi>=2.0.15 (requires build-essential and python-dev)
# adding it to eggs should also work, assuming you have gcc
[buildout]
parts +=
instance
uwsgi-app
uwsgi-run
[uwsgi-run]
@avoinea
avoinea / .vimrc
Last active March 13, 2017 16:03 — forked from david-batranu/.vimrc
plug-only vim, requires a ~/.vim/backups folder for persistent undo
# Installation:
#
# $ mkdir ~/.vim/backups
# $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# $ curl -o ~/.vimrc https://gist.githubusercontent.com/avoinea/3b7a79cb50d86af125454a1c669ec702/raw/e6469bfc7c246cfdf1060abd64c13c871c6ba46a/.vimrc
# $ vim
# :PlugInstall
# :q
#
# Enjoy ;)
@avoinea
avoinea / adapters.py
Last active July 28, 2016 16:07
ZCA: Adapters
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zope import interface
from zope import component
################################################################################
# Geek Model
################################################################################
class IGeek(interface.Interface):
# - Archiving -
archive_mode = on # allows archiving to be done
# (change requires restart)
#archive_command = 'test ! -f /var/lib/pgsql/backup_in_progress || (test ! -f /var/lib/pgsql/archive/%f && cp %p /var/lib/pgsql/archive/%f)' # command to use to archive a logfile segment
archive_command = 'rsync -a %p postgres@db-pg-prod-staging.cvps.eea.europa.eu:/var/lib/pgsql/archive/%f'
# placeholders: %p = path of file to archive
# %f = file name only
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
archive_timeout = 600 # Let's keep us max 10minutes away from the master

UNIX monitoring tools you should know about

  • System

    • htop - Processes
    • atop - System monitor
  • Disk I/O

    • iotop
  • Network

@avoinea
avoinea / docker-cleanup.sh
Last active January 14, 2016 13:04
Docker utils
# Remove all non-data docker containers
docker rm -v $(docker ps -a | grep -v "data" | gawk '{print $1}';)
# Remove <none> docker images
docker rmi $(docker images | grep none | gawk '{print $3}';)
@avoinea
avoinea / configure.zcml
Last active January 13, 2016 13:23
Advanced EEA Faceted Navigation Query
<configure package="eea.facetednavigation.browser">
<browser:page
for="eea.facetednavigation.interfaces.IFacetedNavigable"
layer="enisa.databreach.content.interfaces.IDatabreachContentInstalled"
name="faceted_query"
class="enisa.databreach.content.browser.faceted.CustomQueryHandler"
template="template/query.pt"
permission="zope2.View"
/>
</configure>
@avoinea
avoinea / uninstall-eea-facetednavigation.py
Last active January 13, 2016 13:12
Uninstall eea.facetednavigation
from zope.interface import providedBy
from zope.interface import noLongerProvides
brains = context.portal_catalog(object_provides='eea.facetednavigation.subtypes.interfaces.IFacetedNavigable')
for brain in brains:
doc = brain.getObject()
interfaces = providedBy(doc).flattened()
for interface in interfaces:
if interface.__identifier__.startswith('eea.faceted'):
noLongerProvides(doc, interface)