Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Monday, December 3, 2007

will paginate

I've been working on a Rails app as a sort of hobby, it's for a site that I'm prototyping for fun, and we'll see where it goes. I've been off and on, depending on the home schedule, but having a concrete goal helps in my effort to keep my chops up. My areas of focus right now are Ruby, Rails, AJAX, JavaScript (with the Dojo toolkit), as well as CSS and design (never my strong suit). The things I work on lately are quite fun and challenging, but have taken me away from heads-down web app coding for quite a while.

Anyhow, working with the project, pagination turns out to be deprecated in Rails. I grabbed the new plug-in, classic_pagination, but the first thing I got is a notice that it's dead code, and I should move to WillPaginate. I love working with Rails, but the capricious nature of open source does have its drawbacks! Anyhow, I'm working with it, it looks nice. I found a quick jump-start on a RailsCast episode dedicated to pagination, linked here. RailsCast is a fine resource, and I highly recommend it.

One thing I would point out, and something that I'm still working to change, is to wake up to the fact that Rails and Ruby let you pop open a console and work with your code while you code. Try things out, see what responses you get, and if it looks good, copy it into your codebase. As a Java monkey, this is still a foreign mode of operation. The point is, if you're used to coding Java like I am, get used to having that console open, and monkey with your code! Check out the RailsCast, and give WillPaginate a try.


Friday, July 20, 2007

Try NetBeans 6.0 Milestone as your Rails IDE

I don't have a comprehensive analysis, just a general feeling. I really like coding Rails apps using the NetBeans 6.0 Milestone. I love Eclipse, and switch between the IDE's depending on the specific task, so this is not coming from a particular camp.

I like RadRails a lot, but it seems to have stalled a bit. I kept having problems where the IDE would loose my Rake tasks. I found a fix to manually add an Eclipse builder to the project, point it at rake, etc. Even so, I still periodically see the app forget about Rake. A small complaint, really, but it frustrated me enough to switch. What I found in NetBeans is a rather tight-feeling, smooth IDE for Ruby on Rails. No big analysis, just a nice experience. I'm back to coding, and my IDE seems to not forget about rake. Now if only I can remember my anniversary coming up!

Wednesday, June 6, 2007

Nice Comparison of Ruby/Rails IDE's

This morning, my RadRails seems to have forgotten about my projects Rake tasks. I've seen that before, somewhat frustrating. Made me look at the grass across the fence again.

Here's a nice comparison of Rails IDE's, as part of my short detour into alternatives. It looks like grabbing the latest NB 6.0 Milestone gives you the Ruby support.

Monday, June 4, 2007

Rails Authentication

So as I'm working on a couple Rails apps, I'm worried about the best way to authenticate. I had originally done some things with rails authentication and authorization using a rails engine. I pretty much got it to work, but it seemed a bit kludgey. Part of this, I'm sure, is not quite grokking out how the engine was wired in to my app. Chalk it up to a state of perpetual newbie-ness.

So perhaps my feeling about engines is not totally unfounded. I'm not jumping into the whole debate, but there seems to be a split in the Rails community about engines, enough to look for alternatives. Anyhow, I asked a few more experienced rails programmers, and like a chorus they all told me to forget about engines and go with Acts as Authenticated. That's on my plate, I'm going to try this plug in as part of this SlIcer mash-up.

Additionally, I came across this nice review of Rails authorization tools...a good read.

Wednesday, May 2, 2007

2-way messaging with Second Life

So I'm messing with the idea of a messaging hub for Second Life. The idea would be to create a web app that would accumulate messages bound for named objects in Second Life. These would queue up in a database, and be delivered in batches over some period that would not kill the sim in question.

So you'd have a table with stuff like this:

sl_bound_messages
----------------
id
destination (fk to id)
contents (right now, big varchar text)
source (source of message)
delivered_at (time of batch pick-up)
hub_pickup_id (fk to hub)
status (p = pending, b = batched, e = error, n = no object)
date_created (will be queue time)
date_updated

So an external application, fed by a GPS unit, could report the location of a RL object. This hub would accept the report, and hold it until it can push it through to Second Life. The hub could wait for polls from a 'repeater' in SL, which could be a prim running http requests on a timer. The 'repeater' would call up to the hub, get a batch of messages, and then distribute them around to target objects.

Objects in SL could also be hooked into the hub, in two ways:

  • An object can be scripted to listen for, and register with, a hub. The object could report its location in the sim as it is pinged, as well as the unique id that is assigned to it. This gives some ability to track the location of objects within SL, and allows the hub to provide a handle to objects in the sim by relating a name with the SL-assigned unique id.
  • The hub could know the objects it 'has', and route messages to the objects. The hub would request batches of messages on some period.
The hub could keep a registry that looks something like this:

sl_uids
-------
id
sl_uid
object_name
description
type (a = avatar, o = object, h = hub)
last_check_in
object_location_x
object_location_y
object_location_z
date_updated
date_created

So how to efficiantly distribute messages, and how many http requests and deliveries can be done without causing lag is a question, but I have some things in mind given these facilities. Much of LSL is undocumented, so there could also be better ways of doing this, but sure sounds like a fun experiment

The hub would keep a queue of messages like this:

sl_bound_messages
----------------
id
destination (fk to id)
contents
source (source of message)
delivered_at (time of batch pick-up)
hub_pickup_id (fk to hub)
status (p = pending, b = batched, e = error, n = no object)
date_created (will be queue time)
date_updated

Also, a simple event publishing mechanism seems useful, where SL objects publish an event, and RL things can be notified. Simply, a prim with an LSL script could shoot out an http request on some event in SL, this would go up to the hub, and the hub could allow registration of these events to interested parties outside. These events could note the object, object location, and any other relevant data, and the real world could react.

I've got RadRails fired up, and gonna start hacking.

Tuesday, May 1, 2007

Ruby tidbits

This came across my reader, but have not had a chance to dig and delve yet.

Sun Microsystems, Inc. (Nasdaq: SUNW) and the NetBeans(TM) Community, today announced an early access release of the NetBeans Ruby Pack which provides support for the Ruby programming language. The NetBeans plug-in offers developers added support for dynamic and scripting languages and includes editing features for both Ruby and JRuby - a 100% pure-Java(TM) implementation of the Ruby programming language that runs on the Java Virtual Machine.

In the past, I've messed with RadRails, and like it too. I've got a Ruby project in mind that I might start digging into this week, and I'll give it a spin. RadRails is now available over on the Aptana site, and to be folded into the Aptana ide which is another IDE for web development/ajax/css/javascript. Have not tried that either, but some demo shots of Aptana are here.

Needless to say, I've got some catching up to do. I've been focused on a few projects, and if you take your attention away from your feeds for a couple of weeks (and neglect your blog), then you end up behind the curve!

As far as the idea for Ruby, I'm trying to merge my interest in Ruby/Rails, mash-ups, and Second Life. Our group has put up a server dedicated to some Second Life mash-ups, basically a place where scripters working on several UNC islands in SL can collaborate on supporting code. We're starting out looking at tools like silo, and thinking about tools we might gin up. A prime target early on will be to look at better ways to get data in and out of SL. XML-RPC is one mechanism available to push data into Second Life, but it seems unreliable, and I wonder about it's long-term viability.

As an alternative, here's a Rube Goldberg idea, which brings me back to messing with Rails IDE's. Essentially, I'd like to write a store-and-forward queue arrangement. Put out a REST-ful interface on our mash-up server. You may send messages to an arbitrary object in a Second Life sim (and the framework would have to have hooks to resolve a name to a unique id assigned within SL). The framework would accumulate and sequence these messages. Then, build a series of prims that check the queue on a timer, and retrieve bundles of queued messages, routing them to the proper objects within Second Life. These routers could also manage the resolution of SL unique ids.

I'm still new to the environment, so I don't know how silly this is, but sure sounds fun to try!