I need a way to split an array in to a bunch of arrays within another array of equal size. Anyone have any method of doing this?
For instance
a = [0, 1, 2, 3, 4, 5, 6, 7]
a.method_i_need(3)
a.inspect
=> [[0,1,2], [3,4,5], [6,7]]
I'm not a Ruby dev by trade, but am using Capistrano for PHP deployments. I'm trying to cleanup the output of my script and am trying to add a unicode check mark as discussed in this blog.
The problem is if I do:
checkmark = "\u2713"
puts…
I want to get the last character in a string MY WAY - 1) Get last index 2) Get character at last index, as a STRING. After that I will compare the string with another, but I won't include that part of code here. I tried the code below and I get a…
So I'm writing some rspec tests and I'm embarrassed at my lack of Ruby understanding.
I have a file structure that looks like the following:
GUI_Tests/Tests/test_spec.rb
GUI_Tests/windows_gui.rb
GUI_Tests/upload_tool.rb
when I run spec for the…
I wasn't working with ruby 1.8.7 and recently I was surprised that:
{:k => 30}.to_s #=> "k30"
Is there ready to use fix to convert hash to string for ruby 1.8.7 to make it look like:
{:k => 30}.to_s #=> "{:k=>30}"
I am in a process of migrating my application from ruby 1.8.7 to 1.9.3 (and later upgrading Rails). However I geht some problems with logging in 1.9.3.
By using the following code in environment.rb when console or server starts up
logfile =…
I'm using Rails 3.2.2, with aasm gem, I have Document model this way:
class Document < ActiveRecord::Base
include AASM
aasm do
state :unread, :initial => true
state :read
state :closed
event :view do
transitions :to =>…
I'm trying to make a https post request in ruby and it works in curl, but I get a 400 bad request in ruby and I'm having trouble figuring out why.
Heres the ruby code:
require 'rubygems'
require 'net/https'
require 'uri'
require 'json'
uri =…
Is there a spawn equivalent for ruby 1.8.7?
It appears as though it was introduced in 1.9.1
http://apidock.com/ruby/Kernel/spawn
I need the following to work in ruby 1.8.7:
def run_worker(queue, count = 1)
puts "Starting #{count} worker(s) with…
I have a Rails app using Ruby 1.8.7 and I'm getting this error when running in debug mode and setting a break point:
54749: Exception in DebugThread loop: undefined method `errmsg' for…
Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version?.
Using chruby I have Ruby 1.8.7 installed on macOS:
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
Also, I have used…
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…