ruby

Is Lua, Perl, Python, or Ruby better suited for Unix system automation?

I am starting a new project to provide monitoring and control services for a number of unix (Linux and FreeBSD) servers (think munin, monit, mrtg, etc). The reason I'm not considering using an already existing monitoring solution is that I need to do checks for custom APIs (like post a specific HTTP request and parse the answer body for ...

ruby pdf parsing gem/library

Hi All, Any recommendations as to which is the bestpdf reading library/gem (free/open source of course) in ruby? I found a list at http://rubyforge.org/search/?type_of_search=soft&words=PDF&Search=Search but want to tap peoples experience in filtering it. I mainly want to parse input pdf files and extract the text within, par...

How to check return packet contents in ICMP Ping / Echo?

When validating ping echo's, it seems that utilities / libraries often only check the checksum of the packet, and don't actually confirm that the payload sent out matches the payload that was returned. For instance, Wireshark's ICMP parser only checks for bad checksums, and that's all that Ruby's net-ruby checks as well. I'm debugging ...

Can I invoke an instance method on a Ruby module without including it?

Background: I have a module which declares a number of instance methods module UsefulThings def get_file; ... def delete_file; ... def format_text(x); ... end And I want to call some of these methods from within a class. How you normally do this in ruby is like this: class UsefulWorker include UsefulThings def do_work ...

Finding relative libraries when using symlinks to ruby executables

Imagine you have an executable foo.rb, with libraries bar.rb layed out in the following manner: <root>/bin/foo.rb <root>/lib/bar.rb In the header of foo.rb you place the following require to bring in functionality in bar.rb: require File.dirname(__FILE__)+"../lib/bar.rb" This works fine so long as all calls to foo.rb are direct. I...

In ruby, why does my IRB interactive debugging session always say "No sourcefile available"

Just trying to get my irb sessions to actually list the current line of code, and those around it. Similar to what Perl's -d debugging mode lets you ddo. ...

What is Ruby on Rails and why is it so famous?

I have never heard about this language until I came to this site, why is it so famous? Could you post some example sites developed in this technology? Easy with the downvotes please, am nub I know :( Thanks ...

Why do Test::Unit testcases start up so slowly?

>rails -v Rails 1.2.6 >ruby -v ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] When I run a test fixture (that tests a rails model class) like this, it takes 20-30 secs to start executing these tests (show the "Loaded suite..."). What gives? >ruby test\unit\category_test.rb require File.dirname(__FILE__) + '/../test_helper' cla...

backgroundrb thread_pool.defer method logger output goes to where?

It seems like due to the threading issue logger.warn (thats what I tested) doesn't generate any output? my code is similar to this: def deliver(args) logger.info "delivery start" thread_pool.defer(:deliver_deferred, args) logger.info "delivery end" end def deliver_deferred(args) logger.warn "whatsoever" end Any idea? ...

Strategy for dealing with large db tables

I'm looking at building a Rails application which will have some pretty large tables with upwards of 500 million rows. To keep things snappy I'm currently looking into how a large table can be split to more manageable chunks. I see that as of MySQL 5.1 there is a partitioning option and that's a possible option but I don't like the wa...

How can I check from Ruby whether a process with a certain pid is running?

The question title says it all. If there is more than one way, please list them. :) I only know of one, but I'm wondering if there is a cleaner, in-Ruby way. ...

Detect company names that are visiting my site

I'd like to use visitor IP addresses into a company name. This will be used for displaying something like "Hello visitor from Apple Inc." . Note I am looking for the company name, not the domain name. Extra points for determining the originating country. The app is written in Ruby on Rails, but examples in other languages will do. Thanks...

RDoc : Change name of 'Atttributes:' section in ri-documentation

I'm using some meta-programming to generate a bunch of methods in ruby like so: class EmotionalObject def self.mood( name, *details ) define_method(name) do # ... end end mood :happy, #... mood :sad, #... mood :ebuillent, #... #... end I know that I can pass rdoc '-A mood' to get it to recognize my mood gen...

Best language choice for a spam detection service

I have around 20 or so active blogs that get quite a bit of spam. As I hate CAPCHA the alternative is very smart spam filtering. I want to build a simple REST api like spam checking service which I would use in all my blogs. That way I can consolidate IP blocks and offload spam detection to 3rd party such as Akisment, Mollom, Defensio ...

How can I programmatically pass args to yield in Ruby?

How can I pass a variable number of args to a yield. I don't want to pass an array (as the following code does), I'd actually like to pass them as a programmatic number of args to the block. def each_with_attributes(attributes, &block) results[:matches].each_with_index do |match, index| yield self[index], attributes.collect { |att...

Redirect 'myapp.com' to 'www.myapp.com' in rails without using htaccess?

Using Morph Labs' Appspace to deploy a site means no automated way to redirect 'myapp.com' to 'www.myapp.com' (and no access to .htacess). Is there an in-rails way to do this? Would I need a plugin like subdomain-fu? More specifically, I'm trying to do something like: 'myapp.com' => 'www.myapp.com' 'myapp.com/session/new' => 'www.mya...

Shared file storage for a Rails Application

I have a rails app that accepts file uploads and I wanted to know the best way to have common storage between servers. Since we have a number of windows applications we have used samba in the past, but as we build pure linux apps I would like to do this the best possible way. We are expecting large amounts of data, so would need to sca...

Scripting language choice for initial performance

I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maint...

What is the best way to set default values in ActiveRecord?

What is the best way to set default value in ActiveRecord? I see a post from Pratik that describes an ugly, complicated chunk of code: http://m.onkey.org/2007/7/24/how-to-set-default-values-in-your-model class Item < ActiveRecord::Base def initialize_with_defaults(attrs = nil, &block) initialize_without_defaults(attrs) do ...

Report Generation in a Ruby Web Application

I've been developing business apps, basically CRUD, in ASP.Net for years now, and am interested in learning another language and platform. After a few trips to Borders and poking around a bit on the web, I have not found much dealing with generating reports in Ruby / Ruby on Rails apps. These reports would include things like commercia...