How to create a random index in Jolie - jolie

I am starting to play around with Jolie I was looking for a way to randomise an index
What include do I need to use, can you create a random integer number?

Thanks for the question and interest in Jolie.
Can you create a random integer number?
Not directly
What include do I need to use?
math.iol
Here my simple code
include "math.iol"
include "console.iol"
main{
random#Math()(randomResult);
randomIndex= int (randomResult*10); // 10 is the maximum index size
println#Console(randomIndex)()
}
I hope this helps
B

Related

In the code igniter 3, how is the unique code applied in online nominal payments?

I'm a beginner in programming. please allow me to ask. So I'm making a top up form with Codeigniter 3. I want to give a unique code for each nominal top up. For example, a member will top up 100,000, then what must be transferred is 100,123 (example). how to generate 3 numbers behind it?
Thanks for reading and willing to help
please let me help to answer the question. I think, you just add another php function, for random numbers as needed.
My Example code like this:
<?php
// get top up value from form
$value_top_up = 100000;
// add random number
$value_top_up += rand(100,999);
// example result = 100729
echo $value_top_up;
?>

generate date range with calendar as input

is there a way to directly use
from pandas.tseries.holiday import USFederalHolidayCalendar
in order to subsequently generate a DatetimeIndex, which excludes holidays?
it does not seem like pd.bdate_range() can accept such an argument, but surely there must be some convenient way to accomplish this?
edit:
was able to create a frequency parameter with the CustomBusinessDay() class
USBDay = CustomBusinessDay(calendar=USFederalHolidayCalendar())
pd.bdate_range(start=start, end=end, freq=USBDay)
problem solved!
solution:
was able to create a frequency parameter with the CustomBusinessDay() class
USBDay = CustomBusinessDay(calendar=USFederalHolidayCalendar())
pd.bdate_range(start=start, end=end, freq=USBDay)

Python 3 - string to list (I know it has been asked but I can't get anything to work)

I have an assignment, similar to scrabble. I have to check if a subset is in the set. can only use a letter once. so if subset has 2t and the set has 1t it is false.
My problem is, I used 2 inputs to allow people to enter the subset and set, but that create a string no breaks between the letters which mean split or list won't create a LIST with individual letters. (at least I can't find any way.)
My plan was something like
wordset = word.lower().split()
subset = letters.lower()
for i in range(len(subset)):
if i in subset and in set:
set.remove(i)
I know that properly won't work but until I can get it into a list or someone gives me a hint how to do it with string I can't start testing it. Sorry for so much writing.
If you wish to get a list of characters in a given string you can use a list comprehension:
characters = [x for x in some_string]

Varnish4: need a random integer value

I need a random integer value in Varnish 4.
The std.random() function results in a REAL with three trailing digits.
In VCL:
set req.http.X-AB-test1 = std.random(1,4)
Observed result:
X-AB-test1=3.182
I would love to find some equivalent to the feature that Fastly offers in its extended VCL: 'randombool()' or even better 'randombool_seeded()'
Thank you!
If you are looking for a solution to generate a/b test values, check this solution
Existing integer values that might help: req.xid, now
I solved this by upgrading to Varnish 4.1 and using the function std.real2integer() like this:
set req.http.AB-monitor = std.real2integer(std.random(1,2), 0);

Cassandra comments data model

I am trying to store very simple comments in a wide row, but the problem is that i want to have top comments.
So at first I have tried to use UTF8 comparator type and each column name would begin by likes amount and would be followed by timestamp, for example:
Comments_CF = {
parent:{
8_timestamp: comment,
5_timestamp: comment,
1_timestamp: comment,
...
}
...
}
The problem with this approach is that for example 2_timestamp > 19_timestamp because lexicographically 2 is bigger than 19
I could probably store top comments in a separate CF but then i would need to do two queries instead of one so i would really like to avoid that, any suggestions?
2 queries instead of one is usually not a big deal. You could also just do a composite value(number of likes+the comment) and sort the comments yourself....From stuff I have seen there is never alot of comments except a few posts anyways so that would be very quick.
There are other patterns that might spark ideas here as well...
https://github.com/deanhiller/playorm/wiki/Patterns-Page
Use a composite, where the first component is a long and the second is whatever type is appropriate for your timestamp format. This way the sorting will be correct.

Resources