I have a ruby array with 4 strings
nucleotides = ['A', 'G', 'C', 'T']
I need 4^3 combinations of strings.
new_array = ['AGC', 'AGT' .. 'TTT']
This is the wobble hypothesis in genetics. Could someone explain how I could go about achieving this…
Perhaps there's a better way to do this. I want to be able to load some routes dynamically. I was planning on having static routes in routes.rb, and custom routes in custom_routes.rb. Then at the bottom of routes.rb, I would do:
CustomRoutes.create…
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…
I am noticing differences between a hash object within Ruby 1.8.7 and a hash object within Rails 3.0.10.
For example, within the 1.8.7 irb, I get:
1.8.7 :001 > {}.try(:method)
NoMethodError: undefned method `try' for {}:Hash
from…
I have the following method:
def download_link_for(site,title=nil)
template = proc {|word|(title ? "%s_#{title}_csv": "%s_csv") % word}
if site.send(template.call("update")) == false
x.a "Generate", :href =>…
In Linux, it is very easy "just" to add executable to a file, simply by input:
chmod +x
However, I have failed to find something as easy in the gems of Ruby. Of course, one could do a system call, i.e.
system( 'chmod +x' << fname…
We have an older REE rails app that I work on my local dev environment in OSX Yosemite. I recently switched from Mavericks, with which I had no problems. I ran this app for the first time on my new work mac and found I was unable to login due to it…
I am using ruby 1.8.7 (2011-12-28 patchlevel 357) [i686-darwin11.2.0]
I am playing with Kernet::eval method.
The binding may be a Binding object or a Proc object.
def eval(string, *binding_filename_lineno)
end
I have following test.rb
require…
Using Ruby 1.8.7 I want to store some regular expressions in the database and have them be easily reconstituted as a Regexp object when I need to use them for validation. I've found that Ruby exhibits some unwanted behavior. For instance:
r =…
Using Ruby 1.8.7, is there built-in functionality similar to Array.map which allows for the return of multiple values instead of just one? E.g. I have an array and each element contains an array - I want to end up with all values from the inner…
I'm trying to understand the serialization/deserialization of ruby object using YAML under 1.8.7 and 1.9+ and have a few queries regarding it (I can't find much documentation on this)
Ruby 1.8.7
class Element
yaml_as…
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…
I'm trying to calculate 2^1000 in ruby, but I'm getting different results for different versions. Any idea why?
Using 1.8.7:
~ » rbenv global system ~
~ » ruby --version …
I'm trying to use the "gmail_xoauth" gem and, unfortunately, the gem uses encode("us-ascii") for strings, which is available only for Ruby 1.9.3.
I'm not familiar with encode in Ruby 1.9.3 so I wonder what is "string".encode("us-ascii") and how do…