ruby

Using styledText in SWT application

I have a simple question really: SWT documentation says that if you're using styledText, you either implements its API or you implement LineStyleListener. So, If I do use LineStyleListener, how can I still control the representation of specific characters in the editor widget? It seems that implementing LineStyleListener only provides c...

Help with regex / ruby

Hey guys, so I'm making a script to featch words/results off of this site (http://grecni.com/texttwist.php), So I already have the http request post ready, ect. Only thing I need now is to fetch out the words, So I'm working with an html source that looks like so: <html> <head> <title>Text Twist Unscrambler</title> <META NAME="keyword...

Ruby unit test add a test suite to an already existing test suite

Hi, I have a test suite with me. I want to add another test class with a set of tests in the test suite. Since this is a class with test cases, I do not know how to add it to the test suite. testsuite - existing test suite. FactorTest.rb - test class with test methods (class name is FactorTest) I tried testsuite<<FactorTest and then T...

ActiveRecord::Base.new returning nil

For some reason, one of my models in rails is returning nil when I call .new. This is only a problem in the controller. When I try on the console, it returns an object with nil attributes as I would expect. I suspect the problem is in my controller, but I have no idea. This also happens when I call .all. Again, I can execute these comm...

Ruby tutorial for how to write stored procedures for PostgreSQL?

I have heard that one in PostgreSQL can write stored procedures in Ruby. But I haven't been able to find more information about it teaching one how to actually do it. Could someone recommend good sources for that. Thanks ...

erb template broken on remote server

Newbie here, so probably something stupid :) I'm trying to play with the erb templating in Ruby. It works fine at home - Apache on windows. But when I upload it to the server it breaks every time... Simple example: require "erb" class Stuff def initialize( name ) @name = name end def get_binding binding ...

rackup in Netbeans project

Hi How can I configure a Netbeans Ruby project so that it does not run a Ruby interpreter (a Ruby "platform"), but starts up rackup? Thanks ...

Rails memcached: Where to begin?

I read a few tutorials on getting memcached set up with Rails (2.3.5), and I'm a bit lost. Here's what I need to cache: I have user-specific settings that are stored in the db. The settings are queried in the ApplicationController meaning that a query is running per-request. I understand that Rails has built-in support for SQL cachei...

Which version of Ruby?

I'm just starting out in Ruby (Rails actually) and the book I'm reading covers Ruby 1.8.6, RubyGems 1.0.1, Rails 2.0.2 and SQLite 3.5.4, but the current stable releases of these are 1.9.1, 2.3.8, 1.3.7 and 3.7.0 respectively, should I still proceed with the book or find another? Also, I couldn't find a recent guide/tutorial to walk me t...

How do you print JSON from the mongdb ruby driver?

When I do a find query from the mongodb JavaScript console, I get a beautiful JSON response. However, when I do a find with the ruby driver, it stores the JSON as some Ruby object. How do I convert this back to JSON? Or, better yet, how do I just get the JSON without doing the extra conversions? ...

Any good ruby/rails twitter accounts to follow?

I'm looking for good ruby/rails oriented twitter accounts to follow. Interesting in news/events in life of ruby/rails community. ...

Running Webrick server in background?

MBPro:shovell myname$ ruby script/server => Booting WEBrick => Rails 2.3.8 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-08-01 15:28:35] INFO WEBrick 1.3.1 [2010-08-01 15:28:35] INFO ruby 1.9.1 (2010-07-02) [i386-darwin10.4.0] [2010-08-01 15:28:35] INFO WEBrick::HTTPServer#sta...

What is the shortest Ruby code that can count how many true in each column of n x m array?

Given an n x m array of boolean: [[true, true, false], [false, true, true], [false, true, true]] what is the shortest code that can return "how many true are there in that column?" the result should be [1, 3, 2] ...

controlling VST instruments from Ruby

I've recently bought a copy of EZDrummer, a VST plugin that acts as a virtual drumkit. I'd really like to hook into it from Ruby code so that I can create loops and drum patterns programmatically. To be honest I am not sure even where to start. Presumably I have to create a VST host which can load the plugin and then hook into it somehow...

rake db:migrate not working for me

I am getting this error rake db:migrate (in /Users/john/Sites/my_app) rake aborted! Don't know how to build task 'db:migrate' When I trace the error I get rake aborted! Don't know how to build task 'db:migrate' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1728:in `[]' /usr/local/lib/ruby/gems/1.8/gems/rake-0....

Best Ruby editor for Windows with VI commands

I am looking for a good ruby editor that supports VI commands. I have been using gvim but it would be nice to have an IDE that helps me navigate between files. Any suggestions? I realize there is a similar question http://stackoverflow.com/questions/172168/ruby-on-rails-editor-for-windows however it doesn't address VI specific editors. ...

Ruby's Exception Error classes

You can create a subclass of an exception to make it more descriptive, but how should you set the default 'message'? class MyError < StandardError # default message = "You've triggered a MyError" end begin raise MyError, "A custom message" rescue Exception => e p e.message end begin raise MyError raise Exception => e p e.mes...

Mock out Curl::Easy.perform? (in Curb)

Is there a way to mock out Curb's Easy.perform method for unit testing? I use this to hit Facebook's graph API, and none of the http mock libs seem to support Curb. What's the best approach here? ...

Ruby Gem for intra-site messaging? (think LinkedIn, Facebook, etc.)

Many sites have communication via the site (instead of via email). Examples: LinkedIn: Click "Inbox" at the top of the screen. Facebook: Click "Messages" in the left sidebar. Is there a gem that provides this sort of functionality? Googling hasn't turned up much, because the search terms are so generic - "Rails gem messaging" "Ruby...

Accessing a model instance from a different model's controller

I have a Thread model which has a show page, and in that action's view code I have: <%= render 'comments/form' %> What is the proper way to initialize the new Comment? I've tried: @comment = @thread.comments.build(params[:comment]) in the Comment create action and the comment form's view code. Thread helper methods and Model metho...