ruby

How do I sum up a column in a spreadsheet created by using spreadsheet gem by using a formula.

I have a spreadsheet where i want to sum up a column values. The Spreadsheet::Formula has a very weird documentation. Is Formula supported or should I sum a column by summing up the values of the cells in a column? ...

Sum up Area for material in Components, Google Sketchup

I am making a plugin to sum up the area of all the material in a Sketch. I have succeeded in getting all the faces and such, but now the Components come into the picture. Im using the term single or multi leveled component as i dont know any better way to explain the occurence of having a component inside an component and so on. I have...

Ruby: wait for system command to end

Hey all, I'm converting an xls 2 csv with a system(command) in ruby. After the conversion i'm processing this csv files. But the conversion is still going when the program wants to process the files. So at that time they are non existant. Can someone tell me if it's possible to let Ruby wait the right amount of time for the system comman...

RVM doesn't work for 1.9.1 but works for 1.8.6 and 1.8.7

UPDATE 6/25/10 Using Google, I am not the only person to encounter this problem. Apparently this problem has to do with readline. Has anyone out there encountered this issue? (see error at make.error.log below) As google suggests, I compiled readline: curl -O ftp://ftp.gnu.org/gnu/readline/readline-6.1.tar.gz tar xzvf readline-6.1.tar....

How To Convert Arabic Number Ascii Code to String in ROR ?

I want to convert my English Numbers Pager to an Arabic one, I had something like <% @engnum = "0123456789" %> <% @arabnum = "٠١٢٣٤٥٦٧٨٩" %> <%= (@pagenumber).to_s.gsub(/./) {|s| @arabnum[@engnum.index(s)]} %> But this shows the ascii number not the actual number i need Any idea how to show the actual string (Number) Remember that...

Ruby Hash.merge with specified keys only

I'm pretty sure I saw on a Rails related site something along the lines of: def my_function(*opts) opts.require_keys(:first, :second, :third) end And if one of the keys in require_keys weren't specified, or if there were keys that weren't specified, an exception was raised. I've been looking through ActiveSupport and I guess I might...

Ruby: invalid byte sequence in UTF-8

I'm writing a Django project that uses the LESS language. I'm using the django-css application to do this. My colleague is getting the following error, but I am not. I suspect that this might be because the encoding is wrong on the file being compiled. The weird thing is that we cloned from the same hg repo so I don't see why his fil...

Reduce Heroku Compiled Slug Size

I've just updated rails to v2.3.6 on my app under a bamboo-ree-1.8.7 stack and the compiled slug size has grown up to 40.5Mb! Previous to that last git push, the slug size was about 20Mb and was using rails v2.3.5. Is it because my slug has both of rails versions installed? Probably I'm missing something but I haven't added any special ...

Beginner Ruby / MSQL Error

http://localhost:3000/genre I'm using Instant Rails, I'm introducing scaffolding for the first time ever. So everything looks like its working fine, I did my own RoR page etc, today i come in today and when I go to localhost:3000 I get the following error message: Oops! Google Chrome could not connect to localhost:3000 Any suggestion...

Problems running Ruby on Rails apps on shared hosted server

I have problems installing any Ruby On Rails app on my shared hosted server. Mongrel shows html as plain text for all pages. The problem occurs for any app, even if I create a test empty app and add a scaffolded view without changing anything. It appears that the Mongrel crashes when trying to put cookies to the response header. The HTT...

Ruby implementation of conversion between Latitude/Longitude and OS National Grid Reference point?

For converting between Latitude/Longitude and UK's Ordnance Survey National Grid eastings and northings, this seems to be the most popular explanation and reference implementation in JavaScript: http://www.movable-type.co.uk/scripts/latlong-gridref.html The web is littered with other implementations in different languages. Making the co...

appending <a href> to keywords in rails

Basically, there are some keywords that i want to pick out and assign a link to them dynamically. How should i go about in doing this? Let's say i have something like this; <p>ruby, rails, php, python, django and sinatra</p> and i would like to assign links to keywords like ruby and python, so the end results should look like this; ...

Find by Quantity

Let's say I have a model Vehicle and it has_many :wheels What is the correct find / :conditions => ... statement to find only vehicles with 3 or more wheels, e.g. tricycles, cars, trucks, tanks etc...? ...

RoR: How to load the related record in a one-to-one relationship

I have the following: class User < ActiveRecord::Base has_one :subscription end class Subscription < ActiveRecord::Base belongs_to :user end The User has a subscription_id and thus can have only one subscription (which is what I want). Which works fine, but now I do: @users = User.find(:all) and I want all the subscriptions to...

Access params[] and local attributes in static class as *_filter

Hi! I'm trying to refactor some code and move some of my before_filter's from the controller to a class. Before: class UsersController < ApplicationController before_filter :find_user def find_user @user = User.find(params[:id]) end end ... After class FindUserFilter def self.filter(controller) @user = ...

Getting a DNS TXT record in Ruby

I need to get the txt field from the DNS record. Is there any ruby api to do something like this? nslookup -q=txt xxxx.com Thanks ...

Rubygems Path Question

I am trying to run the following ruby code from IRB but am unable to require the gmail gem. require 'rubygems' require 'gmail' gmail = Gmail.new("user", "pass") Here's the IRB output: Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ irb >> require 'rubygems' => false >> require 'gmail' NameError: uninitialized constant Gmail ...

How to convert a string to a class method in Ruby?

This is how to convert a string to a class in Rails/Ruby: p = "Post" Kernel.const_get(p) eval(p) p.constantize But what if I am retrieving a column from an array/active record object like: Post.description but it could be Post.anything where anything is a string like anything = "description" How can I make it work? Any ideas. ...

Ruby gem to obscure data

Anyone know of a gem that will allow you to obscure/sanitize data? Usecase: Download a production database, run some sanitation so that real customers won't get emails, cards charged etc. ...

Trying to reference a hash using a string value in Ruby

How would I refer to a hash using the value of a string - i.e. #!/usr/bin/env ruby foo = Hash.new bar = "foo" "#{bar}"["key"] = "value" results in foo:5:in `[]=': string not matched (IndexError) from foo:5 How do I use the value of bar (foo) to reference the hash named foo? Thanks! ...