ruby

Eventmachine::defer + ruby

I been Using EventMachine for quite a while a know and I really found it great as It Manage show much more me that i didn't have to worry for anything.But recently I just found this weird issue which i just fail to understand Here what is just telling I have Eventmachine loop Which look like this EventMachine::run { EventM...

Is there a tutorial for Ruby programmers who want to learn Perl?

I'm a Ruby developer (bioinformatics analysis, haven't done Ruby on Rails for a couple of years), and in my spare time I've been given responsibility for a very simple Perl-based website. Although there are plenty of resources that teach Perl, I'm hoping for something aimed at Ruby programmers, so that I can take advantage of the simila...

Ruby unc path access on windows

Not sure what i'm missing: I'm trying to access a unc share via irb on a Windows 2k8 machine: irb(main):016:0> Dir.entries('\\server\share') Errno::ENOENT: No such file or directory - \server\share irb(main):017:0> Dir.entries('\\192.168.10.1\share') Errno::ENOENT: No such file or directory - \192.168.10.1\share Any hints? Sven ...

RSpec: Can I retain the new Rspec (2.0.x) with the old one (1.3.x) and still run autospec on 2.3.x Rails apps?

I gave Rails3 a try and to do so I installed the new gems, like RSpec2. When I went back to my old apps though, autospec stopped working for Rails 2.3.x apps: $ AUTOFEATURE=true autospec /usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find executable autospec for rspec-2.0.1 (Gem::Exception) from /usr/bin/autospec...

SWIG: Avoid name clashes

What is the best way to avoid name clashes in SWIG generated functions? I have two different C++ classes with partially identical function names. When I call such a function on an object, given both classes are loaded in the target language, it seems related to which library was loaded first, which function gets actually executed. It ha...

Ruby 1.9 slower than Ruby 1.8?

I have a Rails 2.3.8 app with an action that pulls a large amount of data from a database and renders it with anywhere from 300-600 partials (recursively rendering a tree-type structure). Benchmarking one request gives me response times of about 7 seconds. I thought that upgrading my Ruby version to 1.9 from 1.8 would give me a perform...

Why are the date fields in my rails object / model evaluating to nil when I can clearly see that they are not?

I'm using ruby 1.8.6 and rails 1.2.3 (ancient but I'm debugging an old app) A model called Payperiod has attributes begindate and enddate and after importing the db, the dates are all there (apparently) But in the console and in the app, the date attributes eval to nil. Why? Below is some code pasted from the console: pp = Payper...

Manipulating ActiveRecords using only a few attributes with Ruby on Rails

Hi, For caching matters, I'm caching an array of the attributes of the objects I need: friends = [{:id => 4, :name => "Kevin"}, {:id => 12, :name => "Martin"}, …] Is it possible to have a list of Users using this array, so that I can use Ruby methods? For instance, I usually get a list of non-friends with this: non_friends = User.al...

Remove differences between two folders

Hi, can anyone please suggest a method (ruby, python or dos preferable) to remove only the different files and sub-folders between two given folders? I need it to recurse through sub-directories and delete everything that is different. I don't wanna have to install anything, so a script would be great. Thanks in advance ...

form.fields_for do for a finite number of times

Hello, I have two models, Product and ProductImage, and I'd like to offer the possibility to add up to 6 images to each product. Product has_many :product_images, :dependent => :destroy while ProductImage belongs_to :product So far, my views are the following: #products/_form.html.erb. <% @product.product_images.build %> ...

How to split a CamelCase string in its substrings in Ruby?

Dear Stackoverflow, I have a nice CamelCase string such as ImageWideNice or ImageNarrowUgly. Now I want to break that string in its substrings, such as Image, Wide or Narrow, and Nice or Ugly. I thought this could be solved simply by camelCaseString =~ /(Image)((Wide)|(Narrow))((Nice)|(Ugly))/ But strangely, this will only fill $1 a...

No dispatch.fcgi on ruby app

Hi I'm trying to interface redmine to IIS 6. It works fine under webrick. So I tried to create a new rails app to reduce the complexity, but that doesn't create the dispatch.fcgi file in the public folder, which leads me to think that my RubyIIS setup is wrong. What am I doing wrong here? I have no idea about ruby or rails, so need ...

ruby socket log server

We use the default ruby logging module to log the errors. We use the delayed_job which is using many worker processes. So we could not manage the log files. We need the ruby based log server with rolling file appender and archive facility so that we can push the logs to the log server and let the log server to manage the logging task. ...

Active Record to_json\as_json on Array of Models

First off, I am not using Rails. I am using Sinatra for this project with Active Record. I want to be able to override either to_json or as_json on my Model class and have it define some 'default' options. For example I have the following: class Vendor < ActiveRecord::Base def to_json(options = {}) if options.empty? super ...

Creating a 'configuration settings' object, persisted to the db, that you can create properties for

Since Rails is using Ruby (dynamic language), would it be possible to create a very flexible 'configuration' class that has properties that you use throughout the website, AND have the ability to add new class properties (in the db for web modification) and then just use it in the code. Each property would be of a specific type like a ...

Django or Ruby on Rails - user extensions, plugins

Which framework has the most mature, flexible, intergrated, centralized and easy-to-use plugins/extension system. My main requirements are: a centralized system/repository where i could find a extension i need no need to make changes in the source code, the plugin should be easily enabled and disabled large plugin/extension database ...

What is an easy way to display graphs in Ruby?

I am looking at some graphing options, and would like one that has the cleanliness of Sparklines gem but that doesn't require Rmagick. I'd like one with some clear tutorials, too. ...

How to get netmask?

I know how to get from ifconfig. (linux) But is there another way? Can found it in socket. ...

RemoteIssue is returned with nil values using jira4r soap interface

I'm building a jira soap client that will allow me to update Jira issues. Problem is when I look up an issue using the getIssue() method, a RemoteIssue object is returned but has nil values in all the standard attributes like: key, summary, description, etc. Here is my simplified code: require 'rubygems' require 'jira4r' hos...

Error installing gems

I am getting an error when installing certain gems. I am using ubuntu 10.10. The error messages shows this. ERROR: While executing gem ... (NoMethodError) undefined method `spec' for nil:NilClass ...