Skip to content

Instantly share code, notes, and snippets.

View toastdriven's full-sized avatar

Daniel Lindsley toastdriven

View GitHub Profile
<!doctype html>
<html>
<head>
<title>Commits</title>
<script src="socket.io.js"></script>
</head>
<body>
<script>
io.setPath('/client/');
@toastdriven
toastdriven / design.css
Created October 26, 2010 15:57
My theme for Textual
/* Basic Body Structure */
* {
margin: 0;
padding: 0;
font-size: 100%;
word-wrap: break-word;
}
body {
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from myapp.models import Note
def note_detail(request, slug):
note = get_object_or_404(Note, slug=slug)
editable = False
if request.user.is_authenticated:
@toastdriven
toastdriven / RiakHttp10k.txt
Created October 29, 2010 14:26
Benching Riak's performance with the Python client.
[daniel@Europa:Desktop]: python riak_test.py
Inserting 0
Inserting 1000
Inserting 2000
Inserting 3000
Inserting 4000
Inserting 5000
Inserting 6000
Inserting 7000
Inserting 8000
from haystack.indexes import *
from haystack import site
from cab.models import Snippet
class SnippetIndex(SearchIndex):
text = CharField(document=True, use_template=True)
author = CharField(model_attr='author__username')
title = CharField(model_attr='title')
tags = CharField()
tag_list = MultiValueField()
@toastdriven
toastdriven / riak_blog.py
Created November 17, 2010 05:35
The storage layer for a simple Riak-powered blog.
import riak
import uuid
import time
# For regular HTTP...
# client = riak.RiakClient()
# For Protocol Buffers (go faster!)
client = riak.RiakClient(port=8087, transport_class=riak.RiakPbcTransport)
@toastdriven
toastdriven / privatebrowse.scpt
Created January 7, 2011 22:46
Private Browse for Textual
# Drop me in ``~/Library/Application Support/Textual/Scripts``...
# Usage is: ``/privatebrowse <url>``
on textualcmd(input)
tell application "Google Chrome"
activate
end tell
tell application "System Events"
tell process "Google Chrome"
tell menu bar 1
start on runlevel [23]
stop on runlevel 1
stop on shutdown
respawn
script
cd /home/solr
java -jar start.jar
end script
@toastdriven
toastdriven / autocomplete.py
Created February 21, 2011 19:12
How to make multiple word autocomplete work in Haystack.
import operator
from haystack.query import SearchQuerySet, SQ
query = 'lil way'
sqs = SearchQuerySet().filter(reduce(operator.__and__, [SQ(name=word.strip()) for word in query.split(' ')]))
# At a shell...
mkdir whooshtest
cd whooshtest
virtualenv --no-site-packages .
. bin/activate
./bin/pip install -E . django
./bin/pip install -E . django-haystack
./bin/pip install -E . whoosh==1.2.6
./bin/django-admin.py startproject whooshtest