June 2010
2 posts
This Week in Google with Chris Messina on OAuth and OpenID http://peter-hoffmann.com/2010/twig-chris-messina-oauth-openid.html
PubSubHubbub for Json http://peter-hoffmann.com/2010/pubsubhubbub-for-json.html
January 2009
2 posts
iterate over list by pairs
The following code will iterate over an list by pairs of elements:
from itertools import chain
def by_pairs(iterable):
sequence = iter(iterable)
previous = sequence.next()
while True:
current = sequence.next()
yield previous, current
previous = current
store json data with sqlobject in mysql database
Especially while developing the final database schema I find pleasant
to store JSON data structures direct in the database. SQLObject has a PickleCol,
but I has the downside, that serialized objects are binary based and thus not
very well to debug.
The following codes need sqlobject as well as formencode:
from sqlobject import *
sqlhub.processConnection = connectionForURI("...")
import...
December 2008
1 post
installing cloudkit on ubuntu 8.10
Installing cloudkit on ubuntu 8.10:
sudo aptitude install rubygems ruby1.8-dev libsqlite3-ruby libhttp-access2-ruby
sudo gem install hoe
sudo gem install sequel -v 2.6.0
sudo gem install thin
sudo gem install cloudkit
Create a configuration file config.ru
require 'cloudkit'
expose :notes, :projects
Start thin with:
/var/lib/gems/1.8/bin/thin -R config.ru start
For more Information...
October 2008
3 posts
vim toogle spell
Toggle spell language and on/off in vim
function! ToggleSpell()
if &spell
if &spelllang == "de"
set spelllang=de,en
echo "toggle spell" &spelllang
elseif &spelllang == "de,en"
set spelllang=en
echo "toggle spell" &spelllang
else
set spell!
echo "toggle spell off"
endif
...
blinkenlights project stereoscope in toronto
The latest blinkenlights project is to transform
the Toronto City Hall into a big interactive computer matrix. The installation
is part of the nuit blache.
The project also provides an iphone simulator (app
store)
which displays a live stream from Toronto.
More images can be found on
flickr
3 tags
http pubsub
I’m looking for some kind of http pubsub messaging server. Just found some
blog posts but nothing I really like:
Webhooks
Joshua Schachter about beyond
rest
xmlrouter
September 2008
7 posts
2 tags
working with uuids on python
Python has a module to generate different UUIDs like defined in RFC 4122.
uuids include creation time. This recipe extracts the timestamp
information:
def get_posixtime(uuid1):
"""Convert the uuid1 timestamp to a standard posix timestamp
"""
assert uuid1.version == 1, ValueError('only applies to type 1')
t = uuid1.time
t = t - 0x01b21dd213814000
t = t / 1e7
return...
middleware to monitor python wsgi applications
I’m working on some RESTful python wsgi application. For debugging and
monitoring I needed a way to see the request and response HTTP header
without modifying the actual code.
So I posted the question to
stackoverflow
where Florian Boenisch came up with a nice solution.
from wsgiref.util import request_uri
import sys
def logging_middleware(application, stream=sys.stdout):
def...
twitter export friends as foaf
A small python script to export your twitter friends.
The script can export the raw screen_names or export an Friend of a Friend
(foaf) RDF file.
If you want to use the foaf type export you need to install the python RDF
library and have a valid twitter user account to access the API. The
python-twitter library is needed anyway.
Usage:
python twitterFriends.py user
python twitterFriends.py...
language statistics for twitter users with python
guess-language is a nice python
script to determine the language of some text. Very useful:
import guess_language
import twitter
api = twitter.Api()
from collections import defaultdict
def guess(username, restrict=None):
#download tweets
tl = api.GetUserTimeline(username, count=200)
d = defaultdict(int)
for tweet in tl:
if restrict is None:
lang =...
Python Interface to vim
Vim has a nice python interface:
http://www.vim.org/htmldoc/if_pyth.html
google v8 javascript stanalone
To build the latest V8 JavaScript engine from
google. Make sure you have scons installed
(aptitude install scons).
svn checkout http://v8.googlecode.com/svn/trunk/ v8-read-only
scons mode=debug library=shared snapshot=on
scons sample=shell
Thats all. You can start an interactive session with
./shell
August 2008
10 posts
add syntax highlighting to tumblr
Get the javacsript prettify script from
http://code.google.com/p/google-code-prettify/ and add the following to your
tumblr custom theme.
<link rel="stylesheet" type="text/css" href="http://lifehacks.de/extern/prettify.css"></link>
<script src="http://lifehacks.de/extern/prettify.js"></script>
<body onload="prettyPrint()">
If want to highlight all code...
post to tumblr via vim
Added my changes to the script at http://www.vim.org/scripts/script.php?script_id=2329
Oh, it’s not possible to upload a new version, so I mailed my changes to the author. Hope he merges them in.
post a range from vim to tumblr
add this to your tumblr.vim
command -range TumblrPostRange python PyPostRangeTumblr(<f-line1>,<f-line2>)
def post(title, body):
from tumblr import Api
blog = vim.eval("g:tumblr_blog")
email = vim.eval("g:tumblr_email")
password = vim.eval("g:tumblr_password")
api = Api(blog,email, password)
post = api.write_regular(title, body, format="markdown")
return...
post to tumblr via vim
Another way to post to tumblr is via vim trough the following script:
tumblr.vim
The script has tow minor bugs, you have to replace the imports with
import vim
import urllib
post to tumblr with python
Python-tumlr is a nice python
script to post to http://tumblr.com via their
api.
from tumblr import Api
import sys
import os
import codecs
BLOG='YOU.tumblr.com'
USER='YOUREMAIL'
PASSWORD='YOURPASSWORD'
def post(filepath):
filename = os.path.split(filepath)[-1]
title, ext = os.path.splitext(filename)
title = title.replace("-", " ")
if ext not in [".mkd"]:
print "unknown...
Highlight your friends commtents on...
The userserstyle from http://userstyles.org/styles/8710 must be tweaked a little bit to work with the beta.friendfeed.com design:
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("friendfeed.com") {
.feed .entry div.friend{
background-color: #ffffc0 !important;
}
.feed .entry div.owner{
background-color: #ecf2fa !important;
}
}
Top 200 friendfeed rooms (update 2008-08-22)
1.1272(+379) thirty-day-challenge This is the home of the thirty day challenge on friend feed
2.1267(+87) social-media Have something to share or something to say related to social media? Join the conversation here and let’s get social! Please keep in mind to only post relevant links and pose relevant questions. The experience you have in this room depends on you, so self-moderate and share...
More friendfeed room stistics
There are at least 1564 rooms on friendfeed. In all rooms there are at least 13901 people. Here are the people who are subscribed to the most rooms:
592 divedi Dimitar Vesselinov
189 susanbeebe Susan Beebe
180 mitchelltsai Mitchell Tsai
144 waynesutton Wayne Sutton
130 jasonw22 Jason Wehmhoener
110 web3beta web3beta
97 maryamsharif Maryamss
...
Top 200 friendfeed rooms
1180 social-media Have something to share or something to say related to social media? Join the conversation here and let’s get social! Please keep in mind to only post relevant links and pose relevant questions. The experience you have in this room depends on you, so self-moderate and share wisely.
1143 friendfeed-news The latest updates, blogs and news stories about FriendFeed. For...
looking for an overview of all friendfeed rooms
So I’m still looking for an overview of all friendfeed rooms. There are some lists out there, but they are neither complete, nor do they show the number of participiants:
http://blogoscoped.com/friendfeed/rooms
http://andybeard.eu/2008/05/how-to-find-friendfeed-rooms-with-google.html
Google shows about 14.000 hits but you can only browse the first 10.000. So I’ll have to do some...