android – Time.timeScale=1 when you close the rewarded ad!

I will add ads and update it in my game and almost everything is ok, but when I turn off the rewarded ad, the game continues in the background by itself. I control stopping and starting the game with the Time.timeScale code, but when I close the rewarded ad, the game automatically sets Time.timeScale=1 and the game runs where it shouldn’t. Even though I wrote Time.timeScale=0 in the HandleRewardedAdClosed(){} part of the ad codes, the problem was not resolved. I would be very grateful if you could help, I want to publish my game as soon as possible. Thank you from now.

dnd 5e – How close do Opportunity Attacks affect flying creatures?

If you are out of a creature’s reach, it cannot make opportunity attacks against you and the Wasp is outside the reach of most Medium creatures

You can make an opportunity attack when a hostile creature that you can see moves out of your reach.

Opportunity attacks only occur if you go from being within somebody’s reach to being outside it, if their reach is 5 feet and you remain 10 feet away, you will not provoke opportunity attacks.

Most creatures have a 5-foot reach and can thus attack targets within 5 feet of them when making a melee attack. 

Medium creatures effectively control a 15×15×15 region regardless of their actual height. Thus, if a creature is two squares above them, that creature is 10 feet away and already out of their reach (various features and Reach weapons aside). In other words, the wasp would avoid any and all opportunity attacks because it is never in a region that the Medium creature can reach.

ubuntu 18.04 – Port 1723 won’t close

I’m not very experienced in linux administration but have been running a server that hosts django for a year or so now. Using ufw I had only opened port 80, 443 and 69 for nginx and SSH.

Recently whilst running tripwire checks I’ve seen a lot of modifications to files – which I’ve assumed is just usual system files doing their thing. I also notice port 1723 is open whilst checking with nmap scans from another machine. I can’t get it to close even when denying with ufw & iptables.

When I check netstat for listening ports it never lists 1723. Is there something suspicious going on or am I missing something?

laravel 8 – Modal created with livewire-ui/modal does’nt close

I am checking the livewire-ui/modal as described in this github page

The modal is showing properly when the open button is clicked but it never closes whatever the mean used is, e.g. :

  • clicking away
  • using the escape touch
  • using a close button with this code
<button wire:click="$emit('closeModal')">No, do not delete</button>
  • usinge a close button with this code
<button class="button-link" wire:click.prevent="close()"> Poster</button>

and having the close function in the modal like this:

<?php

namespace AppHttpLivewire;

use LivewireUIModalModalComponent;

class Hello extends ModalComponent
{
    public function render()
    {
        return view('livewire.hello');
    }

    public function close(){
        
        $this->closeModal();
    }
}

c# – How does Adobe Photoshop have custom close, maximize, and minimize buttons on Windows 10? What language or framework does it use?

I am getting into desktop programming and I want to know which language/framework should I use for windows desktop programming. For macOS, I have decided on Swift and for Linux, Java + JavaFX. But for windows, I can’t pick between C++/WinRT + Win32 or C# with UWP (mostly, a bit of WPF). I already have basic knowledge of C# + XMAL and I am also fine with working hard learning C++. My main concern (at this moment) is that with UWP, I cannot create my own custom close, maximize, and minimize buttons like Adobe Photoshop has (see screenshot below). Their title bar is also thinner than other apps. What do they use? What would you recommend?

enter image description here

Thanks!

dnd 5e – Does wearing a cloak over the Robe of Eyes “close” those eyes, preventing you from seeing out of the robe?

There is a case to be made either way.

This is a great question, and it is going to come down to a DM ruling, as there is a compelling case to be made for either ruling. Unfortunately, I cannot give a definitive answer either way, but I can offer some arguments and let you decide. The first is a more strict rule-oriented approach, that is, let’s just go by what is written without trying to make sense of it; and the other is a more “simulationist” approach, that is, what makes the most sense in the context of the narrative. The DM and the players should just work out how they want to rule on the Robe, and apply that ruling consistently over the course of the campaign.

Interpretation 1: You can still see in all directions, even while the robe is covered by another article of clothing.

There is a case to be made here based on the Robe’s interaction with creatures that have abilities that trigger when they are seen. The medusa has an ability called Petrifying Gaze:

When a creature that can see the medusa’s eyes starts its turn within 30 feet of the medusa, the medusa can force it to make a DC 14 Constitution saving throw if the medusa isn’t incapacitated and can see the creature.

To avoid this, a creature can usually avert its eyes:

Unless surprised, a creature can avert its eyes to avoid the saving throw at the start of its turn. If the creature does so, it can’t see the medusa until the start of its next turn, when it can avert its eyes again.

While wearing the Robe of Eyes, a creature is never considered to be averting their eyes:

Although you can close or avert your own eyes, you are never considered to be doing so while wearing this robe.

If you can never avert your eyes from the Medusa, you can always see the medusa, even while wearing another article of clothing over the robe.

Interpretation 2: The eyes on the robe are doing the seeing, so they would see only the article of clothing that covers them.

Alternatively, we can make an argument from the spell description that the eyes are function as points of sight, and what you see is relative to their position on the robe. Usually magic items don’t tell us how they work – magic be magic. But with the Robe, it seems to indicate how it works:

The eyes on the robe can’t be closed or averted.

This seems to indicate that the position of the eyes matters, so covering the eyes with another robe would mean they see the inside of the robe only.

dnd 5e – Does wearing a cloak over the Robe of Eyes “close” those eyes?

There is a case to be made either way.

This is a great question, and it is going to come down to a DM ruling, as there is a compelling case to be made for either ruling. Unfortunately, I cannot give a definitive answer either way, but I can offer some arguments and let you decide. The first is a more strict rule-oriented approach, that is, let’s just go by what is written without trying to make sense of it; and the other is a more “simulationist” approach, that is, what makes the most sense in the context of the narrative. The DM and the players should just work out how they want to rule on the Robe, and apply that ruling consistently over the course of the campaign.

Interpretation 1: You can still see in all directions, even while the robe is covered by another article of clothing.

There is a case to be made here based on the Robe’s interaction with creatures that have abilities that trigger when they are seen. The medusa has an ability called Petrifying Gaze:

When a creature that can see the medusa’s eyes starts its turn within 30 feet of the medusa, the medusa can force it to make a DC 14 Constitution saving throw if the medusa isn’t incapacitated and can see the creature.

To avoid this, a creature can usually avert its eyes:

Unless surprised, a creature can avert its eyes to avoid the saving throw at the start of its turn. If the creature does so, it can’t see the medusa until the start of its next turn, when it can avert its eyes again.

While wearing the Robe of Eyes, a creature is never considered to be averting their eyes:

Although you can close or avert your own eyes, you are never considered to be doing so while wearing this robe.

If you can never avert your eyes from the Medusa, you can always see the medusa, even while wearing another article of clothing over the robe.

Interpretation 2: The eyes on the robe are doing the seeing, so they would see only the article of clothing that covers them.

Alternatively, we can make an argument from the spell description that the eyes are function as points of sight, and what you see is relative to their position on the robe. Usually magic items don’t tell us how they work – magic be magic. But with the Robe, it seems to indicate how it works:

The eyes on the robe can’t be closed or averted.

This seems to indicate that the position of the eyes matters, so covering the eyes with another robe would mean they see the inside of the robe only.

python – Rigorously checking whether 2 floating point numbers are close in VBA – Exercise in Test Driven Development

cross-post from SO

I’m testing performance regression of some code I wrote (this is not that code) by timing its execution in Unit tests. I would like to see if execution time equals some expected value within a given degree of accuracy, e.g. <1% change. VBA doesn’t have this built in as far as I’m aware, so I wrote this function, inspired by Python’s math.isclose function (but translating to VBA may have introduced some bugs/ required a few nuances):

TestUtils.bas

'@NoIndent: Don't want to lose our description annotations
'@IgnoreModule UnhandledOnErrorResumeNext: Just noise for one-liners
'@Folder("Tests.Utils")

Option Explicit
Option Private Module

'Based on Python's math.isclose https://github.com/python/cpython/blob/17f94e28882e1e2b331ace93f42e8615383dee59/Modules/mathmodule.c#L2962-L3003
'math.isclose -> boolean
'    a: double
'    b: double
'    relTol: double = 1e-09
'        maximum difference for being considered "close", relative to the
'        magnitude of the input values
'    absTol: double = 0.0
'        maximum difference for being considered "close", regardless of the
'        magnitude of the input values
'Determine whether two floating point numbers are close in value.
'Return True if a is close in value to b, and False otherwise.
'For the values to be considered close, the difference between them
'must be smaller than at least one of the tolerances.
'-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
'is, NaN is not close to anything, even itself. inf and -inf are
'only close to themselves. In keeping with existing VBA behaviour, 
'comparison with NaN will also raise an overflow error.
'@Description("Determine whether two floating point numbers are close in value, accounting for special values in IEEE 754")
Public Function IsClose(ByVal a As Double, ByVal b As Double, _
                        Optional ByVal relTol As Double = 0.000000001, _
                        Optional ByVal absTol As Double = 0 _
                        ) As Boolean
                        
    If relTol < 0# Or absTol < 0# Then
        'sanity check on the inputs
        Err.Raise 5, Description:="tolerances must be non-negative"

    ElseIf a = b Then
        'short circuit exact equality -- needed to catch two infinities of
        'the same sign. And perhaps speeds things up a bit sometimes.
        IsClose = True
        Exit Function
        
    ElseIf IsInfinity(a) Or IsInfinity(b) Then
        'This catches the case of two infinities of opposite sign, or
        'one infinity and one finite number. Two infinities of opposite
        'sign would otherwise have an infinite relative tolerance.
        'Two infinities of the same sign are caught by the equality check
        'above.
        IsClose = False
        Exit Function
    
    Else
        'Now do the regular computation on finite arguments. Here an
        'infinite tolerance will always result in the function returning True, 
        'since an infinite difference will be <= to the infinite tolerance.
         
        'This is to supress overflow errors as we deal with infinity.
        'NaN has already been filtered out in the equality checks earlier.
        On Error Resume Next                     
        Dim diff As Double
        diff = Abs(b - a)

        If diff <= absTol Then
            IsClose = True
            Exit Function
        End If
        
        'VBA requires writing the result of Abs(relTol * x) to a variable
        'in order to determine whether it is infinite
        Dim tol As Double
        
        tol = Abs(relTol * b)
        If diff <= tol Then
            IsClose = True
            Exit Function
        End If
           
        tol = Abs(relTol * a)
        If diff <= tol Then
            IsClose = True
            Exit Function
        End If
        
    End If

End Function

'@Description("Checks if Number is IEEE754 +/-inf, won't raise an error")
Public Function IsInfinity(ByVal Number As Double) As Boolean
    On Error Resume Next                         'in case of NaN
    IsInfinity = Abs(Number) = PosInf
End Function

'@Description("IEEE754 -inf")
Public Static Property Get NegInf() As Double
    On Error Resume Next
    NegInf = -1 / 0
End Property

'@Description("IEEE754 signaling NaN (sNaN)")
Public Static Property Get NaN() As Double
    On Error Resume Next
    NaN = 0 / 0
End Property

'@Description("IEEE754 +inf")
Public Static Property Get PosInf() As Double
    On Error Resume Next
    PosInf = 1 / 0
End Property

As you can see, I’ve decided to handle +/- inf and NaN for (I think) more complete coverage, although for my purposes of timing code these values of course have no physical interpretation.

Usage is simple:

?IsClose(1, 1.1, 0.1)  '-> True; 10% relative tol
?IsClose(1, 1.1, 0.01) '-> False; 1% relative tol
?IsClose(measuredSeconds, expectedSeconds, absTol:= 1e-6) 'μs accuracy

Feedback on edge cases/ approach would be great – e.g. not sure if it’s better design to allow for overflow errors in the diff calculation Abs(b-a) since on the one hand IEE754 says that double overflow should result in infinity, and therefore IsClose will always be False since diff is infinite. But what if absTol is also infinite (or relTol>1 and a or b are inf)? Then we expect True regardless of diff.

Also line by line style things would be fantastic – especially comments, naming and other hard stuff.

Finally, here are my unit tests, I’d like feedback on these too if possible; I’ve lumped many into one, but the message is sufficient granularity to identify failing tests so I don’t think splitting tests up would help:

IsCloseTests.bas

Option Explicit
Option Private Module

'@TestModule
'@Folder "Tests.Utils.Tests"

Private Assert As Rubberduck.PermissiveAssertClass

'@ModuleInitialize
Private Sub ModuleInitialize()
    'this method runs once per module.
    Set Assert = New Rubberduck.PermissiveAssertClass
End Sub

'@ModuleCleanup
Private Sub ModuleCleanup()
    'this method runs once per module.
    Set Assert = Nothing
End Sub

'@TestMethod("Uncategorized")
Private Sub IsCloseTestMethod()
    On Error GoTo TestFail
    
    Assert.IsTrue IsClose(1, 1, 0), "Same zero relTol"
    Assert.IsTrue IsClose(1, 1, absTol:=0), "Same zero absTol"
    Assert.IsTrue IsClose(1, 1, 0.1), "Same positive tol"
    Assert.IsTrue IsClose(1, 1.1, 0.2), "Close within relTol for a"
    Assert.IsTrue IsClose(1, 1.1, relTol:=0.099), "Close within relTol for b not a"
    Assert.IsTrue IsClose(1, 1.1, absTol:=0.2), "Close within absTol"
    
    Assert.IsFalse IsClose(1, 1.1, 0.01), "Outside relTol"
    Assert.IsFalse IsClose(1, 1.1, absTol:=0.01), "Outside absTol"
    
    Assert.IsTrue IsClose(PosInf, PosInf, 0), "PosInf same zero tol"
    Assert.IsTrue IsClose(NegInf, NegInf, 0), "NegInf same zero tol"
    
    Assert.IsFalse IsClose(PosInf, 0, absTol:=PosInf), "Nothing close to PosInf"
    Assert.IsFalse IsClose(NegInf, 0, absTol:=PosInf), "Nothing close to NegInf"
    
    Assert.IsTrue IsClose(IEEE754.GetIEEE754SpecialValue(abDoubleMax), _
                          IEEE754.GetIEEE754SpecialValue(abDoubleMin), _
                          absTol:=PosInf), "Finite a, b with infinite diff still close when infinite tolerance"
                          
    Assert.IsTrue IsClose(IEEE754.GetIEEE754SpecialValue(abDoubleMax), _
                          IEEE754.GetIEEE754SpecialValue(abDoubleMin), _
                          relTol:=1.1), "Overflowing infinite relTol always close for finite a, b"
    
    'reversed a,b
    Assert.IsTrue IsClose(1.1, 1, 0.2), "Reversed Close within relTol for a"
    Assert.IsTrue IsClose(1.1, 1, relTol:=0.099), "Reversed Close within relTol for b not a"
    Assert.IsTrue IsClose(1.1, 1, absTol:=0.2), "Reversed Close within absTol"
    
    Assert.IsFalse IsClose(1.1, 1, 0.01), "Reversed Outside relTol"
    Assert.IsFalse IsClose(1.1, 1, absTol:=0.01), "Reversed Outside absTol"
        
    Assert.IsFalse IsClose(0, PosInf, absTol:=PosInf), "Reversed Nothing close to PosInf"
    Assert.IsFalse IsClose(0, NegInf, absTol:=PosInf), "Reversed Nothing close to NegInf"
    
    Assert.IsTrue IsClose(IEEE754.GetIEEE754SpecialValue(abDoubleMin), _
                          IEEE754.GetIEEE754SpecialValue(abDoubleMax), _
                          absTol:=PosInf), "Reverse Finite a, b with infinite diff still close when infinite tolerance"
                          
    Assert.IsTrue IsClose(IEEE754.GetIEEE754SpecialValue(abDoubleMin), _
                          IEEE754.GetIEEE754SpecialValue(abDoubleMin), _
                          relTol:=1.1), "Reverse Overflowing infinite relTol always close for finite a, b"
TestExit:
    Exit Sub
TestFail:
    Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description
    Resume TestExit
End Sub

'@TestMethod("Bad Inputs")
Private Sub IsCloseNaNraisesOverflowErr()
    Const ExpectedError As Long = 6
    On Error GoTo TestFail

    '@Ignore FunctionReturnValueDiscarded: Just testing error raising
    IsClose NaN, 0

Assert:
    Assert.Fail "Expected error was not raised"

TestExit:
    Exit Sub
TestFail:
    If Err.Number = ExpectedError Then
        Resume TestExit
    Else
        Resume Assert
    End If
End Sub

'@TestMethod("Bad Inputs")
Private Sub NegativeTolRaisesArgError()
    Const ExpectedError As Long = 5
    On Error GoTo TestFail

    '@Ignore FunctionReturnValueDiscarded: Just testing error raising
    IsClose 1, 1, -1

Assert:
    Assert.Fail "Expected error was not raised"

TestExit:
    Exit Sub
TestFail:
    If Err.Number = ExpectedError Then
        Resume TestExit
    Else
        Resume Assert
    End If
End Sub

… which uses a modified version of the GetIEEE754SpecialValue function given in this answer – link to modified version not for review. This was retrospective test driven development as I already had most of the code written from python, however a few additions were made to make it more VBA-idiomatic (e.g. throw error on NaN, python does not).

Segunda requisição de pagina com Curl e php retornando “Connection: close Cache-Control: no-cache Pragma: no-cache “

Estou criando um sistema cujo objetivo é acessar uma página com um arquivo JSON protegida por usuário e senha. Até aí ok! Eu faço a requisição da página de login, dou um post no usuário e senha, salvo todos cookies e acesso a outra pagina que já é o arquivo.

Porém consigo acessar esse arquivo uma única vez. Na segunda vez já é informado o erro "Connection: close Cache-Control: no-cache Pragma: no-cache " Já tentei um monte de manipulação com cache, mas simplesmente não dá! Detalhe só acesso uma vez por dia (imagino que quando o login expira, volto a acessar, mas sempre uma única vez por sessão).

Eu acessando no meu navegador não ocorre isso… Somente quando tento acessar via CURL.

Segue meu código de acesso a esse arquivo.

<?php
    $cookie="files/cookies.txt";
    $url = "https://site.com/arquivo.json=";
    
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt ($curl, CURLOPT_COOKIEJAR, $cookie); 
    curl_setopt ($curl, CURLOPT_COOKIEFILE, $cookie);  
    curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    
    $headers = array(
       "Connection: keep-alive",
       Connection: keep-alive",
       "Pragma: no-cache",
       "Cache-Control: no-cache",
       "sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"",
       "sec-ch-ua-mobile: ?0",
       "Upgrade-Insecure-Requests: 1",
       "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
       "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
       "Sec-Fetch-Site: none",
       "Sec-Fetch-Mode: navigate",
       "Sec-Fetch-User: ?1",
       "Sec-Fetch-Dest: document",
       "Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
    );
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    $resp = curl_exec($curl);
    curl_close($curl);
    var_dump($resp);

windows – When does task scheduler close and not close processes?

Is it a rule that when a process exits with a non zero exit code that task scheduler won’t close the process at it’s completion?

I hadn’t seen this documented or discussed anywhere but just seems to be what I have observed, or maybe there is some other rule that governs when a process is closed.

And do any of the task settings like “Stop the task if it runs longer than” affect this behavior? I.e. does such a suspended process get stopped eventually?