Assume, I have a two dimensional array A, and it's stated that somewhere inside it there's an object my_element. What's the quickest way to find out its coordinates? I am using Ruby 1.8.6.
...
I want to get all file names from a folder using Ruby.
...
i write something in ruby thinking that it will work as it did in php but no!
i realized that you need to clone objects using .clone
merely associating to a variable doesn't work !
in php this worked fine!
it took 2 days until i discovered this error!
what tutorials can i read to get firm grasp on ruby ?!
...
I have recently designed a web application that I would like to write in Ruby. Coming from a ASP background I designed it with method and fields and linked them together (in my diagram and UML) like I would do it in C#.
However, now that I've moved from a single app to MVC I have no idea where my code goes or how the pieces are linked.
...
simplified version of my problem
require 'wx'
Wx::App.run do
f = Wx::Frame.new nil
f.title= 'the potlee'
f.size= Wx::Size.new( 200 , 500)
f.pos= Wx::point.new(50,50)
f.show
end
i get this error
`method_missing': undefined method `pos=' for #<Wx::Frame:0x207d020>
how can i set the size on the frame but not the position...
checkout this code and the output
def lab
yield
ensure
puts 'in ensure block'
true
end
puts lab { puts 'inside inline block'; false }
output is
#inside inline block
#in ensure block
#false
I was expecting that after the block is executed then ensure will be executed and since ensure returns true , the final output of cal...
I'm always making the same steps when I do:
script/console
do you know some file to edit or something similiar to avoid doing always the same, like for example loading some particular required gem (in my casi 'spawners' :))
...
I am trying to build a free web application using ruby/rails It should be able to send sms through online forms of various mobile operators. (like this one (in russian)).
So, I need to
wait for the user, who wants to send an sms through my website.
establish connection to operator website. Probably, using Mechanize.
retrieve captcha
s...
I am new to Rails so this is probably an easy question but can't find anything that seems to explain it well.
How do I style forms in rails to. When I try to use the default styling for input (for example) it styles my text field and create button the same. Is there a built in convention or do I have to add some sort of helper. If it i...
What is the best way to create a hide and show effect in rails 2. Is it to use a JQuery type solution or is there something as good, better or easier built in?
...
I changed the highlightColor and highlightEndColor in the /public/javascript/controls.js file but it isn't changing when the AJAX effect runs. What am I doing wrong?
...
I play around with arrays and hashes quite a lot in ruby and end up with some code that looks like this:
sum = two_dimensional_array.select{|i|
i.collect{|j|
j.to_i
}.sum > 5
}.collect{|i|
i.collect{|j|
j ** 2
}.average
}.sum
(Let's all pretend that the above code sample makes sense now...)
The problem is that even th...
I'm using the Rails session to store a cookie_jar I get from Mechanize. This lets me call a webservice and maintain the cookies it sends back.
The class takes a session in it's constructor, so I'm passing in the Rails session. Then, when I call the service, I load the cookie_jar (if I have one) like:
agent = WWW::Mechanize.new
agent.c...
For instance, in Python, I can create a class like this:
class foo(object):
bar = 'x'
def __init__(self, some_value):
self.some_attr = some_value
...where bar is a class attribute and some_attr is an instance attribute. What is the idiomatic way to do things like this in Ruby?
...
For a long time I tried desperately to get this to work, I've googled, I've tinkered, and I've asked some local Rubyists (though not pdx.rb, though I really should).
I think I explained this poorly to begin with. Let me try again. We were trying to do something like this at work
case user.roles.included? (... magic ...)
when ['admin...
I'm looking to create a custom daemon that will run various database tasks such as delaying mailings and user notifications (each notice is a separate row in the notifications table). I don't want to use script/runner or rake to do these tasks because it is possible that some of the tasks only require the create of one or two database ro...
I am using mechanize/nokogiri and need to parse out the following HTML string.
can anyone help me with the xpath syntax to do this or any other methods that would work?
<table>
<tr class="darkRow">
<td>
<span>
<a href="?x=mSOWNEBYee31H0eV-V6JA0ZejXANJXLsttVxillWOFoykMg5U65P4x7FtTbsosKRbbBPuYvV8nPhET7b5sFeON4aWpbD10Dq">
<span...
I have a site listing many jobs, but I also want each account to be able to access its jobs in one place. Thus, I am using these routes:
map.resources :jobs
map.resource :account, :has_many => :jobs
This gets me URLs like localhost/jobs/ and localhost/account/jobs. However, both seem to render JobsController::index. How can I either m...
I was trying to create a quick little script that would insert data into an SQLite db for me but I can't get past the first few steps.
I have done "sudo gem install sqlite3-ruby", my Ruby version is 1.8.7 (I used the Ruby one click installer from rubyforge.org).
My script is incredibly simple. It looks like this:
#!/usr/bin/ruby -w
re...
I'm sure it's a silly question to those who know...but I can't find an explanation of what it does or what it is.
CSV.open('data.csv', 'r') do |row|
p row
end
What does "p row" do?
...