TiL: Double Splat Nil in Ruby
How Ruby can do what you don’t expect Ruby is a very clever language. It will take the code you’ve written and do it’s best to make sure it runs. Take for example the following method call: method_one('Hello', param_two: ' world') That looks simple enough as it takes two arguments, one positional and one keyword. Now, lets take a look at what the method is actually doing: def method_one(param_one, param_two) p param_one, param_two end Interesting. At first glance it might appear that this method would print Hello world, but there is a subtle difference between how the method has been defined and how it is called. Let’s see what it actually outputs: ...
Checking for existing user in Atlas
Ever had to create users in MongoDb Atlas in AWS for use when making database enquiries in a functional test written in Ruby? Ever wished you could leave it to the test pack to check if one already exists and create one when required, instead of hand cranking a new one every single day of your life? Well now you can!!! But, first things first What is MongoDB Atlas and what do its users do? ...
KA-PING! a gem to integrated with Elastic and OpenSearch
You can only stretch elastic so far before it goes KA-PING! The starting point for creating a new DVLA gem to integrate with AWS OpenSearch and ElasticSearch was the amount of documentation there is surrounding the technology. There is a lot for a reason, it’s a very powerful and useful tool, but the flip side is the learning curve involved in understanding all the features and query structure. Our use case is we wanted squads to have a simple way to retrieve specific driver test data to use in their tests without having to fully understand Elasticsearch and all its capabilities. ...
Experimenting with Retrieval Augmented Generation (RAG) with LLMs
Note well Please ensure you consider and adhere to any policies and restrictions your organisation places on the use of data with AI and the selection of AI models. I want to be able to ask an generative AI some questions while giving it the context from which I’d like it to use it’s smarts to derive an answer. This is Retrieval-Augmented Generation (RAG). Being a Ruby engineer, I’m going to pick up my shiny red hammer to attack this problem. ...
TiL: Using the max_by method in Ruby
When trying to get an upper or lower value for a certain field in an object can be cumbersome. But when using the max_by method, this can actually be done quite elegantly. For example: persons = [ { "name" => "John McJohnson","age" => 34, "topScoreAtBowling" => 205}, { "name" => "Davey Jones","age" => 304, "topScoreAtBowling" => 300}, { "name" => "Willy Wonka","age" => 50, "topScoreAtBowling" => 200} ] If we had a bowling competition and wanted to see who had the topScoreAtBowling field, rather than looping through the array and looking at each object, we can simply use the max_by command as follows: ...