News for hackers. Stuff that matters.
Re:What's the best way to stay in a conversation on Hacker N... by petercooper on Friday March 20, 2009 @01:53AM (#524586)
Write a little script that pulls http://news.ycombinator.com/threads?id=<username>; and does some magic to pull out the info into an RSS feed (yes, ideally pg can add this as a real feature, but I'm being pragmatic here ;-)).

Just a messy Ruby-based example I threw together. Works for me.

  require 'rubygems'
  require 'open-uri'
  require 'hpricot'
  
  username = 'petercooper'
  uri = 'http://news.ycombinator.com/threads?id=' + username
  doc = Hpricot(open(uri))
  
  puts %{<?xml version="1.0" encoding="utf-8" ?>
  <rss version="2.0">
  <channel>
  <title>Hacker News responses to #{username}</title>
  <link>#{uri}</link>}
  
  (doc/'td td table').each do |post|
    content = post.inner_html
    next if content =~ />#{username}</       # skip if we posted it
    next unless post.inner_html =~ /vote/    # skip if it's not a post
    id = content[/\_(\d+)/,1]
    comment_text = (post/'.comment').first.inner_text
    commenter = content[/user\?id=(\w+)/,1]
    puts %{  <item>\n    <title>Comment from #{commenter}</title>}
    puts %{    <link>http://news.ycombinator.com/item?id=#{id}</link>}
    puts %{    <description>#{comment_text}</description>\n  </item>}
  end
  
  puts %{</channel></rss>}
It'd be better, but the HTML on Hacker News is from 1996. I was too sloppy to bother fetching the title of the current thread ;-)

With just adding a shebang line and a content-type header line, it works no problems on Dreamhost as a CGI script. Example: http://bigbold.dreamhosters.com/hnc.cgi

Anyway, thanks for giving me the idea. I'm using that now myself.. lol.

Re:What's the best way to stay in a conversation on Hacker N... by jamesheroku on Friday March 20, 2009 @06:36AM (#524741)
Nice work Peter. I wrapped this in two lines of Sinatra and deployed it to Heroku, so anyone can get an RSS feed for their username: http://hackernews.heroku.com/username

Code is here: http://github.com/jnl/hackernews-thread-rss

Re:What's the best way to stay in a conversation on Hacker N... by dreeves on Saturday March 21, 2009 @06:27PM (#526697)
Holy crap, that's handy! Thanks so much!

Out of curiosity (and in hopes of eliciting a reply to see if it shows up in my new Hacker News Responses feed!) would this also be easy to do with Yahoo!Pipes?

Re:What's the best way to stay in a conversation on Hacker N... by petercooper on Sunday March 22, 2009 @04:05AM (#527088)
I wondered about that. I've been using Pipes a little lately but am no expert. I'm not sure if Pipes can deal with operations upon non organized content. You could probably use a service like Feed43 first though.