Skip to content

Instantly share code, notes, and snippets.

View ale-rt's full-sized avatar

Alessandro Pisa ale-rt

View GitHub Profile
from lxml import html
import requests
template = "https://distrowatch.com/search.php?pkg=Python&relation=greaterequal&pkgver={}&distrorange=InLatest#pkgsearch"
def get_distros(min_python_version):
response = requests.get(template.format(min_python_version))
distros = set()
@ale-rt
ale-rt / update_membrane_users.md
Created August 18, 2020 10:51
How to update membrane users

Change some properties

>>> profiles = app.quaive.profiles
>>> profiles["foo"].email = "foo.bar@example.com"
>>> from transaction import commit
>>> commit()

Set an encrypted password

@ale-rt
ale-rt / vm-backup.sh
Created August 7, 2018 15:16 — forked from cabal95/vm-backup.sh
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
# coding=utf-8
from plone.app.blocks import utils
from plone.subrequest import subrequest
from zExceptions import NotFound
from zope.site.hooks import getSite
def resolveResource(url):
"""Resolve the given URL to a unicode string. If the URL is an absolute
path, it will be made relative to the Plone site root.
[style]
# Align closing bracket with visual indentation.
align_closing_bracket_with_visual_indent=True
# Allow dictionary keys to exist on multiple lines. For example:
#
# x = {
# ('this is the first element of a tuple',
# 'this is the second element of a tuple'):
# value,
[instance]
eggs+=
${hotfix:eggs}
[hotfix]
recipe = mr.scripty
eggs=
from urllib import urlopen
version = self.buildout['versions']['Plone']
base_url = 'https://raw.githubusercontent.com/starzel/buildout/master/linkto/hotfixes/%s.cfg'
@ale-rt
ale-rt / gist:3c7741dd2013f364ac8370bc07273727
Created April 27, 2016 16:02
bin/instance run this script to dump your Plone site into an a folder
# coding=utf-8
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from collective.jsonify.export import export_content
from logging import DEBUG
from logging import getLogger
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy
from Testing.makerequest import makerequest
# coding=utf-8
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from collective.jsonify.export import export_content
from logging import DEBUG
from logging import getLogger
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy
from Testing.makerequest import makerequest
@ale-rt
ale-rt / gist:8685751
Last active January 4, 2016 22:09
How to make collective.lineage and collective.simplesocial work together
Just add to the zcml-additional those lines
```
[instance]
...
zcml-additional =
<configure xmlns="http://namespaces.zope.org/zope">
<adapter for="collective.lineage.interfaces.IChildSite"
factory="collective.simplesocial.browser.configlet.FacebookSettingsAdapter"
provides="collective.simplesocial.browser.interfaces.IFacebookSettings"
/>
def plonereload(user="admin", password='admin'):
''' Reload Plone
'''
from requests import get
from lxml.html import fromstring
auth = (user, password)
response = get('http://localhost:7081/reload?action=code', auth=auth)
try:
print fromstring(response.text).find('.//pre').text