Skip to content

Instantly share code, notes, and snippets.

<rss version="2.0">
<channel>
<generator>NFE/1.0</generator>
<title>Business - Google News</title>
<link>http://news.google.com?ned=us&amp;hl=en</link>
<language>en</language>
<webMaster>[email protected]</webMaster>
<copyright>&amp;copy;2010 Google</copyright>
<pubDate>Thu, 12 Aug 2010 20:22:17 GMT+00:00</pubDate>
<lastBuildDate>Thu, 12 Aug 2010 20:22:17 GMT+00:00</lastBuildDate>
require 'rubygems'
require 'simplegeo'
require 'sinatra'
require 'nokogiri'
#set :port, 8084
SimpleGeo::Client.set_credentials('', '')
# Accepts subscriptions vcerification and unsubscription verification
get '/ok' do
require "rubygems"
require "addressable/uri"
uri = Addressable::URI.parse("http://example.com/path/to/resource/")
while true
uri = Addressable::URI.parse("http://example.com/path/to/resource/#{rand(10000)}")
sleep 10
end
require "rubygems"
memory_usage = `ps -o rss= -p #{Process.pid}`.to_i # in kilobytes
puts memory_usage
# $ ruby mem.rb
# 8864
merb : worker (port 4000) ~ undefined method `closed?' for nil:NilClass - (NoMethodError)
/usr/lib/ruby/1.8/net/http.rb:1060:in `request'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr.rb:58:in `solr_select'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr/query.rb:63:in `raw'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr/query.rb:84:in `search'
/usr/share/chef-server-api/app/controllers/search.rb:48:in `show'
/usr/lib/ruby/1.8/merb-core/controller/abstract_controller.rb:315:in `send'
/usr/lib/ruby/1.8/merb-core/controller/abstract_controller.rb:315:in `_call_action'
/usr/lib/ruby/1.8/merb-core/controller/abstract_controller.rb:289:in `_dispatch'
/usr/lib/ruby/1.8/merb-core/controller/merb_controller.rb:252:in `_dispatch'
require 'rubygems'
require 'simplegeo' # gem install sg-ruby
require 'nokogiri' # gem install nokogiri
require 'typhoeus' # gem install typhoeus
require 'sinatra' # gem install sinatra
##
# About:
# This little script, sacca.rb allows you to save a gowalla user's checkins to a layer on SimpleGeo.
# it's using PubSubHubbub (Gowalla's hub is at http://hub.gowalla.com/) to subscribe to the Atom feed
##
# 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
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
<?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
-->
...
<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>
...
...
...