Skip to content

Instantly share code, notes, and snippets.

View macagua's full-sized avatar
🏠
Working from home

Leonardo J. Caballero G. macagua

🏠
Working from home
View GitHub Profile
@simahawk
simahawk / gist:2043829
Created March 15, 2012 11:47
zeo conf for buildout
[buildout]
parts +=
zeoserver
client1
client2
cljobs
cldebug
[zeoserver]
recipe = plone.recipe.zeoserver
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active March 31, 2025 12:04
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@mpampols
mpampols / add_subscriber.py
Created March 31, 2012 14:32
Add / Remove Plone object subscribers and send a notification email on state change
# Add a subscriber email to Plone object with Subscribers field
def add_subscriber(self,plone_object,email):
from Products.PythonScripts.standard import html_quote
from Products.CMFCore.utils import getToolByName
plone_utils = getToolByName(self, 'plone_utils', None)
workflowTool = getToolByName(self, "portal_workflow")
@knzm
knzm / cjk.map
Created April 3, 2012 07:40
sphinx latex-pdf
% Takaoフォントファミリー
%% 明朝系
rml H TakaoMincho.ttf
rmlv V TakaoMincho.ttf
rml-jis H TakaoMincho.ttf
%% ゴシック系
gbm H TakaoGothic.ttf
gbm V TakaoGothic.ttf
gbm-jis H TakaoGothic.ttf
@hvelarde
hvelarde / pre-commit
Created June 5, 2012 22:14
PEP 8 pre-commit hook
#!/bin/sh
# Modified from kevincal version in https://gist.github.com/810399
# The following is a list of the most common PEP 8 errors and warnings; to
# skip some just add them to the IGNORE variable (comma separated):
# E111 indentation is not a multiple of four
# E123 closing bracket does not match indentation of opening bracket's line
# E201 whitespace after '('
# E202 whitespace before ')'
from PdbTextMateSupport import preloop, precmd
pdb.Pdb.preloop = preloop
pdb.Pdb.precmd = precmd
alias inspect import inspect;print inspect.getsource(%1)
alias i import inspect;print inspect.getsource(%1)
alias h !print help(%1)
alias help !print help(%1)
alias wtf !import traceback;traceback.print_exc()
alias ppo pp %1.__dict__
alias ppio pp [a.__dict__ for a in %1]
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bosim
bosim / exportVocabulary.py
Created October 3, 2012 09:57
Script for exporting ATVocabularyManager vocabularies to IMS VDEX format. Put it in the "custom" folder and access it using http://<my-site>/portal_vocabularies/<vocabName>/exportVocabulary
def recurse(element):
elements = []
for item in element.objectValues():
d = {'uid' : item.UID(),
'title' : item.title,
'children' : []}
if hasattr(item, 'objectValues'):
d['children'] = recurse(item)
elements.append(d)
return elements
@kroger
kroger / gist:3856749
Created October 9, 2012 05:14
Show code examples in Sphinx
from __future__ import division
import os
import sys
import codecs
import textwrap
from StringIO import StringIO
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from sphinx.directives.code import LiteralInclude
from sphinx.util.nodes import set_source_info
@bosim
bosim / varnish.vcl
Last active August 25, 2016 06:33
Basic varnish configuration for Plone
acl purge {
"localhost";
}
director plone_director round-robin {
{
.backend = {
.host = "127.0.0.1";
.port = "50020";
.probe = {