Skip to content

Instantly share code, notes, and snippets.

@davisagli
davisagli / releasenotes.yml
Created September 7, 2022 01:15
Github action to preview release notes
name: Preview release notes
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
release-notes:
@davisagli
davisagli / pipes.py
Last active February 27, 2020 05:09
pypes
import inspect
import itertools
class Pipe:
def __init__(self, source):
self.source = source
def __or__(self, sink):
if inspect.isgenerator(self.source) and not inspect.isgeneratorfunction(sink):
schema:
{
"properties": {
"behaviors": {
"additionalProperties": {
"oneOf": [
{
"properties": {
"@type": {
# Change set.__module__ to 'builtins'
# so that it will pickle with the right module for Python 3
from ctypes import Structure, c_ssize_t, c_void_p, c_char_p
class PyTypeObject(Structure):
_fields_ = [
('ob_refcnt', c_ssize_t),
('ob_type', c_void_p),
('ob_size', c_ssize_t),
('tp_name', c_char_p),
]

Keybase proof

I hereby claim:

  • I am davisagli on github.
  • I am davisagli (https://keybase.io/davisagli) on keybase.
  • I have a public key ASDutQViikK1K9Mb7n1PuFHh81ZWUMYDNO-OEIorm5xxTwo

To claim this, I am signing this object:

@davisagli
davisagli / filemaker.py
Created May 17, 2016 19:15
Filemaker CSV reader
import csv
class FilemakerCSVDictReader():
"""CSV reader to read Filemaker CSV exports as dicts.
Applies a few transformations to all values:
* Decodes as cp1252
* Replaces vertical tabs with newlines
* Splits fields containing the Group Separator control character into lists
@davisagli
davisagli / gist:0315c6d206351c5daa4c
Created October 29, 2014 17:15
class for using CiviCRM API from Python
import json
import requests
class Action(object):
def __init__(self, entity, name):
self.civi = entity.civi
self.entity_name = entity.name
self.name = name
@davisagli
davisagli / gist:23663cfa164460f3b3a2
Created September 25, 2014 19:47
Using the CloudShare API from Python
from hashlib import sha1
import random
import requests
import string
import time
# these come from your CloudShare account page
USER_ID = ''
KEY = ''
@davisagli
davisagli / gist:1128383064b1ba5c06b4
Last active May 19, 2021 00:24
authenticating to google API using Service Account credentials
import httplib2
# these are from the google-api-python-client package
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
def _get_google_service(email, key):
"""Get a Google API client using Service Account credentials"""
credentials = SignedJwtAssertionCredentials(
from Products.Five import BrowserView
from zope.interface import implementer
from zope.publisher.interfaces.browser import IPublishTraverse
@implementer(IPublishTraverse)
class AuthorView(BrowserView):
user_id = None
def publishTraverse(self, request, name):