Trackmap Improvements
Eric Hodel | Tue, 22 Nov 2005 08:53:00 GMT
- Attach photos by flickr username, email, or NSID
- Attach photos from the track create
- Multiple photo support “N photos total” if more than one photo per point
- Using the 75×75 size photos for faster loading of bubbles
- More/better error messages
- Tracks of unknown format will automatically get emailed to me
- Switched to the large slider for easy zooming
TODO:
- Text blurbs
- Photo titles
- Track deletion
- Photo deletion
- Time zone support
- Accounts so you don’t have to set your flickr info/time zone offset every time
- Better-looking markers
- Marker images
More Trackmap
Eric Hodel | Mon, 21 Nov 2005 21:59:00 GMT
I’ve got the current revision of Trackmap running. Routes of interest are:
Trackmap
Eric Hodel | Mon, 21 Nov 2005 10:28:00 GMT
OMG OMG OMG!
This is cooler than I thought it would be!
But maybe that’s just because its 2:30 and I just made it work!
From the Flickr description:
Trackmap combines GPS tracks + Google Maps + Flickr to give something totally sweet.
I have some issues to work out with threading, but those may be related only to WEBrick mode.
Pay no attention to the typo in the title bar.
Open-uri makes tests easy
Eric Hodel | Mon, 21 Nov 2005 01:28:00 GMT
Neither of the two Ruby Flickr APIs do what I want. One stomps all over the global namespace (Photo will be a model class, it adds a Photo class at the toplevel) and doesn’t have the photo taken date as one of its properties. The other doesn’t support the search method (you get back an XML blob instead of a collection) or the photo taken date.
Neither has tests, so I wasn’t going to figure out how to add what I wanted to either. Instead, I decided to wrap as much of the API as I needed with something that I could test.
On a whim, I decided to use open-uri instead of Net::HTTP. This made testing super-easy. I don’t have to touch the network at all, other than to get a blob of XML to feed into the test:
class Flickr
attr_accessor :responses, :uris
def open(uri)
@uris << uri
yield StringIO.new(@responses.shift)
end
end
class FlickrTest < Test::Unit::TestCase
def setup
@flickr = Flickr.new 'API_KEY'
@flickr.responses = []
@flickr.uris = []
end
Then a test simply adds the XML blobs it is supposed to receive from flickr up-front. After performing the request, I assert it attempted to fetch the correct URLs along with the rest of the stuff the method was supposed to do. (Search is paginated, and I wanted to fetch all the photos without making things clumsy for the user.)
def test_photo_get_info
@flickr.responses << <<-EOF
...
EOF
info = @flickr.photo_get_info :photo_id => 59864477
assert_equal 1, @flickr.uris.length
assert_equal 'http://flickr.com/services/rest/...',
@flickr.uris.first
assert_equal Time.at(1131153707), info[:date_taken]
assert_equal Time.at(1131153708), info[:date_uploaded]
end
Array#pack vs Tiger defeats ruby-growl
Eric Hodel | Tue, 15 Nov 2005 05:53:00 GMT
Tiger’s Ruby thinks its running on an x86, so I had to release ruby-growl 1.0.1.
The meat of the change was
pack_format.gsub!(/n/, 'v') if BROKEN_PACK where BROKEN_PACK = [1].pack("n") != "\000\001"
Thanks to Aslak Hellesoy for bringing this up, I’ve been running my own Ruby and only using ruby-growl from a FreeBSD box so never would have known it was broken.
Using Queues
Eric Hodel | Fri, 11 Nov 2005 22:34:00 GMT
I have a multithreaded program that updates RSS feeds for 43 People and I want it to finish without leaving any feeds on the Queue or in-process.
Originally I had a bunch of worker threads in a ThreadGroup and when I finished enqueueing records from the database I would repeatedly grab a thread out of the group and join it until there were no more threads left. Unfortunately attempting to join a thread waiting for an item to appear on the Queue will cause the thread to wait forever so I could never exit.
To exit cleanly I went with this approach:
t = Thread.start do
loop do
break if @done and @queue.empty?
begin
feed = @queue.pop true
secs = time { feed.refresh REFRESH_TTL }
log "Updated feed #{feed.id} in #{secs}s"
rescue ThreadError
sleep 0.5
end
end
end
By passing true to Queue#pop you end up with a ThreadError if there is nothing to pull from the queue. I added a short delay to keep the process from busy-looping in case the DB reader thread is delayed. When the DB reader is done, it sets @done to true so the updater thread knows to finish.
Now I don’t have to worry about the updater script exiting while there are jobs in-flight.
Another way is to add a Queue for receipts and compare feeds issued for update to update receipts, but that isn’t nearly as simple as a delay and attempting to pop again.
DOS Vuln in Rails
Eric Hodel | Tue, 01 Nov 2005 01:09:00 GMT
And I’m not telling you what it is, unless you’re named zenspider.
MogileFS + Ruby take one
Eric Hodel | Sun, 30 Oct 2005 04:21:00 GMT
Right now I just support file operations, and only over NFS since FreeBSD + HTTP mode don’t like each other. I’ll get the admin operations finished next, then I’ll have something shippable.
MogileFS + NFS = hard
Eric Hodel | Sat, 29 Oct 2005 11:26:00 GMT
I couldn’t get HTTP mode working, but I didn’t try very hard. It looks like the components only conditionally include Linux::AIO, but I’m not sure.
I submitted a documentation patch for MogileFS + NFS to the mailing list to help out the next people who try this. Its really only two extra sentences that you need.


Articles