Need help converting Ruby code into F#

I have the following code in Ruby which takes a list of 'melds' and creates a Tree Structure in order to find the best combination of melds and returns that. I am wanting to convert this code into a F# equivalent but I am having a hard time thinking ...
more »

2017-04-20 15:04 (1) Answers

Load File From Local Gem in IRB

I have a cloned a ruby gem to my client. According to the docs here (https://github.com/Jbur43/usps_counties) I have to require 'usps_counties' in order to load it. So my path is /usps_counties. From there I load irb and try requiring the usps_cou...
more »

2017-04-20 14:04 (1) Answers

ruby private class method helper

Hi I am trying to create a helper for mass defining ruby methods as private class methods. In general one can define a method as a private class method by using private_class_method key work. But I would like to create a helper in the following style...
more »

2017-04-20 13:04 (3) Answers

Schedule an ActiveJob in Rails

I'm doing a weather API which will get, process and save data from another API. In order to get the daily updates (request URL info, get the JSON/XML data, construct my data and save it to my database) I think the most proper way is to use an ActiveJ...
more »

2017-04-19 23:04 (3) Answers

ActiveRecord multiple where date range

Is there a more ActiveRecord idiomatic way to find which records have a start_at or end_at within a certain date_range? (Basically, need to find the records that start or end in a given time frame). Here's what I'm currently doing: Project.where('(s...
more »

2017-04-19 16:04 (2) Answers

My rails controller didn't work

My rails application is used acts-as-taggable-on. I would like to add function which articles can be searched by tags. In my articles_controller.rb def index @articles = params[:tag].present? ? Article.tagged_with(params[:tag]) : Article.all ...
more »

2017-04-19 07:04 (1) Answers

MRI duplicates memory allocation when Thread.new

It seems that MRI makes duplication of memory allocation for every new thread. I use Ubuntu x64, ruby-2.2.4 (rvm), and this what i get: Just started irb: I see pmap -d 1656 59760K (allocated memory, or '[ stack ]' for the program stack [man pmap...
more »

2017-04-18 19:04 (0) Answers

How to save a variable in an rspec expect?

I have something along the following lines in one of my spec files: expect(my_instance).to receive(:my_function).with(arg: instance_of(String)) I want to be able to capture the actual value of arg in a variable I can use in the spec. Is there a wa...
more »

2017-04-18 18:04 (1) Answers

Sinatra event triggered by Rufus Scheduler

Trying to send an event from within Rufus Schedulers results in this error: { 70231586340180 rufus-scheduler intercepted an error: 70231586340180 job: 70231586340180 Rufus::Scheduler::IntervalJob "2s" {} 70231586340180 error: 7023158...
more »

2017-04-18 17:04 (1) Answers

Globalid and pg not existing when in gemfile

I am trying to rails server from a cloned repo, I have updated ruby, and rails, followed the rvm process, updated all my gem files, and when I go to serve I receive the message Could not find globalid-0.3.7 in any of the sources Run bundle inst...
more »

2017-04-18 01:04 (2) Answers

FactoryMethod pattern on Ruby

I'm learning the design patterns. How do you think is it an appropriate example of FactoryMethod pattern? There are Unit and its subclasses: Soldier and Doctor. They can greet somehow. There are also UnitFactory, SoldierFactory and DoctorFactory. T...
more »

2017-04-17 21:04 (0) Answers

Binary tree maze generation in Elixir

I have an implementation of a binary tree maze generation in Ruby, in a purely OO way. I'm trying to rewrite this in Elixir as a learning exercise but I'm running into some problems with OO vs FP paradigms. I render a grid containing cells. When wal...
more »

2017-04-17 16:04 (1) Answers

How to correctly use require? - ruby

I have this small project I've been working on. In this project, I've been using the rspec to test the classes, so my project folder is structured like this: . +--lib | +-- # bunch of classes | +--spec | +-- # bunch of tests Being in the pro...
more »

2017-04-17 16:04 (1) Answers

How to output variable in sinatra without <%=

In Rails, there exist such helper as "concat" to output variables inside <% %> block for erb remplates. Which helper can I use in Sinatra to perform the same action, without using <%= %> block ? I mean, something like <% #code concat "Thi...
more »

2017-04-17 12:04 (1) Answers

How to add image upload system in Active admin?

I tried a lot but couldn't get an idea. I am using windows 32 bit system and mysql as database. I tried https://spin.atomicobject.com/2016/07/23/file-upload-active-admin-paperclip/ this but it didn't save the image and its attributes on database. Ple...
more »

2017-04-17 03:04 (0) Answers