Because apparently require 'date' doesn't include the method hours or seconds etc:
undefined method `hours' for 5:Fixnum (NoMethodError)
Am I missing something? Is 5.seconds only something you can do in Rails? If so, what is the require statement I need to get this to work in a ruby script?
Hi All,
I've spent some time today looking for a pure ruby library that will parse an excel workbook. I could find the parseexcel gem in the repos, but the problem is that I can't find any documentation on it. and the rdoc is pitiful. so, my question is 1) is there good documentation out there for this gem? 2) if not, is there another gem that does the same thing that has good documentation?
thx :)
-C
It is said that FastCGI doesn't work well with Ruby on Rails deployment. Why is that? In previous experience, something either works quite well or it might be fundamentally wrong. So if FastCGI is a viable solution, why is it not reliable with RoR?
Does FastCGI work well with most any language / frameworks?
I realize this sounds a little crazy, but I'm working on a project for which I need a server to run user-provided Ruby code and return the result.
I'm looking to prevent something like this:
system("rm -rf /")
eval("something_evil")
# etc...
I'm sure there must be some reasonably safe way to do this, as it already exists at places like tryruby.org. Any help is greatly appreciated, thanks!
In Ruby on Rails,
http://localhost:3000/foobars/alt/1
works
but
http://localhost:3000/foobars/alt/1.xml
doesn't work.
config/route.rb is
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
so supposedly it supports an id.format in the URL?
I want to run my ruby script x times a day (the number might change) on my linux box. What would be the best way to do so if I do not want it to happen at the same time? I want the time (hour and minute) to be random
given an xml string like this:
<some><nested><xml>value</xml></nested></some>
what's the best option (using ruby) to format it into something readable like:
<some>
<nested>
<xml>value</xml>
</nested>
</some>
I would like to pull the titleand description fields from the newsfeed at http://www.tagesschau.de/newsticker.rdf to feed them to the Mac's Text-to-Speech engine.
My search for a nice Ruby Gem to do this has brought me to Nokogiri, but all examples that "pull something out" of a given XML seem to be centered around CSS somehow.
Does anyone have any idea how to save the titleand description fields in an array?
I opened a question how can I capture response from twitter.com? ( ruby + twitter gem) to know if my update was successful. It is working fine...
But I would like to know how I can capture HTTP Response Codes and Errors
oauth = Twitter::OAuth.new('consumer token', 'consumer secret')
oauth.authorize_from_access('access token', 'access secret')
client = Twitter::Base.new(oauth)
response = client.update('Heeeyyyyoooo from Twitter Gem!')
What is the best way to implement real time updates in ruby on rails using node.js? It would be great to hear either real examples or your thoughts on alternative solutions.
If I have the following piece of Ruby code:
class Blah
def self.bleh
@blih = "Hello"
@@bloh = "World"
end
end
What exactly are @blih and @@bloh? @blih is an instance variable in the class Blah, and @@bloh is a class variable in the class Blah, correct? Does it mean that @@bloh is a variable in Blah's class, Class?
if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?
or is there no major difference just a matter of taste?
cause i know python definetely is a good scripting language.
thanks
I wonder if there is a way to get offsets and delimiters while I am splitting a string in ruby analagous to PHP preg_split:
preg_split("/( | |<|>|\t|\n|\r|;|\.)/i", $html_string, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE);
I imagine I can achieve it by traversing string by characters or using something heavy as treetop, but I would like to use something more convenient.
I have two Ruby arrays, and I need to see if they have any values in common. I could just loop through each of the values in one array and do include?() on the other, but I'm sure there's a better way. What is it? (The arrays both hold strings.)
Thanks.
Hi is there an equivalent ruby method to JavaScript encodeURIComponent method? i am using the URI.unescape(str) but it recognizes the "£" (after encodeURIComponent it becomes "%C2%A3") as a "?" sign. any solution's? thanks
PHP was the undisputed king of easy webapp development, until Ruby on Rails, Django, and other dynamic programming frameworks appeared. What are, in your opinion, PHP's strengths against the newcomers?
In Ruby on Rails, how is an ActionView object able to access the instance variables of ActionController object (how is view code able to use instance variables that are set inside the controller code)?
Does ruby on rails have issues with regards to max # of threads the server and serve?
i.e. you have to run multiple instances of the server if you reach high load?
I want to run my ruby script x times a day (the number might change) on my linux box. What would be the best way to do so if I do not what it happen at the same time? I want the time (hour and minute) to be random
I have a Ruby app with a lot of classes/modules, and some of them are not used. Is there an easy way of finding out which?
I was thinking to do a profile, and then work with it's output. Any other ideas?
I have seen this sample written in Ruby code, how i can simulate it in C language?
Open3.popen3(command) do |stdin, stdout, stderr|
@stop_stdin = stdin
while !stdout.eof do
output = stdout.read(1024 * 100)
list_pipes.each do |out|
out.print output
end
end
end
I have this:
require 'tempfile'
t = Tempfile.new('test-data')
t.open
t.sync = true
t << "apples"
t.puts "bananas"
puts "contents are [#{t.read}] (#{t.size} bytes)"
t.close
This prints:
contents are [] (14 bytes)
Why aren't the contents actually shown? I'm on Ruby 1.9.2.