Skip to content

Instantly share code, notes, and snippets.

@jimfulton
jimfulton / gist:4649546
Created January 27, 2013 18:19
A first stab ant code to build parts of an android project. See open issues in the comment.
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is very much a work in progress.
Issues:
- You have to install scala. We aren't reusing the scala install
embedded in scala-ide.
@jimfulton
jimfulton / svn2git.py
Created January 31, 2013 15:56
Here's a Python script I wrote to convert subverstion projects to git. I wrote it after I had some problems with the Ruby svn2git program. Like the Ruby svn2git program, it's a fairly thin wrapper over the git svn plugin, which does most of the heavy lifting. This isn't "finished", but it's good enough for most cases and I doubt I'll do any more…
##############################################################################
#
# Copyright (c) 2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
@jimfulton
jimfulton / ptest.py
Created April 6, 2013 17:58
Informal comparison of pickling speeds across Python versions. Python 3's pickling speed improvements are impressive, especially given the transparency of the C optimizations.
import sys, time
if sys.version_info[0] == 2:
import cPickle as pickle
else:
import pickle
class C(object):
def __init__(self, i):
self.name = 'my object'
@jimfulton
jimfulton / server.py
Last active December 15, 2015 21:39
I've noticed that buildout tests run much slower on Python 3. This surprised people. I was curious how other things run. Pickling is much faster, https://t.co/y2mSHTDneZ. Here's an informal comparison using the wsgiref server.
# This is taken more or less verbatim from the Python docs for wsgiref
from wsgiref.simple_server import make_server, demo_app
httpd = make_server('', 8000, demo_app)
# Respond to requests until process is killed
httpd.serve_forever()
@jimfulton
jimfulton / sample-session
Last active December 20, 2015 21:49
Stupid little timer for timing grizzled.io.RichInputStream.copyTo. Meant to be run from the sbt console. sample-session shows a sample session copying a file named "src" to a file named "dest".
bash-3.2$ sbt console
scala> :load streamtimer.scala
scala> f("src", "dest")
@jimfulton
jimfulton / gitrpm.py
Created September 19, 2013 21:02
Here's a script we sometimes used to build rpms from git projects....
#!/opt/cleanpython26/bin/python
"""usage: %prog options
Automate tagging and buildoing rpms from hg python projects.
You need to run this on a centos machine.
This probably wants to be a recipe to automatically pull in
buildout-siyrce release. Or maybe this shouldn't involve source
releases.
@jimfulton
jimfulton / README
Last active January 2, 2016 23:19
Script that illustrates issue writing empty nodes w kazoo and reading them with the Python C ZooKeeper API
kazoo script that builds a ZooKeeper tree. To run, with kazoo in the path::
bad.py inp
If you export the tree with zc.zk 1, you'll see random(ish) bad data in the nodes that should be empty.
import sys
import marshal
import json
header = '''<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document>
'''
footer = '</Document></kml>'
@jimfulton
jimfulton / perf.py
Last active August 18, 2016 13:25
A zodb-shootout-like script for measuring ZEO server performance.
import argparse
import logging
import multiprocessing
import os
import persistent
import re
import time
import ZODB
from BTrees.IOBTree import BTree
@jimfulton
jimfulton / perf4.py
Created August 10, 2016 18:58
A zodbshootout inspired by ZEO-specific performance-measurement script.
import argparse
import logging
import multiprocessing
import os
import persistent
import re
import time
import ZODB
from BTrees.IOBTree import BTree