adonis-scheduler module running several times - scheduler

I've installed adonis-scheduler module, and I set up the time to run everyday, following the pattern according to node-scheduler which it makes use of:
static get schedule() {
return '* */23 * * *'
}
But it happens that I saw results many times today, like it wasn't set for every day. Is this correct?

The cron expression you have listed should run every minute. You may be looking for something like 0 */23 * * *.
This site is helpful for writing cron expressions.

Related

Nightbot command - !uptime combined with a different command, is it possible?

I don't know if I'm posting to the right place or what but I was wondering if someone could help me with a Nightbot command I want to make.
I have the !uptime command and I have a !rage command which only retrieves one value. Now I'd like to combine the two into a command that would retrieve 5 or 6 different values (stages of rage in this situation) depending on what value !uptime would retrieve. So basically if I have been streaming for an hour !rage would say minimum but if for 5 hours it would say critical or something.
How is this possible? Someone pls help
Go to https://nightbot.tv/commands/custom and simply add these two commands
command : message : alias
!hour : $(eval var index = $(1); const options=["min","avg","max","babyRage"]; options[index] )
!rage : $(urlfetch https://beta.decapi.me/twitch/uptime/itsashawe) : !hour
NOTE: Remember to use your channel name instead of mine (itsashawe). Make sure you add !hour as alias in the !rage command.
P.S.
I've used an api to make it simpler. The rage command calls the hour command which gets the hours, minutes and seconds. The rage command uses $(1) i.e. the first argument i.e. the hour and uses it as an index to get values from options which you can change according to your use.

How to find out KDB Query Execution Time

I would like to find out how much time a query took for getting executed. I plan to log this for audit and support purposes.
I have found this in the documentation:
q)\t log til 100000 / milliseconds for log of first 100000 numbers
3
But the above method actually evaluates the query again and tells us the time. It doesn't return the results of the query. So if I use this it will actually be like running every query twice, once for getting the results and once for knowing the execution time.
Is there any other method someone is aware of?
You could also capture the time before/after the query runs to figure out the execution time.
Execute on one line:
q)start:.z.p;result:log til 100000;exectime:.z.p-start
q)exectime
0D00:00:00.297268000
q)result
-0w 0 0.6931472 1.098612 1.386294 ...
This method will give you nano-second precision but can easily be adapted to return the same as \t.
q)res:system"t a:{st:.z.p;log til 10000000;.z.p-st}[]"
q)`long$`time$a /convert to Ms
297
q)res
297
You can use a "system t" call (the equivalent of \t) to store the result and the time in one go.
b:system"t a:log til 100000"
It's not very general or functional though so it mightn't suit your needs to have the commands inside a string.
Expanding on Connor's idea, you can wrap this in a function that will return the value and print the time taken to stdout:
time:{ t0:.z.t; r:eval x; 0N!.z.t-t0; :r }
And then send the parse tree of your function as the argument:
q)a:time (log;til 100000)
00:00:00.003
q)a
-0w 0 0.6931472 1.098612 1.386294 1.609438 1.791759 1.94591 2.079442 2.197225..

Adding messages to grib2 files

Context
I would like to add additional fields to a grib2 file, which are a function of existing fields.
e.g.: I would like to add a wind-chill message, given by the formula:
35.74 + 0.6215 * T -35.75 * V^0.16 + 0.4275 * T * V^0.16
where T and V are the temperature and wind speed field that appears in the original grib2 file.
Question
I have searched for documentation on the subject, but failed to find any reference :(
Is there any easy way doing that (preferably using bash, other interfaces are also relevant...)?
Thanks :)
Multi-field messages are generally considered a bad idea. Regardless, to edit a message, you can use grib_api or wgrib.

Quartz Get trigger description

Is there a function in the API that returns language description of a trigger? For example,
cron trigger expression="0 0 0 L * ?"
Language I'm looking for is "Fires at 0:00:00 every last day of the month" (Or something like that)
I want to use this to give feed back to user of what schedules are created. I'm hoping I don't have to parse the expression myself. I search Google but have came empty, maybe I'm not using the right words to search for.
I'm using the .NET version. But if there is a java function out there I could probably figure out how to port it.
Thanks in advance
There is a question similiar to this here I think your going to have to write something yourself for this.

Sum of DOM elements using XPath

I am using MSXML v3.0 in a VB 6.0 application. The application calculates sum of an attribute of all nodes using for each loop as shown below
Set subNodes = docXML.selectNodes("//Transaction")
For Each subNode In subNodes
total = total + Val(subNode.selectSingleNode("Amount").nodeTypedValue)
Next
This loop is taking too much time, sometime it takes 15-20 minutes for 60 thousand nodes.
I am looking for XPath/DOM solution to eliminate this loop, probably
docXML.selectNodes("//Transaction").Sum("Amount")
or
docXML.selectNodes("Sum(//Transaction/Amount)")
Any suggestion is welcomed to get this sum faster.
// Open the XML.
docNav = new XPathDocument(#"c:\books.xml");
// Create a navigator to query with XPath.
nav = docNav.CreateNavigator();
// Find the sum
// This expression uses standard XPath syntax.
strExpression = "sum(/bookstore/book/price)";
// Use the Evaluate method to return the evaluated expression.
Console.WriteLine("The price sum of the books are {0}", nav.Evaluate(strExpression));
source: http://support.microsoft.com/kb/308333
Any solution that uses the XPath // pseudo-operator on an XML document with 60000+ nodes is going to be quite slow, because //x causes a complete traversal of the tree starting at the root of the document.
The solution can be speeded up significantly, if a more exact XPath expression is used, that doesn't include the // pseudo-operator.
If you know the structure of the XML document, always use a specific chain of location steps -- never //.
If you provide a small example, showing the specific structure of the document, then many people will be able to provide a faster solution than any solution that uses //.
For example, if it is known that all Transaction elements can be selected using this XPath expression:
/x/y/Transaction
then the evaluation of
sum(/x/y/Transaction/Amount)
is likely to be significantly faster than Sum(//Transaction/Amount)
Update:
The OP has revealed in a comment that the structure of the XML file is quite simple.
Accordingly, I tried with a 60000 Transaction nodes XML document the following:
/*/*/Amount
With .NET XslCompiledTransform (Yes, I used XSLT as the host for the XPath engine) this took 220ms (milliseconds), that means 0.22 seconds, to produce the sum.
With MSXML3 it takes 334 seconds.
With MSXML6 it takes 76 seconds -- still quite slow.
Conclusion: This is a bug in MSXML3 -- try to upgrade to another XPath engine, such as the one offered by .NET.