Skip to content

Instantly share code, notes, and snippets.

View cdw9's full-sized avatar

Chrissy Wainwright cdw9

View GitHub Profile

Keybase proof

I hereby claim:

  • I am cdw9 on github.
  • I am cdw9 (https://keybase.io/cdw9) on keybase.
  • I have a public key whose fingerprint is 20A2 09E8 62F8 6C09 0D7E E059 22F1 091D E583 C731

To claim this, I am signing this object:

@cdw9
cdw9 / instance
Created April 26, 2017 03:10
Sample instance script with eggs listed
#!/Users/chrissy/projects/nd/nd-buildout/env/bin/python2.7
import sys
sys.path[0:0] = [
'/Users/chrissy/.buildout/eggs/Pillow-3.2.0-py2.7-macosx-10.11-x86_64.egg',
'/Users/chrissy/.buildout/eggs/collective.indexing-1.8-py2.7.egg',
'/Users/chrissy/.buildout/eggs/collective.upgrade-1.1-py2.7.egg',
'/Users/chrissy/.buildout/eggs/plone.app.dexterity-2.0.18-py2.7.egg',
'/Users/chrissy/.buildout/eggs/plone4.csrffixes-1.0.9-py2.7.egg',
'/Users/chrissy/.buildout/eggs/Products.PloneHotfix20160830-1.3-py2.7.egg',
@cdw9
cdw9 / Folder.xml
Last active January 22, 2021 09:07
Plone batch file download - adds a download link to folders, will create a .zip of all files or PDFs in the folder
<?xml version="1.0"?>
<object
i18n:domain="plone"
meta_type="Dexterity FTI"
name="Folder"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<action
action_id="download_files"
category="object"
@cdw9
cdw9 / metadata.xml
Created September 26, 2019 14:49
Plone 4 - Add valid_tags to the safe_html
<?xml version="1.0"?>
<metadata>
<version>002</version>
</metadata>
@cdw9
cdw9 / Products.CMFPlone.browser.templates.description.pt
Last active November 14, 2019 14:55
Plone 5.2 - HTML Dublin Core Behavior for Plone. Meant to replace plone.dublincore. Honors HTML filtering, and saves a plain text version of the value to the default Title and Description, so you don't have to override dozens of templates in your site
<div class="documentDescription description"
tal:define="html_descrip context/html_description | nothing;
plain_descrip context/Description"
tal:condition="plain_descrip">
<tal:html tal:condition="html_descrip"
tal:content="structure html_descrip">
Description
</tal:html>
<tal:plain tal:condition="not: html_descrip"
tal:content="plain_descrip">
@cdw9
cdw9 / dates.py
Created December 17, 2019 20:31
Taking separate date and time strings (which are not following a specific format), turn them into datetime objects and return [start, end]
def event_dates(date, time):
"""Takes the event's date and time fields,
returns a start date and end date (if applicable)
example date: "2017/09/16 00:00:00 GMT-4"
example time: "11:00 am" or "9:00am - 11:00pm"
"""
if not date:
return [None, None]
date = date.replace('GMT-4', 'America/New_York')
if not time:
requests==2.21.0
six==1.12.0
slackeventsapi==2.1.0
slackclient==2.5.0
websocket-client==0.54.0
@cdw9
cdw9 / README.txt
Created March 4, 2020 17:28
Mac daily reminder with Python, Arrow, and a cronjob!
1. Install terminal-notifier: https://github.com/julienXX/terminal-notifier
2. Create a virtualenv
3. pip install arrow
4. test code with `env/bin/python daily-notify.py`
5. Set up the cronjob
6. If you want the notifications to be sticky, go to System Preferences > Notifications, and make sure terminal-notifier notifications display as Alerts
@cdw9
cdw9 / configure.zcml
Created August 20, 2020 21:10
Restrict access to a custom Plone File type
<!-- custom template -->
<browser:page
name="ofs_file_view"
class=".ofs.OFSFileView"
template="ofs_file_view.pt"
permission="zope2.View"
for="plone.app.contenttypes.interfaces.IFile"
/>
<!-- custom @@download for the type -->
@cdw9
cdw9 / portlet_assignments.py
Created September 19, 2022 19:53
Get a listing (type, path) of where all the portlets are assigned within a Plone site
# bin/instance1 -O plonesiteid run scripts/portlet_assignments.py
import logging
import sys
from AccessControl.SecurityManagement import newSecurityManager
from plone import api
from plone.portlets.interfaces import IPortletAssignmentMapping, IPortletManager
from zope.component import queryMultiAdapter, queryUtility