Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tschellenbach's full-sized avatar

Thierry Schellenbach tschellenbach

View GitHub Profile
@tschellenbach
tschellenbach / replace_url_param.py
Created September 16, 2011 13:58
Very super simple url param replace for when u cant use a querydict
import re
def replace(url, key, value):
p = re.compile('%s=[^=&]*' % key, re.VERBOSE)
return p.sub('%s=%s' % (key, value), url)
url = 'http://www.google.com/?a=b&c=d&d=f'
print replace(url, 'a', 'test')
print replace(url, 'c', 'test')
print replace(url, 'd', 'test')
@tschellenbach
tschellenbach / solr_config.xml
Created May 16, 2011 11:13
solr schema tag search
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
<luceneMatchVersion>LUCENE_31</luceneMatchVersion>
<lib dir="../../contrib/extraction/lib" />
<lib dir="../../dist/" regex="apache-solr-cell-\d.*\.jar" />
<lib dir="../../dist/" regex="apache-solr-clustering-\d.*\.jar" />
<lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />
<lib dir="../../contrib/clustering/lib/" />
@tschellenbach
tschellenbach / Django Mock Request Object.py
Created April 18, 2011 12:54
Fake django requests for testing purposes
from django.core.handlers.base import BaseHandler
from django.test.client import RequestFactory
class RequestMock(RequestFactory):
def request(self, **request):
"Construct a generic request object."
request = RequestFactory.request(self, **request)
handler = BaseHandler()
handler.load_middleware()
for middleware_method in handler._request_middleware: