Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
<id>tag:pulsejfk.com,2005:/atom</id>
<link type="text/html" href="http://pulsejfk.com" rel="alternate"/>
<link type="application/atom+xml" href="http://pulsejfk.com/atom.xml" rel="self"/>
<title>Pulse JFK</title>
<subtitle>The Pulse of New York City</subtitle>
<link href="http://pulsejfk.superfeedr.com" rel="hub"/>
<link type="html" href="http://twitter.com/pulsejfk" rel="me"/>
<link type="html" href="http://facebook.com/pulsejfk" rel="me"/>
require "rubygems"
require File.join(File.dirname(__FILE__), '..', "lib", "bosh")
Bosh.logger { |message|
puts message
}
@connection = Bosh.connect("[email protected]", "xxx", "http://beta.superfeedr.com/http-bind/")
pslist = <<-EOXML
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>@superfeedr's recently favourited tweets</title>
<description>Tweets by @superfeedr that have been recently favorited</description>
<link>http://favstar.fm/users/superfeedr/recent</link>
<atom:link rel="hub" href="http://favstar.superfeedr.com" />
<item>
# curl "http://www.google.com/reader/atom/user%2F13489847268102873975%2Fstate%2Fcom.google%2Freading-list"
<html><head><title>302 Redirection</title>
<style type="text/css">
body {font-family: arial,sans-serif}
div.nav {margin-top: 1ex}
div.nav A {font-size: 10pt; font-family: arial,sans-serif}
span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight: bold}
div.nav A,span.big {font-size: 12pt; color: #0000cc}
div.nav A {font-size: 10pt; color: black}
A.l:link {color: #6f6f6f}
require 'rubygems'
require 'sinatra'
# Accepts subscriptions vcerification and unsubscription verification
get '/ok' do
params['hub.challenge']
end
# Refuses subscriptions vcerification and unsubscription verification
get '/ko' do
<iq type='set' from='[email protected]' to='firehoser.superfeedr.com' id='sub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub' xmlns:superfeedr='http://superfeedr.com/xmpp-pubsub-ext'>
<subscribe node='http://blog.superfeedr.com/atom.xml' jid='[email protected]' superfeedr:digest='true' />
</pubsub>
</iq>
<message to="[email protected]" from="firehoser.superfeedr.com">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<status xmlns="http://superfeedr.com/xmpp-pubsub-ext" feed="http://domain.tld/my/feed.xml" digest="true">
<http code="200">All went fine</http>
<next_fetch>2010-05-13T10:25:13+02:00</next_fetch>
<title>Hello my friend</title>
</status>
...
...
...
<?xml version="1.0"?>
<feed xmlns:geo="http://www.georss.org/georss" xmlns="http://www.w3.org/2005/Atom" xmlns:as="http://activitystrea.ms/spec/1.0/" xmlns:sf="http://superfeedr.com/xmpp-pubsub-ext" sf:digest="true">
<!--
HTTP Status: 200
Last Message: Awesome we got the feed right
Next Fetch: 2010-05-13T11:29:12+02:00
-->
...
loop do
ids = $redis.rpoplpush("ring", "ring", 50)
items = $redis.get(ids)
ids.each do |item|
if item.time_to_fetch < now()
fetch(item)
else
# skip
##
# This module implements a simple locking algorithm based on redis's SETNX, as described here : http://code.google.com/p/redis/wiki/SetnxCommand
module Lock
@signature = rand(100000).to_s
def self.prefixed(key)
"l:#{key}"
end