Fatos Morina

Software engineering and personal development

Month: September 2017

How to iterate over a stream with indices

 

Img source: deadcoderising.com

Baeldung.com is yet another publishing site in which I have published one article. It is a technical article related to a few ways of iterating over Java streams with indices.

Continue reading

Repeat code blocks after exceptions with Retryable gem

Retryable is another handy gem that lets you repeat a code block after an exception has happened. It has a really easy syntax, and comes with many customizations, that make it a great tool to use, especially when you have to work with web services.

Continue reading

Get random data for your tests with Faker gem

Img caption: railscarma.com

Developers may feel they do not have that much creativity when it comes to use random words as arguments, or values for many fields. For example, if we have some test cases when we are creating a new instance of a Book object, chances are that we will assign ‘book’ to this object’s title, which does not seem that much interesting. We code because it is something that gives us pleasure, and getting help with these types of difficulties can be helpful. Fortunately, there is a Ruby gem called Faker that generates random fake value that you can use in your tests.

Continue reading

Select ActiveRecord’s rows with pluck and column names with pluck_to_hash

Img caption: stackoverflow.com

When you select multiple column values using pluck method of ActiveRecord, you usually get an array of arrays. If you want to get an array of hashes with column names as hash keys, you can use this useful Gem called pluck_to_hash.

Continue reading

© 2017 Fatos Morina

Theme by Anders NorenUp ↑