'River of news' code sample in ruby? - ruby

Looking for a good example of a 'River of News' implementation done in Ruby. Rails, merb, sinatra or any other web framework would work. I have a couple ideas about how to implement it, but would love to see how people would do it.
The implementation should load more items into the same page as soon the user reach the bottom of the document.
For more information about the 'River of News' format, please check this video about humanized reader at vimeo.

I know about Mars, a river-of-news aggregator written by Sam Ruby as a port of Venus (which is written in Python and is a refactoring of Planet). Please note that, however, it doesn't use a web framework; if this is a strict requirement on your part, then Mars may not be what you need.
Venus, the aggregator which the Mars port has originated from, comes with extensive documentation: some (most?) of it should probably be valid for Mars, too; you may be particularly interested in the architectural diagram of the software.

Related

Dummies tutorial for Websocket in tomcat8 server and client

My first post.
I have experience of basic java servlet and jsp and have got my webpage implemented in tomcat7.
Regarding Websocket, I am finding difficult to build understanding of how to implement it, i want to use tomcat8 implementation of websocket api and uplift my webpage (jsp, java, jquery, tomcat7) to use the websocket features, have not been able to find the the tutorial that can guide me through, something like hello world example. any pointers (sample codes, tutorials)?
have tried to understand tomcat8 examples but not understanding them at all
You need to understand that you don't just "add" WebSocket to an existing web application.. to make it faster, better, cheaper, more scalable, etc. Instead, you have to completely re-architect the web-layer of the application to take advantage of its capabilities.
I suggest that you first read a lot about WebSocket and what the whole idea is before you try to write any code, using Tomcat or any other WebSocket-capable server.
Nick Williams has a forthcoming book that appears to cover everything in the web application world, and as I understand it, will have a great deal of information about WebSocket-based code. You will unfortunately have to wait until March 2013 (at least) to use that particular book.
I'm sure there are similar books available, or even online tutorials to help get you started using WebSocket. Just be aware that switching to WebSocket isn't some simple configuration option: it's a very disruptive change to any existing web application.

Ruby Torrent Library

Is there any good library for Ruby to work with BitTorrent trackers? To download or seed files. There's a rubytorrent library on rubyforge, but it was last updated in 2005 and doesn't seem like working anymore.
see lib-torrent ruby...
https://github.com/maran/libtorrent-ruby
I'm not sure if this is what you want.
Also see this post which contains some potentially useful comments as well, including a Ruby wrapper for the Transmission API using RPCs.
My experience with libtorrent derived clients has been very positive, I would like to see something new here. (I prefer the high density interface & advanced features of qbittorrent to the sparse UI of Transmission.)
A torrent client that exchanges DHT buckets to crawl the public DHT... ?
(No web searching required.)

Getting started with Sinatra, CouchDB & CouchRest?

I'm just starting to learn my way around CouchDB and Sinatra, but am struggling to find some basic examples of integrating the two via CouchRest. The CouchRest docs assume a little too much to be useful to me yet.
Does anyone have links to useful examples/articles/docs?
Sinatra docs are pretty great and easy to work with.
The examples in the couchrest repo seem to show a lot of use cases. https://github.com/couchrest/couchrest_model
The best way to understand code (and especially bleeding edge ruby) is to just read the code.
Updated, with link to tutorial: http://japhr.blogspot.com/2009/03/spike-sinatra-and-couchdb.html
You should probably look into the couch_potato library too, it just hits the sweet spot between the basic approach of couch rest and active record. Source and examples: https://github.com/langalex/couch_potato

How do I move from C#/ASP to Ruby?

I have recently designed a web application that I would like to write in Ruby. Coming from a ASP background I designed it with method and fields and linked them together (in my diagram and UML) like I would do it in C#.
However, now that I've moved from a single app to MVC I have no idea where my code goes or how the pieces are linked.
For example, my application basically collects information from various sources for users, and when they log in the information is presented to them with "new" information (information collected since last login) is tagged specially in the interface.
In C# I would have a main loop that waits let's say 5 minutes and does the collection, then when a client tries to connect it would spawn a new thread that generates the page with the new information. Now that I'm moving to Ruby I'm not sure how to achieve the same result.
I understand that the controller connects the model to the view and I thus assume this is where my code goes yet I've haven't seen a tutorial that talks about doing what I've mentioned. If someone could point me to one or tell me precisely what I need to do to turn my pseudocode into production code I'd be extremely grateful and probably will still have hair: D
EDIT: Somehow I forgot to mention that I'll be using the Rails framework. I don't really like Ruby but RoR is so nice together that I think I can put up with it.
The part of your application that is retrieving the data at certain interval shouldn't be, strictly speaking, part of the web application. In Unix world (including Rails), it would be implemented either as a daemon process, or a cron job. On Windows, I presume that Windows service is the right tool.
Regarding C# -> Ruby transition, if that's purely for Rails, I'd listen to the George's advice and give ASP.NET MVC a shot, as it resembles Rails logic pretty closely (some would call it a ripoff, I guess ;)). However, learning a new language, especially so different than C# as Ruby is, is always a good idea and a way to improve yourself as a developer.
I realize you want to move to Ruby; but you may want to give ASP.NET MVC a shot. It's the MVC framework on the ASP.NET platform.
Coming from ASP, you're going to have to do a lot of conversion to change your code to become more modular. Much more than any one post on Stack Overflow will do justice.
MVC is made up into 'tiers':
Model - Your Data
View - What the user Sees
Controller - Handles requests and communicates with the View and Model.
Pick up a book on ASP.NET MVC 1.0, and do some research on the MVC pattern. It's worth it.
Whatever Ruby web framework you plan to use (Rails, merb, Sinatra), it sounds like the portion that collects this data would typically be handled by a background task. Your models would be representations of this data, and the rest of your web app would be pretty standard.
There are some good Railscast episodes on performing tasks in the background:
Rake in Background
Starling and Workling
Custom Daemon
Delayed Job
There are other options for performing tasks in the background (such as using a message queue and the ActiveMessaging plugin) but these screen casts will at least give you a feel for how background jobs are generally approached in Rails.
If you perform these tasks on a regular schedule, there are tools for that as well.
I hope this is of some help.
Check out Rails for .NET Developers. I've heard good things about this book and it sounds like it's just what you're looking for.

Ruby support for XML namespaces

I work at a small company and our production system uses a hand-rolled RESTful API, implemented in Java with JAXB. We now find that we're taking on customers who use Ruby on Rails, and I have to come up with a reference implementation to show customers how to use our API in Ruby. I'd love to be able to just tell them to use ActiveResource, but the XML required by our API uses (and absolutely requires) namespaces. Unfortunately, we've already got a number of other customers who've already integrated this API, so removing the usage of namespaces is out of the question. What's the best way to generate XML with namespaces in Ruby ?
"Best" obviously depends on your needs.
The fastest way to generate any XML in ruby is to use libxml-ruby - link to rdoc.
If your server gets any kind of load at all, this will be the way to go.
The easiest way to generate any XML in ruby is to use REXML as it's part of the standard library and therefore it "just works". If your XML generation is something that hardly ever gets used, it's probably easier to just go with rexml.
Both support XML namespaces - check the rdocs to find out how to set and get namespaces
I find myself in almost an identical situation as yours (RESTful API done with JAXB w/ namespaces).
I think the most promising project for working with XML in Ruby is HappyMapper. It is a kind of XML binding library (along the lines of an early JAXB-type implementation). It has been gaining a lot of traction recently, and a few of us have been working on providing good namespace support.
The project resides here:
http://happymapper.rubyforge.org/
with the source here:
http://github.com/jnunemaker/happymapper/tree/master
The project currently doesn't support creation of XML from Ruby Objects, and the original author has expressed no desire to provide that support, but I'll be committing some functionality for that in my fork:
http://github.com/jimmyz/happymapper/tree/master
Hope this helps.
--
Jimmy Zimmerman

Resources