I have written a rule like
if
the period of 'Request' is more than 0
then
set the date of 'Request' to due_date - 1 Day;
else
set the date of 'Request' to due_date ;
for period values other than 0 it's working fine but when value of period is 0 it just skips whole rule, i.e it neither go to then nor else.
I am using ODM 8.6 and testing through DVS file.
I have tried same thing in ODM 8.5 and it's working fine there
please help in getting this issue resolved.
Did you try with the latest fixpack?
In general it is poor design for rules to use the else construct. Try to split the rule into 2 different rules:
for period of 'Request'>0, and
for period of 'Request'<0.
Related
Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
Trying to use node.dsleepMax() and it is returning a really smaller number (147324921). Then I tried to manually set the sleep time in node.dsleep to the 32-bit max value (4294967295) and it only remained sleeping for around 30 min or so.
Tried the following:
sleeptime = 4294967295
>
=print(sleeptime)
2147483647
which is 2^31 -1.
Also did a loop adding to a variable, and it becomes negatve when it reaches 2^31.
Questions:
Why is the variable wrapping at 2^31?
Isn't node.dsleep supposed to accept a 64-bit value with SDK 2.1 and above?
Regards,
Cesar
You already got some feedback regarding int vs. float. As for dsleep the documentation doesn't explicitly state that it accepts 64bit values but that's indeed what's happening as per https://github.com/nodemcu/nodemcu-firmware/pull/2358 (since April 2018).
Problem
Hello, StackOverflow community! I am working on this Lua game, and I was testing to see if it would change the text on my TextLabel to the Bitcoins current worth, I was utterly disappointed when nothing showed up.
I have tried to do research on Google, and my code seems to be just right.
Code
Change = false
updated = false
while Change[true] do --While change = true do
worth = math.random(1,4500) --Pick random number
print('Working!') --Say its working
Updated = true --Change the updated local var.
end --Ending while loop
script.Parent.TextLabel.Text.Text = 'Bitcoin is currently worth: ' .. worth
--Going to the Text, and changing in to a New worth.
while Updated[false] do --While updated = false do
wait(180) --Wait
Change = true --After waits 3 minutes it makes an event trigger
end -- Ending while loop
wait(180) --Wait
Updated = false --Reseting Script.
I expect the output on the Label to be a random number.
I can't really speak to roblox, but there are a couple of obvious problems with your code:
Case
You have confusion between capitalized ("Updated", "Change") and lowercase ("updated", "change" [in commented while statement]), which will fail. See, for example:
bj#bj-lt:~$ lua
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> Updated = true
> print(Updated)
true
> print(updated)
nil
So be super-careful about what identifiers you capitalize. In general, most programmers leave variables like that in all-lowercase (or sometimes things like camelCase). I suppose there might be some oddball lua runtime out there that is case-insensitive, but I don't know of one.
Type misuse.
Updated is a boolean (a true/false value), so the syntax:
while Change[true] do
...is invalid. See:
> if Updated[true] then
>> print("foo")
>> end
stdin:1: attempt to index global 'Updated' (a boolean value)
stack traceback:
stdin:1: in main chunk
[C]: in ?
Note also that the "While change == true do" is also wrong because of case ("While" is not valid lua, but "while" is).
Lastly:
Lack of threading.
You have basically two different things that you're trying to do at once, namely randomly change the "worth" variable as fast as possible (it's in a loop) and see a set a label to match it (it looks like you probably want it to change constantly). This requires two threads of operation (one to change worth and another to read it and stick it on the label). You've written this like you're assuming you have a spreadsheet or something and that. What your code is actually doing is:
Setting some variables
Updating worth indefinitely, printing 'Working!' a bunch, and...
Never stopping
The rest of the code never runs, because the rest of the code isn't in a background thread (basically the first bit monopolizes the runtime and never yields to everything else).
Lastly, even if the top code was running in the background, you only set the Text label one-time to exactly "Bitcoin is currently worth: 3456" (or some similar number) one time. The way this is written there won't be any updates thereafter (and, if it runs once before the other thread has warmed up, it might not be set to anything useful at all).
My guess is that your runtime is spitting out errors left and right due to the identifier problems and/or is running in a tight infinite loop and never actually getting to the label refresh logic.
BJ Black has given an excellent description of the issues with the syntax, so I'll try to cover the Roblox piece of this. In order for this kind of thing to work properly in a Roblox game, here are some assumptions to double check :
Since we are working with a TextLabel, is it inside a ScreenGui? Or a SurfaceGui?
If it's in a ScreenGui, make sure that ScreenGui is in StarterGui, and is this code in a LocalScript
If it's in a SurfaceGui, make sure that SurfaceGui is adorning a Part and this code
is in a Script
After you checked all those pieces, maybe this is closer to what you were thinking :
-- define the variables we're working with
local textLabel = script.Parent.TextLabel
local worth = 0
-- create an infinite loop
spawn(function()
while true do
--Pick random number
worth = math.random(1,4500)
-- update the text of the label with the new worth
textLabel.Text = string.format("Bitcoin is currently worth: %d", worth)
-- wait for 3 minutes, then loop
wait(180)
end
end)
I removed Updated and Changed because all they were doing was deciding whether or not to change the value. The flow of your loop was:
do nothing and display an undefined number. Wait 3 minutes
update the number, display it, wait 6 minutes
repeat 1 and 2.
So hopefully this is a little clearer and closer to what you were thinking.
Hey Stack Overflow fellows,
I need your help on this one. For a few months now I'm dealing with Ruby on Rails application that is mostly Legacy. Today, I noticed the weirdest thing about the codebase. Some files, not many but the significant ones, contain a few lines of code that would end up with ; 1. Like for example: Users.find(id); 1. Occurrence of those suffixes does not create any form of the pattern. Sometimes is ; 1 appears after puts or after expression that will always return value e.g. nil || 'default_value'; 1.
Does it make any sense to use the suffix? Is there any reason behind this? Maybe there used to be a tool that worked with Ruby code and ; 1 was form of annotation. I would gladly remove the suffix but I want to make sure that it's 100% safe.
Here is a code sample from the project added in the same commit:
times = events.map{|x| [x.time, x.time_from_impression_id]};1
times = times.map{|x| (x.first - x.last) / 1.day}.sort;1
time_to_event_success = times[(times.length.to_f * 0.95).to_i]
events = events.select{|e| e.time_from_impression_id < time_to_event_success.days.ago};1
Semi-colons in ruby terminate statements in the same manner as a line break. The ; 1 really isn't doing anything useful.
Logically the code you posted is equivalent to:
times = events.map{|x| [x.time, x.time_from_impression_id]}
1
times = times.map{|x| (x.first - x.last) / 1.day}.sort
1
time_to_event_success = times[(times.length.to_f * 0.95).to_i]
events = events.select{|e| e.time_from_impression_id <
time_to_event_success.days.ago}
1
The only thing I can think of is that if someone was testing the code out in IRB adding the ; 1 to the end of a line would prevent the return value of the previous statement from echoing. That or they didn't quite understand how implicit return and truthy and falsy values work in ruby.
I am currently using ActiveRecord to access a PostGres DB.
The overall app works but I have some issue when trying to get the data from a specific timezone.
I am trying to get data since X to today.
I have user the where condition as below:
time = [ "ts > :since_date", since_date: params['since']]
This returning the list of data from "since_date" to the last one.
My issue is I do not want the 'since_date' as a part of the result but everything > to since_date. I have tried to play with '>=' and '>' only.
In both cases, I have the same result.
Any idea how to not have the 'since_date' as a part of the result
Right now the ts field is always following the format :
2017-08-24 07:00:21.967185+00
et the param['since'] will follow exactly the same format :
2017-08-24 07:00:21.967185+00
which mean when I am doing the where condition with since using the command
time = [ "ts > :since_date", since_date: params['since']]
must return from '2017-08-24 07:00:21.967185+00' to now but the data with ts = '2017-08-24 07:00:21.967185+00' must not be returned that's why I have used > instead of >=
Thanks
how would the JQL look like for this condition?:
Generate a report of all HIGH severity JIRA tickets for a project with key X (or name X) that were created from 9 PM EST to 12 AM EST from the start of the year?
I tried something like :
Project = X AND Severity = "HIGH" AND created > "2015/01/01 21:00" and created < "2015/09/09",
but I need only those issues that are created between 9 PM and 12 AM everyday, from the beginning of the year.
Any ideas would be greatly appreciated.
Unfortunately there seems to be no tool to get the hour from created date but you can workaround it.
My two ideas are:
find these tickets directly on Jira database (if you have access) it should be very easy since there are functions like hour (mySQL) or truncate (postgres)
prepare JQL filter using some generator script - it is definetely less comfortable but possible to achieve even when you have not acces to database. The worst thing is that Jira filter fields accepts only 2000 characters string so you would need to copy that filter few lines by few lines.
Little crazy but ok - it works so what's the idea? The idea is to use startOfYear() JQL function and its *offset version**. For example:
created >= startOfYear(21h) and created < startOfYear(24h)
will give you all tickets from 1 Jan 21:00 - 2 Jan 00:00
then you can use this Python script:
step = 27
maxDay = 1
while maxDay <= 365 + step:
maxDay += step
output = "project = X and Severity = HIGH and ("
for i in range(maxDay-step, maxDay):
output += " (created >= startOfYear(" + str( ( (i-1) * 24 ) + 21) + "h) and created < startOfYear(" + str(i*24) + "h)) or"
output = output[:-3]
output += ")"
print output
print
which will generate you set of JQL requests to copy-paste and execute (it is actually 15 of them - you can see here). Every set bounds 28 days because of 2000 limit of filter input in Jira.
I fixed this issue by writing a custom JQL function and then using that function with a JQL query, which fits well with our requirements :
created >= "2015-01-01" and created <= "2015-12-31" and issue in getIssuesForTimeRange("21", "24")