ruby

Memory Leak in Ruby net/ldap Module

As part of my Rails application, I've written a little importer that sucks in data from our LDAP system and crams it into a User table. Unfortunately, the LDAP-related code leaks huge amounts of memory while iterating over our 32K users, and I haven't been able to figure out how to fix the issue. The problem seems to be related to the ...

Insert rows on specific line in a file.

I have opened my existing file in r+ mode. open("#{RAILS_ROOT}/locale/app.pot", 'r+') do |f| end I want to insert some other rows at specific line no.. Like i want insert "Hii " on line number 10. "hello " on line number 2. "world " on line number 20. How may i handle it in ruby ?? ...

Nokogiri response different

Does anyone have a problem with Nokogiri acting differently between two servers (staging, and production)? On staging, it grabs and return the page properly (Nokogiri 1.4.2 Mechanize 1.0.0) On production, it returns a much smaller set of html that looks like a canned message (Nokogiri 1.4.2 Mechanize 1.0.0) I found out by running it i...

How to I merge two databases with same schema that are on Heroku?

I created two applications that were essentially identical on heroku. They started off different because I was testing uploading to heroku and having some challenges making the adjustments. But now things seem to be working, but both have data that I would like to consolidate. Since they run off the same git repository, the code is th...

Parsing XLS and XLSX (MS Excel) files with Ruby?

Hi. Are there any gems able to parse XLS and XLSX files? I've found Spreadsheet and ParseExcel, but they both don't understand XLSX format :( Any ideas? Thank you. ...

Using <string>.split (and a regular expression) to check for inner quotes

I'm implementing a search in my website, and would like to support searching for exact phrases. I want to end up with an array of terms to search for; here are some examples: "foobar \"your mom\" bar foo" => ["foobar", "your mom", "bar", "foo"] "ruby rails'test course''test lesson'asdf" => ["ruby", "rails", "test course", "test lesson"...

What is the <= operator on Ruby Classes?

following snippet is from rails code def rescue_from(*klasses, &block) options = klasses.extract_options! unless options.has_key?(:with) if block_given? options[:with] = block else raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument." end ...

Rails or Django?

Possible Duplicates: Rails or Django? (or something else?) Django or Rails? I come from a PHP background and was planning to try out a new framework. I have never done Ruby or Python before. Knowing PHP, what language would be easier to learn? ...

Ruby: Threading and sockets.

I'm trying to write a server connection in Ruby that will spawn a thread to handle incoming connections. This thread will then interpret the incoming data, then place some instructions in a queue to be processed by the main program loop at its convenience. However, I seem to have some issues with the queue processing, as the program se...

Why would Paperclip be failing to find the geometry key when on my server?

I'm getting an error in thumbnail.rb saying :geometry is empty Here's a condensed version of the stack: NoMethodError in PagesController#create undefined method `[]' for nil:NilClass RAILS_ROOT: ... Application Trace | Framework Trace | Full Trace .../vendor/plugins/paperclip/lib/paperclip/thumbnail.rb:18:in `initialize' .../vendor/...

Ruby Net::IMAP: closing a connection

Ruby Net::IMAP library provides a good API for IMAP stuff (http://railsapi.com/doc/ruby-v1.8/classes/Net/IMAP.html). There are two methods related to closing the IMAP connection: logout() and disconnect(). In which turn are they supposed to be called? ...

To Ruby and/or To Ruby on Rails, that is the question...from a non-coder

I am a non-coder and am very good at HTML. I am going to self-teach myself Ruby & Ruby on Rails because I hear it's a good skill to have but especially because it may be an easy first language to learn with my HTML background. I would like to create my webpage, which will catalog my photographs, using Ruby on Rails. For a non-coder-HTML...

Braces: [Brackets], (Parentheses) & {Curlies} in Ruby & Rails

So the loose tolerance of Ruby to use braces sometimes and not REQUIRE them has led to alot of confusion for me as I'm trying to learn Rails and when/where to use each and why? Sometimes parameters or values are passed as (@user, @comment) and other times they seem to be [ :user => comment ] and still others it's just: :action => 'edit'...

Ruby graphic libraries

What's the difference between RMagic, ImageMagick, GD, etc. and which one should I use? I was looking for a thumbnail generation script and noticed that every script I found uses a different library for the same thing. ...

Nil class when using Ruby injection

I'm new to Ruby, and I'm having a strange problem with the inject method. When I do: (1..10).inject(0) {|count,x| count + 1} the result is 10, as expected. But when I do (1..10).inject(0) {|count,x| count + 1 if (x%2 == 0)} I get an error: NoMethodError: undefined method `+' for nil:NilClass from (irb):43 from (irb):43:in...

Using Ruby, Perl, or Python, how to "Move the window 'Firefox' to coordinate (0,0) on screen and resize it 1024 x 768"?

Can it be moved by Window Title as well as exe name? Other info on moving it in another language could be helpful. Update: some Perl sample can be found in Win32::GuiTest but there seems to be no resize or move functions. ...

How to match certain text in returned XPath HTML?

I am using Xpath in Ruby with following statement. print XPath.first(Document.new(html),"//tr[@id='ctl00_c1_rr_ci_trAdd']//td[2]") The Query return the following text. <td> 1371 N Belsay Rd<br/>Burton, MI 48509 <br/> <a href='http://www.mapquest.com/maps/map.adp?style=2&amp;amp;addres...

how do I ensure graceful death in rails?

I am new to ruby and rails but seem to be getting the hang of it better than I expected... So I have a few instance methods, within which calls to ruby gems are made. When one of them throws an error, how do I get that to gracefully pass back to the client? Either let it keep going if it can and display an error message, or die and giv...

regex to get the domain name from a url in ruby

I trying to construct a regex to extract a domain given a url . for eg. http://www.abc.google.com/ http://abc.google.com/ https://www.abc.google.com/ http://abc.google.com/ should give abc.google.com any hellp verymuch appreciated. Thanks ...

rails testing helpers with instance variable?

hi, I want to test a helper where I use a instance variable inside. I'm using rails 2.3 with the default testing framework. Can please someone write my a simple test (I guess a Unit test) for this? thanks A simpler version of my code as example. # controller @bla = "some value" # view <%= foo %> # helper def foo @bla.reverse end ...