Skip to content

Instantly share code, notes, and snippets.

@glenfant
glenfant / Vagrantfile
Last active August 29, 2015 14:09
Vagrantfile for taiga-vagrant that supports OSX AND Linux. Contrib for Windows Welcome. See https://github.com/taigaio/taiga-vagrant/issues/15
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "./source.rb"
ROOT_PATH = File.dirname(__FILE__)
VAGRANTFILE_API_VERSION = "2"
def configure_extra(config)
end
@glenfant
glenfant / dottedname.py
Created January 6, 2015 11:46
Turns a dotted name in a string as 'sys.path' into a Python object
# -*- coding: utf-8 -*-
"""
==========
dottedname
==========
This module may be used when you need to refer to Python objects from non
Python files. For example, in a configuration file.
Resolve a python dotted name (stolen from zope.dottedname)
@glenfant
glenfant / mlsearch.py
Created January 16, 2015 17:31
Attempt to record a new query as extended REST service in ML 7
# -*- coding: utf-8 -*-
"""
Provided a new XQuery, we record it as extended REST resource in ML 7 server
"""
import httplib
import urlparse
import requests
@glenfant
glenfant / buildout.cfg
Created March 9, 2012 12:59
Add Products.PloneFilesZip to Plone 4.1.3
############################################
#
# Buildout Configuration File for ZEO Plone
# -----------------------------------------
# $LastChangedDate: 2011-08-05 17:56:09 -0700 (Fri, 05 Aug 2011) $ $LastChanged$
#
# After making changes in this configuration file,
# you should run bin/buildout to update the components.
#
# ALWAYS back up all Plone/Zope data and components
@glenfant
glenfant / test_aws_with_splinter.py
Created July 22, 2012 18:30
Démonstration de Splinter
# -*- coding: utf-8 -*-
"""Tests de www.alterway.fr avec splinter"""
# Préambule
import splinter
HOME = 'http://www.alterway.fr'
browser = splinter.Browser('firefox')
# On va à la page d'accueil
@glenfant
glenfant / issueorderinglist.py
Created August 28, 2012 15:30
sqlalchemy OrderingList issue
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy import Column, Integer, Text, ForeignKey
sa_engine = create_engine("sqlite:///:memory:")
@glenfant
glenfant / recurse_to_jpg.py
Last active December 11, 2015 08:09
Hint to David Hernandez
import os
from PIL import Image
# Prefer the r"xxx" notation when you have backslashes
pathe = r"C:\David\"
for (path, dirs, files) in os.walk(pathe):
print path
print dirs
print files
for archivo in files:
@glenfant
glenfant / buildout.cfg
Created June 29, 2013 12:40
Make a wsgi script with zc.buildout (buildout.cfg)
[wsgiscript]
# Build the wsgi script for mod_wsgi
recipe = z3c.recipe.runscript
install-script = ${buildout:directory}/buildouthelpers.py:make_wsgi_script
update-script = ${:install-script}
# Parameters
egg = egg.with.wsgiapp
script = ${buildout:parts-directory}/wsgiscript/myapp.wsgi
@glenfant
glenfant / buildouthelpers.py
Last active December 19, 2015 03:29
Make a wsgi script with zc.buildout (buildouthelpers.py)
WSGISCRIPT_TEMPLATE = """\
# -*- coding: utf-8 -*-
import sys
import os
sys.path[0:0] = [
{0}
]
_application = None
@glenfant
glenfant / timeoutctxmanager.py
Last active December 28, 2015 12:39
This is a (Unix only) context manager that cancels the execution of its inner code block when its timeout is gone. Note: deprecated, see my "stopit" third party package.
# -*- coding: utf-8 -*-
"""
This recipe provides a context manager that stops the execution of its inner
code block after the timeout is gone. This recipe is stolen with some changes
and rewording in a less app centric vocabulary from the "rq" package.
https://github.com/glenfant/rq/blob/master/rq/timeouts.py.
Warnings: