Ruby is an open-source dynamic object-oriented interpreted language that supports multiple programming frameworks including functional, object oriented and imperative. It also has a dynamic type system and automatic memory management. Ruby focuses on simplicity and productivity. Ruby's market share spiked due to Ruby on Rails, a model-view-controller (MVC) framework for building web applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

Now this is IT learning day one but I am self taught so apologies. I have a nice Ruby program that backs up a directory - "G:/Sage50" in the file copied below. I need to copy other folders - eg "G:\Sage Export" so had the idea of changing the text to an array ('Source') then reusing the code with different parameters. It should be so simple but i am foxed.
Could somebody help me please, encapsulating the code into a block that can be called on many occasions, with the folders set as parameters with each run? - with exit at the very end, of course!

#!/usr/bin/env ruby

require 'fileutils'

require 'date'
require 'time'
tooday =
nameday = tooday.strftime('%a')
namemonth = tomonth
puts nameday
puts namemonth

Source = "G://Sage50/"
replacements = {"://" => "/"}
Sourcery = Source.gsub(Regexp.union(replacements.keys), replacements)
puts Source
lister = Dir.glob Source + "**/"

for i in lister
  sister = i.to_s.gsub(/\"/, "/").gsub(/[\[\]]/, '')
  mister = sister.slice! Source
  puts sister
  Dir.mkdir("H://"  + nameday + "/" + Sourcery + sister) unless File.exists?("H://"  + nameday + "/" + Sourcery + sister)

filer = Dir.glob(Source  + "**/*").select{ |e| File.file? e }
#puts filer
for i in filer
  tooday =  File.mtime(i)
  tonow =
  if tooday >  tonow
    siler = i.to_s.gsub(/\"/, "/").gsub(/[\[\]]/, '')
    miler = siler.slice! Source
    tiler =  "H://" +  nameday…
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

I am new to Ruby and VS Code.  Have installed both as per:

Seems to start up OK but when I try the simple code attached I get the error as per the attached.The error I am trying to solve
From StackOverflow et al I am not the only one who has experienced this error.

Any advice will be most appreciated, and thanks in anticipation.  

This may be more a matter of taste rather than a technical question:

I have a web app that I'm going to be selling Membership access to. I'd like to use Shopify as the Merchant Account/Gateway in which I will need to purchase and configure two plugins:

1. A Recurring Subscription plug-in that will allow me to charge Customer's 30 days out from when they subscribed and keep that payment recurring for a given duration
2. An "Affiliate" plug-in as I will be paying a Sales Team a portion of the initial cost from the Customers.

I realize this is a big ask and I'm fairly new to Shopify, so please use laymen's terms with your suggestions. The app is written in Node.JS/React so I suspect that integration won't be too difficult for the Devs.

Thanks for your assistance.
I'm trying to create a table with an index named 'by_sub_account_classification_code'.
Due to long default index name i got 'index name too long' error. So I tried to name the index with 'name' option , but somehow it does not work. Do you know what is wrong with this migration code?

Any advised would be very appreciated.

Rails version: 5.2.1

$ bundle exec rails db:migrate
== 20190403020630 CreateSubAccountClassificationCodes: migrating ==============
-- create_table(:sub_account_classification_codes)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

Index name 'index_sub_account_classification_codes_on_account_classification_code_id' on table 'sub_account_classification_codes' is too long; the limit is 64 characters

Open in new window

class CreateSubAccountClassificationCodes < ActiveRecord::Migration[5.2]
  def change
    create_table :sub_account_classification_codes do |t|
      t.integer :sub_account_classification_code, null: false
      t.references :account_classification_code, foreign_key: true
      t.string :description, null: false


    # Name cannot be specified. don't know why. Fix in future.
    add_index :sub_account_classification_codes, :sub_account_classification_code, :name => 'by_sub_account_classification_code'

Open in new window

I am attempting to modify a file that is supposed to be at


I am root and cannot see this file

if i do a find i get this

[root@ugw1baspippin01 /]# find -name jenkins

Open in new window

I have an array of numbers and want to find the numbers that can add up to the max number in the array if possible.
So, my max number = 50 and the numbers that can add up to 50 are [4,5,7,10,24] … is this possible and how?
Using Windows 10 - want to connect to sql server and download some data.
Any help appreciated.

I updated the patches on a Ubuntu box running gitlab-ce.  Now it's refusing to start with the following error in unicorn_stderr.log

F, [2018-10-12T21:47:15.632756 #3235] FATAL -- : error adding listener addr=
/opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:185:in `bind': Cannot assign requested address - bind(2) for (Errno::EADDRNOTAVAIL)
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:185:in `new_tcp_server'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/socket_helper.rb:165:in `bind_listen'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:242:in `listen'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `block in bind_new_listeners!'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `each'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:813:in `bind_new_listeners!'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:138:in `start'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
      from /opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/unicorn:23:in `load'
      from …
Hi All,

I have an requirement to convert the .webarchive file into xml and vice-versa.
Can you please provide any reference links for scripts or tool which does this.

Hi All,

I have decent powershell skills, I now want to learn either Ruby or Python , which language will you recommend  and which will be the easiest for someone from a powershell background?

Also do any know if if chef configuration management support python?

thank you in advance
Announcing the Winners!
LVL 13
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

this script pick up a file and steps through it, and then picks up another file and matches the item number to merge the file and i getting this error, and I do not know why ?

here is the code where the file is blowing up with the following errors repeatedly.

substr outside of string at ./ line 272, <PLUS> line 745800.
substr outside of string at ./ line 273, <PLUS> line 745800.
Use of uninitialized value $bo_plus in substitution (s///) at ./ line 283, <PLUS> line 745800.
Use of uninitialized value $res_plus in substitution (s///) at ./ line 284, <PLUS> line 745800.
Use of uninitialized value $res_plus in string eq at ./ line 286, <PLUS> line 745800.
Use of uninitialized value $bo_plus in string eq at ./ line 287, <PLUS> line 745800.

while(<PLUS>) {
     $the_plus = $_;
     $item_plus = substr($the_plus, 0,10);
     $bo_plus   = substr($the_plus,36, 5);
     $res_plus  = substr($the_plus,41, 5);

   next if $item_plus =~ m/\s*MSC/i;
     $item_plus =~ s/\s+//;
     next if $item_plus eq "";
   #print " $item  >$item_plus< \t $bo_plus  \t $res_plus \n";
   $bo_plus  =~ s/\s+//; ### Error happens here !!!
   $res_plus =~ s/\s+//; ### Error happens here !!!

         $res_plus = ($res_plus eq "" ) ? '0' : $res_plus;
        $bo_plus = ($bo_plus eq "" ) ? '0' : $bo_plus;
        next if ( $item ne $item_plus);
I am trying to install redmine (a ruby based bug tracker) on a goDaddy VPS running ubuntu 15.10. I got the app to install on my dev box using Ubuntu 16.04, however GoDaddy does not offer that as an option for VPS.

For the most part things are working and from what I gather, to get over the 500 error I am getting now, I need to run:
sudo RAILS_ENV=production bundle exec rake db:migrate

Open in new window

And here is where things become harder than the documentation. Now when I run the command I am given the output of:
W: `require 'RMagick'` is deprecated, please change to `require 'rmagick'`

Open in new window

This is where I am over my head for Linux. I am sure this is an easy fix, but I have no idea where to look. I swear I installed Ruby 2.3.3 before I rebooted, however when I run
ruby -v

Open in new window

I get
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]

Open in new window

. When I run
sudo rails -v

Open in new window

, I get
Rails 4.1.10

Open in new window


Again, I just want to get this command to run:
sudo RAILS_ENV=production bundle exec rake db:migrate

Open in new window

, please help.
I just spun up an Ubuntu 15.1 server on GoDaddy VPS.

I am trying to get a ruby web app working, when I enter command:
 ruby -v

Open in new window

I get  back: ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]

however, in my home directory I see a folder named ruby-2.4.0. Why is my Ubuntu server not using Ruby 2.4?

this website has a very organized layout

what language
or what content management system is used

I have installed the following gem:

The documentation states the following:

Ruby on Rails
Add the autoprefixer-rails gem to your Gemfile:
gem "autoprefixer-rails"

Clear your cache:
rake tmp:clear

I found a file named 'Gemfile', at the following location:

I opened the file, which had the following line
eval_gemfile "#{ File.dirname(__FILE__) }/sprockets4.gemfile"

Open in new window

i added the line,
gem "autoprefixer-rails"

Open in new window

just underneath and saved

Is this what was needed?

About the cache instructions:

I issued the command rake tmp:clear, from the following two locations

I received the error response

rake aborted!
No Rakefile found

Open in new window

Also, there are separate instructions for Ruby on rails, and separate instructions for Ruby. What is the difference?

Thanks for your help!
Hi there, recently our business has started to request the need for remote data and or a portal page for our clients.
I have developed in (ASP.NET Core) and I have done some research on web api and how it works.
My question is this, what is the general structure for business applications? Is there usually a back-end server program that interacts internally with the company database to process/send request such as web-api that then forwards them to an internal or externally hosted application such as a rails/ site. Or are these generally lumped together into one single application hosted internally? We currently are using WCF services for an in-house mobile application so my thoughts were creating an api that we could use for any existing and future projects to use. Mainly the goal I want to achieve is a reusable system.

Thanks for any help.
# Check OS platform to ensure this only executes on Windows

include_recipe "chef_handler"

powershell_script do
  code <<-EOH
  # Title:
  # Description:
  # Returns 1 if any share or share path allow read/write by the 'Everyone' group (fail)
  # Returns 0 if this condition is not found (pass)
  # 0.1

    #get all shares
    $shares = Get-S | Select-Object Name,Path
      Foreach ($share in $shares)
        #check share for everyone permissions
        $shareAccounts = Get- -Name $share.Name
        Foreach ($account in $shareAccounts)
          If ($account.AccountName -eq 'Everyone')
            return 1

        #check underlying NTFS path for everyone permissions
        $volum= Get-$share.Path
        if ($volumePerm.Access.Where({$PS -eq 'Everyone'}))
          return 1
    return 0
    #loop through each share checking for 'Everyone'
    # How to pass the return values and send to Chef or something else.
    #build error message
#Return  some final message
   fail "instance has failed the check" if code == 1

Please respond with an example, as I think I'm looking at this the wrong way. I see it as a more complex effort - like having to write out a temp file. The client doesn't see …
I have several rows of twin radio buttons that are generated via a loop in ruby on rails.  For each row, one of the button is already selected, how do i detect if the user accidentally click on a radio button that's already selected?  Keep in mind these buttons all have generated ids so I can just look for a specific id.  Can someone show me how to do this via ruby on rails or javascript?  Thanks.
Hello I have two XML files that I need to merge into one. I am able to use Python or Ruby to accomplish this and so far I have had little to no success.

The two XML files are as follows (unfortunately due to very restrictive licensing they can not be shared):


The products XML has over 1000 nodes(if that is the right term) for each product. One of those "nodes" is UPC which is unique. The ingredients XML files has over 500k ingredients that are all individual but match to the product by UPC.

So I am trying to merge the ingredients to the products using UPC as the unique identifier. Any help on this would be greatly appreciated.
Angular Fundamentals
LVL 13
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Hello, I am trying to update a Ruby script that looks in html files downloaded from the IRS site and finds specific text in the file to extract the Year from the document.   The script works fine however there are not 2 types of documents that can be in the folder and the line in question is different in each document.  How can I add an "or" or "if" clause so the script looks for the text formatted either way and pulls out the year based on how the line of text reads.   The line currently in the file is displayed as "TAX PERIOD:    DEC. 31, 2014"  The line in the 2nd document that I need to add is displayed as "Tax Period or Periods:  December, 2014"  I would need the year "2014" extracted from each document.   I have attached screenshots of the script in color and the 2 document types.

#Open and read the downloaded file
	transcript_html_name = files_in_dir[i] + "/Transcripts/#{transcript_html_name}", "r") do |f|
		f.each_line do |line|
			 #Search for the Tax Period date to get the year
			if line.include? "TAX PERIOD:" 
				line.gsub!(/(<[^>]*>)|\n|\t/s) {""}
				line.slice!("TAX PERIOD:")
				line.gsub!(/\w\w\w[.]\s\d\d[,]\s/) {""}
				year = line

Open in new window

I am creating a short Ruby script to kill a stuck process. I checked the syntax (see attached script) and I get the error message below. Please help.


killProcStk.rb:24:in `block in <main>': undefined method `*' for nil:NilClass (NoMethodError)
      from killProcStk.rb:21:in `each'
      from killProcStk.rb:21:in `<main>'
Can Sql Server be configured with Ruby?

Im getting this error while trying to access a https URL.

[2016-01-14 14:42:58] ERROR OpenSSL::SSL::SSLError: SSL_accept SYSCALL returned=5 errno=0 state=SSLv2/v3 read client hello A /usr/lib/ruby/1.8/openssl/ssl-internal.rb:174:in `accept'

Im not knowledgeable in this area but looking around and in the rb file I found this: DEFAULT_PARAMS = { :ssl_version => "SSLv23", :verify_mode => OpenSSL::SSL::VERIFY_PEER, :ciphers => "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW", :options => OpenSSL::SSL::OP_ALL, }

I treid already to change the ssl_version to TLSv1 and tried to access the URL again but I got the same error...

Any suggestion on how to solve this?

Just getting started with using chef recently.  I have created custom JSON in AWS Opswork and trying to access it as an attribute in Chef recipe, but its failing to grab the JSON values. JSON file looks like.
 "normal": { 
 "filbeat": {
 "log_path" : "/var/log/*.log",
 "hosts" : "Some Random Host ID", 
 "port"  : 5000

Open in new window

and I am trying to catch it in recipe as,

log = node['filebeat']['log_path']
hosts = node['filebeat']['hosts']
port = node['filebeat']['port']

Open in new window

But it failed, I have also tried without 'normal'. I got the some []null class error.
I have a multi-select dropdown, eg:
<select id="mySelect" multiple="multiple" onchange="myFunction(event)">
  <option value="Audi">Audi
  <option value="BMW">BMW
  <option value="Mercedes">Mercedes
  <option value="Volvo">Volvo
What will the myFunction look like? I've found examples with single-select but not multi-select.
The user would have to use Ctrl + Click or Shift + Click to select multiple options. Let's say for now, i just want to print out the values selected to the console.


Ruby is an open-source dynamic object-oriented interpreted language that supports multiple programming frameworks including functional, object oriented and imperative. It also has a dynamic type system and automatic memory management. Ruby focuses on simplicity and productivity. Ruby's market share spiked due to Ruby on Rails, a model-view-controller (MVC) framework for building web applications.

Top Experts In