How to extract from an array by name that includes a specific string? - ruby-on-rails-5

I am building a Rails 5.2 app.
In this app I handle incoming emails. I parse the body of the email and get an array with links from the body. How can I extract a specific link/url and remove the others.
This is my array:
["code:", "request:", "https://mail.google.com/mail/vf-%5BANGjdJ9Ql923ILcJJ6A_uyjeKXxfYXWYew3ao8Hg1sDGPECPFhhZ7LPRP2-vIfW09o5MIoRmcrdxNDnD9LPYUTwTTx-LaJLIlfZ1xoGL7vyjLVlDyU8PVlv1T9Rf3p_I%5D-DWNS6pShF_p-zPxZNCLRE7RI-hI", "verification:", "https://mail.google.com/mail/uf-%5BANGjdJ-tvNwZ7q-MwbYcKwoXRJQ9XN0bTmUKs5ktJIP2gmeHTvnbBEj_ogXKy6uTz2dF6a-W6Qbz-2oJ5olVf4m5QPvpAi9nKS_6wHIcFY1WzYkQh3d_OS0o2r0dDB50%5D-DWNS6pShF_p-zPxZNCLRE7RI-hI", "visit:", "http://support.google.com/mail/bin/answer.py?answer=184973."]
I extract links with this:
URI.extract(body)
It unfortunately not only extracts links but other strings.
I want to extract the link starting with https://mail.google.com/mail/.

Related

How to send a list of numbers / strings with scrapyd to a spider when using scrapyd.schedule

I'm trying to start my scrapy bot from a Django application and I need to pass in a list of strings and also a list of numbers that the bot requires to function. This is my code in the views.py of my Django application:
task = scrapyd.schedule('default', 'arc',
settings=settings, numIds=numIds, formOp=formOp)
numId is the list of the numbers I need to pass and fromOp is the list of strings I need to pass. I tried extracting them in the scrapy spider file using:
kwargs.get('numIds')
kwargs.get('formOp')
for some reason, it only gives me the first number/string in the list even if I try and send a JSON object. is there a way to pass the entire list through scrapyd?

Is there any way to store array/list as variable/parameter in constructing an API in Postman?

I'm trying to parameterize a url in Postman and loop over that list to call multiple APIs one after another and append the JSON bodies.
For example:
if the url is GET https://location/store/{{user_id}}/date
and
user_id = ['1','3','5','2','6','8']
then how do I store user_idas a variable such that request can loop over each user_idin the url and generate an appended JSON body?
You can use data files. Store the user id values into a csv or JSON file and call that file in to your collection runner. The headers of the csv files can be used as variables names. please see the details of this approach in the below link
https://learning.postman.com/docs/postman/collection-runs/working-with-data-files/

How to get all the data from a DICOM file with Imebra

I am working on a project that integrates Imebra inside an android application. The application is supposed to extract all the data from a given DICOM file and put them into a .xml file. I need a little bit of help with it. For example, I don't know how to get all the VR tags that the given DICOM has, instead of getting them one by one using tag ids.
Thank you for your help.
Load the file using CodecFactory.load(filename).
Then you can use DataSet.getTags() to retrieve a list of tags stored into the DICOM structure.
The returned class TagsIds is a list containing all the TagId: scan each tag ID and retrieve it via DataSet.getString() (to retrieve the value as string) and DataSet.getDataType() to retrieve its VR.
When DataSet.getString() fails then you are dealing with a sequence (an embedded DICOM structure) which can be retrieved with DataSet.getSequenceItem().
You can use the static method DicomDictionary.getTagName() to get a description of a particular tag.

How to call whatsmate translation API on the Bowser?

subscribed to their API today, I was wondering about how I can call their API on the browser
they already provided this, I tried a lot but I didn't get anything
See Their API Reference https://whatsmate.github.io/api-reference/
Translation Endpoints
1. Translate text
Endpoint: POST /v1/translation/translate
Parameters required in JSON payload:
fromLang: String. The code representing the language of the supplied text.
toLang: String. The code representing the language you want the text to be translated to.
text: String. The piece of text you want to be translated.
List of language codes: See the next endpoint.
Response: String. The translated text.

How to test / extract different mime parts of Mail::Message in Rails

When testing a multipart mail message in rails 3, is there a built-in way to extract the different parts (text/html, text/plain, etc) and then test those
I've hacked together something quickly for use in my test: https://gist.github.com/2899995, but would prefer to use existing rails code if it exists.
You can use email.html_part and email.text_part to get the two parts and email.html_part.body and email.text_part.body to get the text. You can also validate the email is multipart with email.multipart?
The email.parts method will give you all the parts of the message:
https://github.com/mikel/mail/blob/master/lib/mail/message.rb