Hello,
I have the following hash table:
COUNTRIES = {
'France' => 'FR',
'German' => 'GE',
'United Kingdom' => 'UK'
}
I have it in my model and use it in my views so the countries are displayed as a select box. Now I have one view where I want all those values plus one more value "Europe" => 'EU' to be shown.
Meaning I wou...
I wrote a simple Sinatra app that generate an image using rmagick from some user inputs. The image is saved in the ./public directory with a unique file name. The unique file name is used in the HTML generated by Sinatra so that each user gets the correct image. Once a day a script deletes files older than one hour. This is clearly a ter...
Hi,
I am currently working on a rails application in which the user upload a video file on the server, after what I send it to S3 where it's encoded by another service.
The thing is that before uploading it to S3 I need to know the quality of this file, the resolution, the bitrate, ...
I saw that the rvideo gem can do that but I'd lik...
What is the fastest, most optimized, one-liner way to get an array of the directories (excluding files) in ruby? How about including files?
...
I seem to not be able to do this (which I used to be able to do in Python). Let me explain ..
Suppose I have the following method in Ruby:
def someMethod(arg1=1,arg2=2,arg3=3)
...
...
...
end
Now to call this method I could do
someMethod(2,3,4)
someMethod(2,3)
someMethod(2)
and the arguments are taken by their respective order.. b...
In ruby, if muliple HTTP request comes for single action/method then how ruby handles each and every request?
I don't know exactly, I heard that java uses multi thread concept. Is ruby uses the same or anything else? If it uses to create process for every request then this thing eat the cpu process.
...
Hi,
I'm trying to replace different parts of a html code using a single regexp.
For exemple i have this text :
option_!!NID!! [somme_text][5] some_text_option 5_option_some_text
using this regexp:
content.replace(/(!!NID!!)|\[(\d)\]|(\d)_option/g, 1))
I expect to get :
option_1 [somme_text][1] some_text_option 1_option_some_text
...
Hi, I'm working with mechanize and having problems with inheritance when testing in a rails environment, using script/console.
When I write like this:
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
agent.get 'http://www.google.com'
Everything works fine. But when I try to create a subclass of WWW::Mechanize like ...
I'm new to the twitter API http://apiwiki.twitter.com/Twitter-API-Documentation and I would like to incentivize users on my website to follow me, or re-tweet me by giving them extra privileges on my site if they do. In order to do this, I need some type of confirmation after they have followed me, or retweeted, etc. Is this possible, or ...
What does this do? I find the example here, but other than what it does, what does it mean? I can't find anything on google because well, I am not sure what '=>' is even called in this context.
More examples here:
http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html
...
Hi,
I am studying the ruby object model and have some questions. I understand the idea that an object only stores instance variables, and methods are stored in the class, which an object has a reference to. I also understand the idea of 'self' -- what it is, how it changes, etc.
However, what I don't understand is the notion that 'cla...
I am trying to extract a US address from a text.
So if I have the following variations of text then I'd like to extract the address portion
Today is a good day to meet up at a
bar. the address is 123 fake street,
NY, 23423-3423
just came from 423 Elm Street, kk, 34223 ...had awesome time
blah blah bleh blah 23414 Fake Te...
I have a ruby script that is simultaneously and asynchronously receiving and displaying messages from a server, and allowing user input on the console. When a message is received, it is currently being written in the middle of what the user is typing. The input itself isn't garbled, but it looks horrible. Ideally, it would save the users...
I want to have some kind of single list that is initialized in a seperate module, then can be included in a controller and modified at the controller-class level, and accessed at the controller-instance level. I thought class variables would work here, but something strange is happening, they don't seem to be being initialized within my ...
There is a command I want to call that returns a string, I want to call this command while inside a ruby script, and have access to the result.
...
I have managed to figure out the primary part of my question, "how do I insert one XML document into another?" The result I get will work but the printed XML is missing a linefeed.
s = <<EOF
<application>
<email>
<host>mail.test.com</host>
<port>25</port>
</email>
</application>
EOF
p = <<EOF
<auth>
<user>godber</user>
...
What language and libraries are suitable for a script to parse and download small numbers of web resources?
For example, some websites publish pseudo-podcasts, but not as proper RSS feeds; they just publish an MP3 file regularly with a web page containing the playlist. I want to write a script to run regularly and parse the relevant pag...
Is it possible to tell ruby to give a warning only once, rather than multiple times?
class SoylentGreen
def eat
warn "Algae harvesting not implemented. Soylent green is people!"
end
end
5.times do
soylent_green = SoylentGreen.new
soylent_green.eat
end
produces
Algae harvesting not implemented. Soylent green is people!
Al...
Possible Duplicate:
Ruby: difference between || and or
Using Ruby
||
and
or
are very common practices which makes it important to know the difference between the two as unfortunately I am not sure.
First of all my question is if the following assumption is correct:
EX1:
if @variable_1 || @variable_2 || @variable_...
I'm not sure if I'm doing the best approach here, but I have a block of data that I want to show after a search is done and to not be there at all before. First of all, there is nothing to show, and second the model it references is nil so it throws an exception.
I placed this block in a partial template and added it the appropriate sp...