Skip to content

Instantly share code, notes, and snippets.

@sbp
sbp / run.sh
Created January 19, 2010 22:37
#!/bin/bash
function cleanup() {
echo Quitting
kill -9 %1
exit
}
trap cleanup 2
~/bin/redis-server &
@sbp
sbp / server.js
Created January 19, 2010 23:56
/*
* server.js — Ampify Draft Server
* Author: Sean B. Palmer, inamidst.com
* License: Creative Commons Attribution 3.0
*
* Source: http://gist.github.com/281449
* Helper: http://gist.github.com/281380
* Requires: (a) redis, (b) nodejs (c) redis-node-client
*/
#!/usr/bin/env python
"""
fieldtree.py - Field Tree Object
Author: Sean B. Palmer, inamidst.com
The FieldTree object is a kind of OrderedDict. The name Field refers
to a label and value pair, usually called an item in Python.
There are two main extra features that a FieldTree provides over an
OrderedDict. The first is that when a field is set, it returns a Key
common = 74
results = []
# following function from http://bit.ly/ftnW6
def factor(n):
if n == 1: return [1]
i = 2
limit = n**0.5
while i <= limit:
if n % i == 0:
@sbp
sbp / gist:604382
Created September 30, 2010 10:40 — forked from tav/gist:604107

The project is about the delivery of Espra -- an open source, web-based social platform that sets out to improve quality of life and create new market opportunities by helping to efficiently organise people, ideas and resources. Espra will significantly improve people's ability to function in the digital world by tackling information overload and allowing content creators to get paid for their work.

To this end Espra brings together innovative solutions built around Trust Maps, which will help people filter and overcome information overload, and a Reputation Economy, which will enable content creators to get rewarded for their works through aggregated micropayments.

Espra fulfills parts of the Technology Strategy Board's wider Digital Britain Strategy of enabling "a sustainable marketplace for intellectual property" and helping create "economic and social benefit from increasing volumes of information".


The ability to filter information flow through Trust Maps and the use of aggregated micropayments

@sbp
sbp / example.mkdn
Created October 23, 2010 11:46
Example markdown file.
@sbp
sbp / codeshui.txt
Created October 29, 2010 22:05
Code Shui
def moveLeft(self):
y, x, q, p = self.position()
schar = self.editor.doc.getStartchar(q)
if x: self.editor.moveCursor(y, x - 1)
elif schar:
start = max(0, schar - self.editor.maxx - 5)
self.editor.doc.setStartchar(q, start)
self.drawline(y)
self.editor.moveCursor(y, min(p - 1, self.editor.maxx))
elif (y or self.editor.doc.startline):
@sbp
sbp / tags9091.html
Created January 1, 2011 13:33
Protovis scatterplot of HTML tag frequencies from 1990 to 1991
<!DOCTYPE html>
<title>Scatterplot</title>
<script type="text/javascript" src="protovis-r3.2.js"></script>
<div id="fig">
<script type="text/javascript+protovis">
var data = [
{date: new Date(1991, 1, 28), tag: "dd", count: 30},
{date: new Date(1991, 1, 28), tag: "p", count: 1},
{date: new Date(1991, 1, 28), tag: "title", count: 4},
// [...]
@sbp
sbp / gender.cgi
Created January 2, 2011 22:09
Python CGI to show the gender of words in various languages
#!/usr/bin/env python
import cgitb
cgitb.enable()
import os, re, urllib, json
from htmlentitydefs import name2codepoint
def GET(uri):
u = urllib.urlopen(uri)
@sbp
sbp / hyperion.py
Created January 7, 2011 13:51
Convert plain text to simple hypertext
#!/usr/bin/env python
'hyperion - Convert Text to Hypertext'
author = 'Sean B. Palmer, inamidst.com'
modified = '2010-12-10 22:59'
import sys, os.path
def encode(text):
text = text.replace('&', '&amp;')