Skip to content

Instantly share code, notes, and snippets.

@ejucovy
ejucovy / gist:2965585
Created June 21, 2012 12:50
I want a tool that can do this.
egj@alcibiades:~$ echo "PasteScript==1.7.5
> WebOb==1.0
> python-dateutil
> http://launchpad.net/bzr/2.3/2.3.4/+download/bzr-2.3.4.tar.gz
> -e svn+https://svn.socialplanning.org/svn/fassembler/tags/0.4#egg=fassembler-0.4
> -e [email protected]:deliverance/Deliverance#egg=Deliverance-dev" > /tmp/req1.txt
egj@alcibiades:~$ echo "WebOb==1.2
> python-dateutil==2.1
> Paste==1.7.5.1
@ejucovy
ejucovy / gist:3394993
Created August 19, 2012 13:57
Trac FineGrainedPermissions for repository - sample code
from trac.core import *
from trac.perm import IPermissionPolicy
class MultiRepoPermissionSystem(Component):
implements(IPermissionPolicy)
# Helper methods
def parent_repository(self, resource):
while True:
[[PageOutline]]
= Installing and Integrating Trac and Gitolite =
This blog post details how I install Trac and Gitolite using:
* Trac 1.0
* Gitolite v3
* Ubuntu 12.04 LTS
* Python 2.7.3
jQuery(document).ajaxSend(function(event, xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
With 100K tickets and eight custom fields, in the current system:
{{{
2013-02-04 11:27:23,508 Trac[web_ui] INFO: needed 2.1167910099 seconds for searching terms '[u'nardine']'
2013-02-04 11:27:28,881 Trac[web_ui] INFO: needed 2.04926395416 seconds for searching terms '[u'nardine', u'reminiscency']'
2013-02-04 11:27:34,073 Trac[web_ui] INFO: needed 2.05887007713 seconds for searching terms '[u'nardine', u'reminiscency', u'Niagaran']'
2013-02-04 11:27:37,980 Trac[web_ui] INFO: needed 2.05345582962 seconds for searching terms '[u'nardine', u'reminiscency', u'Niagaran', u'pyramidize']'
2013-02-04 11:27:41,786 Trac[web_ui] INFO: needed 2.06689596176 seconds for searching terms '[u'nardine', u'reminiscency', u'Niagaran', u'pyramidize', u'monasterially']'
}}}
@ejucovy
ejucovy / gist:5079195
Last active December 14, 2015 11:29
Initializing a new trac database for an existing environment.
from trac.env import Environment
from trac.db import DatabaseManager
from trac import db_default
env = Environment("/path/to/my/env")
DatabaseManager(env).init_db()
with env.db_transaction as db:
for table, cols, vals in db_default.get_data(db):
db.executemany("INSERT INTO %s (%s) VALUES (%s)" % (table, ','.join(cols), ','.join(['%s' for c in cols])), vals)
${chrome.logging.debug("This is a log message in a genshi template")}
diff --git a/opencore/nui/wiki/bzrbackend.py b/opencore/nui/wiki/bzrbackend.py
index 7d2cad3..6234395 100644
--- a/opencore/nui/wiki/bzrbackend.py
+++ b/opencore/nui/wiki/bzrbackend.py
@@ -5,6 +5,8 @@ import logging
from opencore.interfaces.catalog import ILastModifiedAuthorId
from opencore.utils import get_config
import os
+import pickle
+import cPickle
@ejucovy
ejucovy / wsgi.py
Created October 16, 2013 13:35
Trac WSGI script that sets database uri from environment variable
import os
import trac.web.main
from trac.env import open_environment, Environment
from trac.util import translation
import gc
import threading
def application(environ, start_response):
req = trac.web.main.RequestWithSession(environ, start_response)
run_once = environ['wsgi.run_once']
### pip install pycrypto
import base64
from Crypto.Cipher import AES
from Crypto import Random
import datetime
import hashlib
import hmac
import json
import os