Hi! A newbie question.
Do languages like e.g. Ruby (if running MRI, I mean not compiled to byte-code) run actually parsed everytime when an execution of, e.g., method or loop body is needed? I mean, to execute a loop, you need to parse its body N times?
I just always thought that all these programs are being parsed one time at the boot...
I'm currently in the process of toying with a few things at the same time: Heroku, Sinatra, HAML/SASS, and of course the glue: Ruby. I'm loving that, and it all goes well with DataMapper. However, my current "project to learn by" seems to be pretty data-intensive. Though it is also something I want to have.
I've been a bit of an amat...
I'm trying to run RSpec tests straight from ruby code. More specifically, I'm running some mysql scripts, loading the rails test environment and then I want to run my rspec tests (which is what I'm having trouble with)... I'm trying to do this with a rake task. Here is my code so far:
require "spec/autorun"
require"spec"
require "spec/r...
[[1, 20],[2,30],[1,5],[4,5]]
In ruby how does one go through this array and add the second element if the first is the same with and output such as:
[[1, 25],[2,30],[4,5]]
...
Hello, Linux newbie question I guess..
How can I find out where gem installs the gems on my Ubuntu 10 system? I want to read gem sourcecode and perhaps change things up a bit.
...
I'm studying Ruby and my brain just froze.
In the following code, how would I write the class writer method for 'self.total_people'? I'm trying to 'count' the number of instances of the class 'Person'.
class Person
attr_accessor :name, :age
@@nationalities = ['French', 'American', 'Colombian', 'Japanese', 'Russian', 'Peruvi...
What is the "Rails-way" or the "Ruby-way" of doing the following:
In my controller, I'm creating and instance of an Options class. It will be initialized with information in the params hash if the params hash exists. Otherwise, it will check the sessions hash for the information. Finally, it will initialize with defaults if neither p...
Hi everybody, I need comunicate a rails ap with skype, more specific, I need than(previously aprovation) a user can call other user using skype and keep both id private, is that possible?, thank so much!!!
...
I was following a video tutorial by Adam Keys about how to make a URL shortener app in Sinatra. The code that is giving me problems is located here http://pastie.org/958644
So when I ran it I got this error:
shortener.rb:12: syntax error, unexpected $undefined, expecting $end @@ home
I typed it exactly as Adam said but this keeps happ...
I have the following flat tree:
id name parent_id is_directory
===========================================================
50 app 0 1
31 controllers 50 1
11 application_controller.rb 31 0
46 models 50 ...
I need to save a few informations about some files. Nothing too fancy so I thought I would go with a simple one line per item text file. Something like this :
# write
io.print "%i %s %s\n" % [File.mtime(fname), fname, Digest::SHA1.file(fname).hexdigest]
# read
io.each do |line|
mtime, name, hash = line.scanf "%i %s %s"
end
Of course...
How do you set the headers for downloads in ruby/rails?
In php I'd set the header for an mp3 download like this:
header("Content-Transfer-Encoding: binary");
header("Content-type: audio/mp3");
header("Content-Disposition: attachment; filename=\"$songname.mp3\"");
header("Content-Length: " . $size);
@readfile("http:...
It is easy to setup Datamapper with a Sqlite3 in memory database with:
DataMapper.setup :default, 'sqlite3::memory:'.
However, when testing, I'd like to destroy the whole in memory database after each test, instead of invoking automigrate! as a shortcut on dropping everything. Is it possible? Or is it enough to set the default repositor...
I can see in the Savon log that my SOAP faults contain XML like this:
<errorCode>666</errorCode><errorDescription>some evil error</errorDescription>
Does anyone know how to parse the error code and description out of the response? Sorry if this is a stupid question, but I've tried everything, and I haven't been able to find any docume...
Hi,
I discovered a bug in my Rails app due to Rails app and gems upgrades and undocumented code from the previous developers. I have a lot of images that have been processed, but not sized correctly using attachment_fu. All of the images that were uploaded since the upgrade need to be resized correctly.
Does anyone have any ideas to ...
Hi,
I'd like to create several builders, with common tags, in order to have xml docs like :
<xml version="1.0"?>
<a_kind_of_root>
<!-- This part is common -->
<event_date>20100514</event_date>
<event_id>123</event_id>
<event_type>Conference</event_type>
<!-- This part is specific to the builder -->
...
I am trying to setup my dev environment on my Mac (running Mac OS X 10.6) for my work's rails application. It requires FreeImage and now that I have installed that, I run rake db:migrate and receive the following error:
dyld: lazy symbol binding failed: Symbol not found: _FreeImage_SetOutputMessage
Referenced from: /Users/username/.ru...
hi,
i have ruby code to parse data in excel file using Parseexcel gem. I need to save 2 columns in that file into a Hash, here is my code:
worksheet.each { |row|
if row != nil
key = row.at(1).to_s.strip
value = row.at(0).to_s.strip
if !parts.has_key?(key) and key.length > 0
parts[key] = value
end
end
}
ho...
Greetings,
Every time I make a change to a Sinatra app I'm working on and try to refresh the browser (located at http://localhost:4567/) the browser will refresh and, the console window seems to restart the WEB brick server. The problem is that the content in the browser window does not change.
A friend of mine told me it was a shotgu...
I'm kind of new to Ruby and some of the closure logic has me a confused. Consider this code:
array = []
for i in (1..5)
array << lambda {j}
end
array.map{|f| f.call} # => [5, 5, 5, 5, 5]
This makes sense to me because i is bound outside the loop, so the same variable is captured by each trip through the loop. It also makes sense to ...