In IRB on Ruby 1.8.7, I have a collection of strings I'm working with that have newlines in them. When these newlines are output, I want to explicitly see the \r and \n characters within my strings. Is there some way to tell puts to escape those…
So, my client has me working on a legacy app which is running Rails 2.3.8 and Ruby 1.8.7, so I'm attempting to install the proper version of ruby using rbenv but it keeps giving me this error:
→ rbenv install 1.8.7-p249
ERROR: This package must be…
Say I have...
arr = ["a", "b", "c"]
...and I want to move "a" between "b" and "c".
I currently do
arr.delete("a")
arr.insert(2, "a")
Can I do that in a single operation?
Thanks
When I do the following in Ruby 1.9.3 (also JRuby, Rubinius...), it works as expected:
enum = [1,2,3,4,5].each
#=> #
enum.next
#=> 1
If I try the same thing on Ruby 1.8.7 with backports, the following thing…
I'm using (and stuck with) the following version of Ruby:
ruby 1.8.7 (2012-06-29 patchlevel 370) [x86_64-linux]
I tried a lot of Googling, but I can't find a working answer to my problem. I'm importing a CSV file that will usually come from the…
I am encountering errors when I am using Ruby's File.exist? method in middleware. I have no idea why.
This is the background. I am improving some old webapp which hosts around 100GB of photos and growing. I need to replicate production environment…
I can't install ruby ree or ruby 1.8.7 on my Mac 10.8.2.
I did that:
$ brew install libksba
$ brew update
$ brew install autoconf automake
$ brew tap homebrew/dupes
$ brew install autoconf automake apple-gcc42
Then i try to install ruby 1.8.7 and i…
I want to get an xml content from a url (let's say http://stackoverflow.com). For this I use open uri. When I do
begin
status = Timeout::timeout(5) {
getresult = open("http://stackoverflow.com", "UserAgent" => "Ruby-OpenURI").read
}
rescue =>…
I am able to convert a local time in string format, to UTC time format. But when i save this utc time in my MySQL table, it is getting saved in a strange format.
t_utc = Time.parse('Mon Apr 23 03:00:23 -0700 2012').utc # => Mon Apr 23 10:00:23 UTC…
How can I do a regexp in ruby 1.8 that matches:
/my_dir/1/file
but not if I have:
/my_dir/1/deeper_stuff/file
So far I have
source_string = '/my_dir/1/index.html.erb'
/^\/my_dir/.match(source_string)
for the initial match, how do I add the…
I'm getting the following error:
/Users/user_name/.rbenv/versions/1.8.7-p375/lib/ruby/1.8/net/https.rb:124:in
`use_ssl=': uninitialized constant Net::HTTP::OpenSSL (NameError)
So, I opened up the https file and changed one thing just to see what…
I have a file called "output.txt":
"name": "abc",
"age": 28,
"name": "xxx",
"age": 11,
"name": "yyyb",
"age": 15,
I want to read the file and print the name and age values on one line, one after the other:
abc 28
xxx 11
yyyb…
I have a sorted 2D array as follows:
a = [[1, 2011], [3, 1999], [4, 2014], [6, 1998], ...]
How can I transform this into a hash with the key being the year and the value being the number in front?
{2011 => 1, 1999 => 3, 2014 => 4, 1998 => 6, ...}
I have a excel sheet(.xlsx) format which has only text data,I want to count the no of rows as well read the text data from the excel sheet in ruby
using win32ole gem only.I have gone through many of the post in stackoverflow which represent these…