Skip to content

Instantly share code, notes, and snippets.

Avatar
🇷🇴
The Sound of Silence

Alin Voinea avoinea

🇷🇴
The Sound of Silence
View GitHub Profile
View dynamic_schema.py
""" 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 Jul 26, 2019
# Fix broken zc.async within Data.fs
View fix_zc.async.py
# Fix broken zc.async within Data.fs
$ bin/instance debug
>>> del app._p_jar.root._root['zc.async']
>>> import transaction
>>> transaction.commit()
View buildout.cfg
# 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 Mar 13, 2017 — forked from david-batranu/.vimrc
plug-only vim, requires a ~/.vim/backups folder for persistent undo
View .vimrc
# 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 Jul 28, 2016
ZCA: Adapters
View adapters.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zope import interface
from zope import component
################################################################################
# Geek Model
################################################################################
class IGeek(interface.Interface):
View replication-postgres.conf
# - 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
View UNIX monitoring tools.md

UNIX monitoring tools you should know about

  • System

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

    • iotop
  • Network

View docker-cleanup.sh
# 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 Jan 13, 2016
Advanced EEA Faceted Navigation Query
View configure.zcml
<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 Jan 13, 2016
Uninstall eea.facetednavigation
View uninstall-eea-facetednavigation.py
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)