When I try and send an email say [email protected] it throws (Net::SMTPSyntaxError) "501 5.1.3 Bad recipient address syntax" is it me or is the syntax checker a little too strict?
Has anyone come across this before/have a patch for net/smtp?
back trace:
/usr/local/lib/ruby/1.8/net/smtp.rb:679:in `check_response'
/usr/local/lib/ruby/1....
Does Ruby have a bug in its rounding? Why does it behave like this:
>> [1.14, 1.15, 1.16].map{|x| "%.1f" % x}
=> ["1.1", "1.1", "1.2"]
>> [1.4, 1.5, 1.6].map{|x| "%.0f" % x}
=> ["1", "2", "2"]
as in, why does 1.15 get rounded to 1.1, but 1.5 gets rounded to 2? At the very least, isn't this inconsistent? the behaviour is the same in ru...
Is it worth learning Python over Ruby and PHP for Web Development? If so why?
Thank you in advance.
EDIT: Related on StackOverflow:
Should I learn Ruby or Python?
Django or RoR
Rails or Django? (or something else?)
Ruby on Rails versus Python
What are the biggest differences between Python and Ruby from a philosophical perspective
...
Hi, I am trying to remove text that is within parentheses (along with the parentheses themselves) but am having trouble with the scenario where there are parentheses within parentheses. This is the method I am using (in Ruby):
sentence.gsub(/\(.*?\)/, "")
and that works fine until I have a sentence such as:
"This is (a test (strin...
I understand due to the inexact representation of floating points, the following code 'feels' inconsistent.
"%.1f" % 1.14 # => 1.1
"%.1f" % 1.15 # => 1.1
"%.1f" % 1.16 # => 1.2
"%.0f" % 1.4 # => 1
"%.0f" % 1.5 # => 2
"%.0f" % 1.6 # => 2
However, is there an easy way of doing consistent floating points rounding by 5? One way might be t...
Hi! I wish to download a video from YouTube and then extract its audio. Can anyone point me to some Ruby code to download a video? Thanks!
...
Hey, I am using a reg expression to remove parentheses and the content between them from a ruby string. The problem is that this sometimes leaves a space before commas. I am not sure how to go about removing this space. I've been playing around with the following but it has not been working:
@char_count = 0
sentance.each_char{|char...
I'd like to process the info in my form params before they enter the database, I just want to know what the optimal method is to do this.
For example, for my users model, should I add a method to each expected param, for example:
def first_name=(name)
self.first_name = name.capitalize.strip
end
Or should I modify the form params in...
I have no formal education in computer science but I have been programming in Java, Ruby, jQuery for a long time.
I was checking out macruby project. I keep running into statements which are similar to "In MacRuby objective-c runtime is same as ruby runtime".
I understand what MRI is. I understand what ruby 1.9 is bringing to the table...
Hi,
Rather than allowing a Ruby method to blindly return the last statement evaluated, is there any advantage to returning nil explicitly?
In terms of implementation hiding and reuse, it seems dangerous to blindly allow the last expression evaluated to be returned - isn't there a danger that a user will rely on this only to get a nast...
I'm having a problem using Curb (ruby curl bindings) for FTP downloads.
It looks like curb doesn't fall back to simple passive mode when extended passive mode fails. Extract from the log follows:
< 250 Directory changed to /outgoing/productcatalog/35591
> EPSV
* Connect data stream passively
< 229 Entering Passive Mode (|||40938|)
* ...
A user has defined the order of columns which is in an array.
order = [:col1, :col2, :col3]
Since the user defined columns order the state of table has changed and the current list of columns is
cols = [:col1, :col4, :col3, :col5]
With the given order cols need to sorted. In this case the sorted columns could look like one of the...
Hey there,
I'm using Ubuntu 9.10 Karmic Koala and Ruby 1.9.1.
I installed Rails using sudo gem install rails, which installed all the libraries for me.
When I type rails in the terminal it says.
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
rails: command not found
I can fi...
I would like to store a mySQL query in a file. I plan on having to string replace parts of it with variables from my program.
I played around with the 'eval' method in ruby, and it works, but it feels a little clumsy.
Using irb I did the following.
>> val = 7
=> 7
>> myQuery = "select * from t where t.val = \#{val}" #escaped hash si...
How to get https server certificate using Net::HTTP or HTTPClient Ruby lib?
...
I need to access files that are relative to the location of my Ruby script.
The only solution I've found is using File.dirname(__FILE__), however, if the script is run from a symlink, __FILE__ gives the location of the symlink.
I would prefer a solution that does not involve looking at __FILE__, checking if it's a link, if it is, findi...
I am using prawn to generate a pdf. So far everything has been rather straight forward. I am having a problem defining the leading between lines of text.
For example: when using a text_box
pdf.text_box "Ipsum dolor sit amet consectetue?",
:width => pdf.bounds.width - 10, :height => 150,
:overflow => :ellipses
This will genera...
How does one "parameterize" variable input into a Regex in Ruby? For example, I'm doing the following:
q = params[:q]
all_values.collect { | col | [col.name] if col.name =~ /(\W|^)#{q}/i }.compact
Since it (#{q}) is a variable from an untrusted source (the query string), I have to assume it could be an attack vector. Any best practice...
I want to sort an array by strings first and then numbers. How do I do this?
...
In Ruby, can one object destroy another?
For example:
class Creature
def initialize
@energy = 1
end
attr_accessor :energy
end
class Crocodile < Creature
def eat(creature)
@energy += creature.energy
creature = nil #this does not work
end
end
fish = Creature.new
croc = Crocodile.new
croc.eat(fish)
After the cro...