Mockaroo Formulas for random date range using Ruby - ruby

I am trying to create a data field using Mockaroo and they say they have Ruby support but I know nothing about Ruby so I am trying to find out how to do a field that will randomly choose between the 3 options.
now() or
now()+days(-1) or
now()+days(-2) or
now()+days(-3)
Idea 1
I was initially thinking something using random like now()+days(this.rand(-3))
Idea 2
I also thought of using or logic like now() or now()+days(-3) or etc...
This answer may end up being different than a typical ruby solution since Mockaroo has their own little API to use too... Appreciate any help that can be given.

Turns out I had to use the random function first and pass in min and max date parameters.
random(now()+days(2), now()+days(-3))

Related

How to perform Sorting using flow steps in WebMethods (Software AG)?

I am new to this Middleware and I tried my level best to perform sorting using the flow steps in designer but couldn't make it.Can anybody help me out by giving me direction for how to complete my work?(like the flow steps in order and where i can put the conditions and all)
Thanks.
No need to over-complicate it - use the utilities - pub.document:sortDocuments is what you are looking for.
If you receive stringList as input - convert this into a documentList. This can be done using pub.list:stringListToDocumentList (set the key to 'value')
Use pub.document:sortDocuments to sort the documentList. Remember to specify the key as 'value' once again and compareStringAs as 'numeric'. The order can also be set (ascending/descending)
What do you want to Sort? For Document-Lists you will find a built-in services in the WmPublic Folder.
For String-Lists i would use a Java-Service for Sorting.
Logic behind Sorting in webMethods is same as all other languages. You need LOOP to iterate every string in stringList, BRANCH to compare the two number and then map to the compare result to new StringList.
What format do you have the numbers in? Are they in a flat file or in a string list etc.

Using Date Range in Google Search API with Ruby

I am using the google-search gem for Ruby found here.
And I'm trying to make my search within a custom date range.
results = Google::Search::Web.new(query: "SearchTerm daterange:2455197-2455562")
That doesn't seem to work and just ignores the daterange which is how you would do the search normally with Google. So it gives me the results for the term with no date range.
Does anyone have any experience with this? Or maybe there is a better solution.
NOTE: I have no experience with 'google-search' gem, following
solutions are NOT tested!
According to google docs, the api expects something like:
https://www.google.com/cse?cx=12345:example&q=lebanese+restaurant&sort=review-date:r:20090301:20090430
To make google-search populate this request for us, you could try two things:
Use order_by option (which is not documented but i imagine it will do sorting)
results = Google::Search::Web.new(query: "SearchTerm", order: "review_date:r:2455197-2455562")
2.According to gem ReadMe:
Arbitrary Query String Support
Arbitrary key / value pairs may be passed to Google::Search.new, all
options passed that are not assigned (deleted) will pass on to be part
of the query string.
So, theoretically we could do:
results = Google::Search::Web.new(query: "SearchTerm", sort: "review_date:r:2455197-2455562")
Give it a try!

Possible to have a simple formula within the [value_if] argument? - excel

I'm trying to use a relatively basic IF function but having no luck - i'm sure i just have brackets or parenthesis wrong or something. Reckon it will be childsplay for you guys....
The formula is intended to show how many days a date has passed by. Date is shown in T column.
Basically it was working fine as the following, both for pending and past dates:
=IF(T7<=TODAY(), (TODAY()-T7),-(T7-TODAY()))
But I got greedy and wanted it to return more of a statement when the date has passed, as to how much it has passed by. So I've tried to make this happen with:
=IF(T7<=TODAY(),"EffOut(TODAY()-T7) days ago",-(T7-TODAY()))
Hoping it would enter "EffOut 8 days ago" (when TODAY()-T7 is 8 days) for example.
But it doesnt - it shows the entire argument i.e "EffOut(TODAY()-T7) days ago" in the return cell.
Is it possible to have a kind of embedded formula in the 'value_if' fields, mixed with text in this sense?
Happy to share the document if that would help, but will need to clear the data first so just let me know.
Thanks in advance, any help is much appreciated! Having read other posts I think it will just be a simple fix but its well beyond me! (I only got this far by perusing forums...)
Maybe something like this...
=IF(T7<=TODAY(),"EffOut "&DAYS(TODAY(),T7)&" days ago",-(T7-TODAY()))
=IF(T7<=TODAY(),"EffOut "&(TODAY()-T7)&" days ago",-(T7-TODAY()))
You just need to be careful to put "" around any strings. This is how Excel knows that's not a part of the formula. Remember to out the spaces is to the string like I did above so it looks like a sentence. The & sign combines the results of the calculated parts and the strings.

How to get difference between 2 dates as duration via using xpath on BPM 11g

Need to get difference between 2 dateTime payload objects as duration format for using on HT expiration value. (i.e. returned as PT2055M or P1DT10H15M)
Actually checked functions on that link: http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_appx_functs.htm#autoId13
And i tried to solve the issue by creating duration such as
concat("P", xp20:year-from-dateTime(string(bpmn:getDataObject('myPayloadDate'))) - xp20:year-from-dateTime(xp20:current-dateTime()) ,"Y", xp20:month-from-dateTime(string(bpmn:getDataObject('myPayloadDate'))) - xp20:month-from-dateTime(xp20:current-dateTime()),"M", xp20:day-from-dateTime(string(bpmn:getDataObject('myPayloadDate'))) - xp20:day-from-dateTime(xp20:current-dateTime()),"DT", xp20:hour-from-dateTime(string(bpmn:getDataObject('myPayloadDate'))) - xp20:hour-from-dateTime(xp20:current-dateTime()),"H",xp20:minute-from-dateTime(string(bpmn:getDataObject('myPayloadDate'))) - xp20:minute-from-dateTime(xp20:current-dateTime()),"M")
But realized that this approach interests with just only seperate values not whole values as expected.
I could not find the right composition of functions to solve.
Could you plz guide?
Assuming you have an XPath 2.0 processor, just use the subtraction operator. For example
current-date() - xs:date('2001-03-04')
gives
P4744D
(You said "dates" but your examples look more like dateTime's. The subtraction operator will work with either.)

Getting text from a form and evaluate in selenium using ruby

I am testing a registration form and one of the questions before submitting is:
"What is 8 + 4?"
The values will be different every time. I am using Selenium 2 with Ruby and want to to see if anyone knows how to a) get the text from the question and then b) compute the addition and return the correct answer in the field.
Thanks!
Using ruby code try to get the values in between is and ? Store this in Variable and now split the text with deliminator + now you will get the Values in array in different location. Now you can add these two and use for your evaluation. I don't have idea about ruby but its possible in PHP as I have done the same. Its should be in Ruby too.
Getting text between is and ? can be done strpos() in php that gives the position of the string see similar function for ruby.

Resources