Skip to content

Instantly share code, notes, and snippets.


Nathan Van Gheem vangheem

View GitHub Profile
View gist:2c625d89c33c1010662c
def renderTiles(request, tree):
copy from blocks minus ESI stuff
site = getSite()
siteUrl = site.absolute_url()
root = tree.getroot()
except AttributeError:
vangheem / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import zope.interface
import zope.schema.interfaces
import z3c.form.interfaces
import z3c.form.browser.textarea
import z3c.form.widget
from import RelatedItemsWidget
class MyRelatedItemsWidget(RelatedItemsWidget):
vangheem / gist:6358511
Created Aug 27, 2013
archetypes note patch
View gist:6358511
import transaction
from copy import deepcopy
from cgi import escape
from cStringIO import StringIO
from logging import ERROR
from types import ClassType, FileType, StringType, UnicodeType
from zope.contenttype import guess_content_type
from zope.i18n import translate
from plone.tiles import Tile
from import RelatedItemsFieldWidget
from import image_scales
from plone.autoform import directives as form
from plone.supermodel import model
from zope import schema
from zope.component import getMultiAdapter
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.interface import Invalid
<tal:container tal:define="image python: view.get_image()">
<div class="image-tile-container" tal:define="caption view/data/caption|nothing">
<p class="image" tal:condition="nocall: image">
<img src="${image/absolute_url}/@@images/image/${view/data/scale|large}" alt="${image/Title}" />
<p class="description" tal:condition="caption">${caption}</p>
<p tal:condition="python: not image">
No image specified
View patterns.js
/* globals define */
'use strict';
var REGISTERED = {};
var register = function(name, config){
REGISTERED[name] = config;
vangheem /
Created Feb 27, 2017
Streaming s3 file for downloads
# using aiobotocore and plone.server(aiohttp)
ob = await client.get_object(Bucket=bucket, Key=key)
info = ob['ResponseMetadata']['HTTPHeaders']
resp = aiohttp.web.StreamResponse(headers=aiohttp.MultiDict({
'CONTENT-DISPOSITION': 'attachment; filename="%s"' % self.filename,
'Content-Type': info['content-type']
resp.content_type = info['content-type']
resp.content_length = info['content-length']
vangheem /
Last active May 8, 2017
Export all your tablo vidoes
# Requirements:
# - Python >= 3.5
# - requests
# - aiohttp
import argparse
import asyncio
import json
import os

Keybase proof

I hereby claim:

  • I am vangheem on github.
  • I am vangheem ( on keybase.
  • I have a public key ASCNjRhUMtWBRcsWbhvLA8bxXGTtTbURKVorvouxR9rsdwo

To claim this, I am signing this object: