ruby

Regex to remove text before "http://"?

I have a ruby app parsing a bunch of URLs from strings: @text = "a string with a url http://example.com" @text.split.grep(/http[s]?:\/\/\w/) @text[0] = "http://example.com" This works fine ^^ But sometimes the URLs have text before the HTTP:// for example @text = "What's a spacebar? ...http://example.com" @text[0] = "...http://ex...

Any good Ruby console application gems out there?

I'm digging around trying to find a good set of tools for creating console applications, as most of the settings I expect to be using Ruby in the coming months won't be webapps, but server-side scripts. I know of highline, and I do plan on using that for user and possible password prompts, but I know that the Console application world s...

"193: %1 is not a valid Win32 application" bug with a new Rails Application

I have a new rails application which I have created under Windows 7 by going into a directory and typing "rails newapp". The creation went fine, and when I access the root page, all is well. However, when I try to access a page that would access the database, I get this: 193: %1 is not a valid Win32 application. In the developer.log. ...

Seeing "Error: Rake tasks fetching failed with..." Under NetBeans?

Netbeans seems to be throwing this error: "Error: Rake tasks fetching failed with..." whenever I start it up, though otherwise it's fine. What does this mean? ...

Rubygame + OSX hello world crashes at startup

I have this crash-at-startup problem with rubygame and OSX. Anybody knows what might be causing it, and how to fix it? Versions: OSX 10.5.7, ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9], rubygame 2.5.3 installed from a rubygem, most software installed with MacPorts (up to date). Different versions of ruby and rubygame seem to...

Parsing string in Ruby

I have a pretty simple string I want to parse in ruby and trying to find the most elegant solution. The string is of format /xyz/mov/exdaf/daeed.mov?arg1=blabla&arg2=3bla3bla What I would like to have is : string1: /xyz/mov/exdaf/daeed.mov string2: arg1=blabla&arg2=3bla3bla so basically tokenise on ? but can't find a good example. ...

Exception notifier plugin not sending emails

Trying to get Rails exception notifier plugin working. I've installed it in my app... script/plugin install git://github.com/rails/exception_notification.git Put this at the end of environment.rb outside of the Rails::Initializer call... ExceptionNotifier.exception_recipients = %w([email protected]) ExceptionNotifier.sender_address = %("...

Passing options to Haml on the command line

I'm using Haml from the command-line to do a basic transform of one .haml file to .html, like this: > haml input.haml output.html Thing is, this produces single-quotes around attributes in the resulting HTML. So how to I pass in the :attr_wrapper => '"' option from the command-line? Alternatively, can I just globally set :attr_wrappe...

Rails :include vs. :joins

This is more of a "why do things work this way" question rather than a "I don't know how to do this" question... So the gospel on pulling associated records that you know you're going to use is to use :include because you'll get a join and avoid a whole bunch of extra queries: Post.all(:include => :comments) However when you look at ...

Parse Italian Date with Ruby

I would like to use Date.parse, but it doesn't work with Italian month names! Date.parse "26 agosto 1991" => Sun, 26 Jul 2009 Is there any alternative? ...

Is there a trick to installing RMagick & ImageMagick on Ubuntu?

I keep getting Segmentation faults in the rmagick_processor.rb:52 (part of attachment_fu) while trying to run the test suite for community_engine on a fresh ruby app. I've noticed I have both librmagick-ruby and librmagic-ruby1.8 which are both ImageMagick APIs for Ruby. Should it be just one? If so which? ...

Caching in Rails 2.3 help

Hello, I'm using rails 2.3 for a blog app. I'm trying to get caching to work. So far, I've managed to follow along with these tutorials: http://railslab.newrelic.com/2009/01/22/page-caching I thought everything was working fine. I even managed to get a cachesweeper to work a la the next tutorial in that series. But I noticed in the dev...

C_ISAM file parsing with ruby or perl

Does anybody had success parsing *.idx and *.dat files with ruby or perl? I have an old application, without the source code and i want to parse files generated by this legacy code. Any direction? ...

Why is Method#arity called, well, arity?

Hi All, In Ruby, I know that Method#arity will return a value representing the number of arguments accepted by a method, however I do not know why it is called arity. Can anyone provide some insight into why it would exist in such a seemingly random namespace? and, how do you pronounce it? THX :) -C ...

PHP equivalent of a Ruby assignment idiom

Hello, what's the PHP equivalent of Ruby's "||=" assignment idiom? The scenario is I want to instantiate an object or array "on demand," and not necessarily when a class is initialized. I've tried to find this in the PHP docs, but I'm having difficulty finding things I need in there (miss the Ruby). Thank you! ...

Plugins/Gems/Libraries to get syntax highlighting for code in the browser?

I have a simple idea for a small web application that I'd like to build out, but it requires syntax highlighting in the same manner that Pastie does. I was wondering if anybody knew what library (jQuery, Prototype, any) was used in the frontend, and/or which (if any) plugins/gems were used in the backend. For reference, you can find an...

How do I write a hygienic Ruby mixin?

Say I'm writing a mixin module that adds functionality to a third-party class. Obviously some of the methods and instance variables I want to make accessible to the third-party class and its clients. These constitute the public interface of the mixin module. But I want certain other methods and instance variables to be encapsulated. I d...

How to make a Multiple-Select List Box in Ruby Glade/GTK, maybe using TreeView?

Hey guys, I am trying to make a multiple-select listbox in glade/ruby program and I am wondering how I go about doing this, like what element I add to the window and the corresponding example code I can use. I was looking at GTKList but it says it is deprecated now, and also I don't know how to get it working in ruby. GTK List docs say ...

How do I split a string in ruby maintaining whitespaces in the split

I have a string: "hello\t World\nbla" I would like to split it to: ["hello\t ", "World\n", "bla"] How would I do this in Ruby? ...

Which CMS features do you need in Rails?

I am going to write a ContentManagementSystem for RubyOnRails for administration of static pages. Which features do you prefer to appear in this CMS? What do you think might be helpful for daily work? Best regards ...