问:
PHP MVC View doesn't load any CSS or JS when specifying controller method
I am a newbie when it comes to MVC in PHP and I have encountered a problem with using my controllers. When I try to load a page (e.g. SignUp). When I specify my URL as localhost/MyProject/public/signup, everything works just fine. But when I try to specify the method I want to use as localhost/MyProject/public/signup/index (while the default method in App.php is index too), it breaks. Both css and js doesn't load into the page and all I see is just html document. Any ideas why that happens? The only solution I could come up with is to use absolute paths like> https://localhost/MyProject/public/css/styles.css but it just seems like there should be an easier or more elegant solution. I tried both my original css/styles.css and /css/styles.css but neither of them fixed my problem. So my final question is, whether there is an elegant alternative or using the absolute path is my only solution.

My App.php class:

```<code>class App
{

    protected $controller = 'signin';
    protected $method = 'index';
    protected $params = [];

    public function __construct() {
        $url = $this->parseUrl();

        if (isset($url[0]) && file_exists('../app/controllers/' . $url[0] . '.php')) {
            $this->controller = $url[0];
            unset($url[0]);
        }

        require_once '../app/controllers/' . $this->controller . '.php';

        $this->controller = new $this->controller;

        if (isset($url[1]) && method_exists($this->controller, $url[1])) {
            $this->method = $url[1];
            unset($url[1]);
        }

        $this->params = $url ? array_values($url) : [];

        call_user_func_array([$this->controller, $this->method], $this->params);
    }

    public function parseUrl() {
        if (isset($_GET['url'])) {
            return explode('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL));
        } else {
            return [];
        }
    }
}
</code>```

My SignUp.php controller:

```<code>class SignUp extends Controller
{
    public function index()
    {
        $this->view('signup');
    }
}
</code>```

My signup.php view:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <title>Habit Journal</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/signInUp.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Mukta&display=swap" rel="stylesheet">
</head>
<body>
<div class="page-container">
    <main class="login-container">
        <div class="login-top">
            <img src="img/logoZwa2.png" alt="Logo">
            Habit Journal
        </div>
        <div class="login-text">
            Sign up to use Habit Journal.
        </div>
        <form method="post">
            <label for="email">E-mail</label>
            <input id="email" name="email" type="email" required>
            <label for="password">Password</label>
            <input id="password" name="password" type="password" required>
            <label for="password_check">Retype password</label>
            <input id="password_check" name="password" type="password" required>
            <input id="submit" type="submit" value="Sign Up" disabled>
        </form>
    </main>
    <div class="login-redirect">
        <a href="signin">Login</a>
    </div>
    <script>
        document.getElementById("submit").disabled = true;
    </script>
    <script src="js/signInUpValidation.js"></script>
</div>
</body>
</html>
</code>```

My file structure
.htacces file:

```<code>Options -MultiViews
RewriteEngine On

RewriteBase /MyProject/public/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</code>```

I tried to relocate both JS and CSS files to various locations without any change, look into the console and other developer tools in browser but I just found out, that both JS and CSS didn't even load, when I specified the method.

Body:
I am a newbie when it comes to MVC in PHP and I have encountered a problem with using my controllers. When I try to load a page (e.g. SignUp). When I specify my URL as localhost/MyProject/public/signup, everything works just fine. But when I try to specify the method I want to use as localhost/MyProject/public/signup/index (while the default method in App.php is index too), it breaks. Both css and js doesn't load into the page and all I see is just html document. Any ideas why that happens? The only solution I could come up with is to use absolute paths like> https://localhost/MyProject/public/css/styles.css but it just seems like there should be an easier or more elegant solution. I tried both my original css/styles.css and /css/styles.css but neither of them fixed my problem. So my final question is, whether there is an elegant alternative or using the absolute path is my only solution.

My App.php class:

class App
{

    protected $controller = 'signin';
    protected $method = 'index';
    protected $params = [];

    public function __construct() {
        $url = $this->parseUrl();

        if (isset($url[0]) && file_exists('../app/controllers/' . $url[0] . '.php')) {
            $this->controller = $url[0];
            unset($url[0]);
        }

        require_once '../app/controllers/' . $this->controller . '.php';

        $this->controller = new $this->controller;

        if (isset($url[1]) && method_exists($this->controller, $url[1])) {
            $this->method = $url[1];
            unset($url[1]);
        }

        $this->params = $url ? array_values($url) : [];

        call_user_func_array([$this->controller, $this->method], $this->params);
    }

    public function parseUrl() {
        if (isset($_GET['url'])) {
            return explode('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL));
        } else {
            return [];
        }
    }
}

My SignUp.php controller:

class SignUp extends Controller
{
    public function index()
    {
        $this->view('signup');
    }
}

My signup.php view:

<!DOCTYPE html>

    <title>Habit Journal</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/signInUp.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Mukta&display=swap" rel="stylesheet">

            Habit Journal

            Sign up to use Habit Journal.

        <form method="post">
            E-mail
            <input id="email" name="email" type="email" required>
            Password
            <input id="password" name="password" type="password" required>
            Retype password
            <input id="password_check" name="password" type="password" required>
            <input id="submit" type="submit" value="Sign Up" disabled>
        </form>

        Login

My file structure
.htacces file:

Options -MultiViews
RewriteEngine On

RewriteBase /MyProject/public/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

I tried to relocate both JS and CSS files to various locations without any change, look into the console and other developer tools in browser but I just found out, that both JS and CSS didn't even load, when I specified the method.


来源: stackexchange

问:
How to replace / for \/ in R?
I need a code to parse a html file to json in R for a REST call. Since i was unable to find any parser that worked for my ends, i was doing it myself.
For some reason i am unable to transform "/" into "\/"

```<code>s = "https://test.app.net/pixel"
</code>```

to

```<code>"https:\/\/test.app.net\/pixel"
</code>```

Some attempts were

```<code>s = gsub("/","\\/",s)
s = gsub("/","\\\\/",s)
s = gsub("/","\/",s,fixed = TRUE)

</code>```

The results showed exactly the same string or double backslash instead of a single one.

Edit:
After reading @MrFlick response i was able to solve my issue

```<code>html = gsub("/","sa\\\\/",html)
html = gsub("sa\\\\",'\\\\',html)
</code>```

was enough to create the desired effect since R would interpret it twice, but it was only visible using cat().
after a lot of hours doing the html to json parse i learnt that toJson(), if properly used could do exactly what i needed from the beginning...

ContentLicense: CC BY-SA 4.0

Title: How to replace / for \/ in R?

Body:
I need a code to parse a html file to json in R for a REST call. Since i was unable to find any parser that worked for my ends, i was doing it myself.
For some reason i am unable to transform "/" into "\/"

s = "https://test.app.net/pixel"

to

"https:\/\/test.app.net\/pixel"

Some attempts were

s = gsub("/","\\/",s)
s = gsub("/","\\\\/",s)
s = gsub("/","\/",s,fixed = TRUE)

The results showed exactly the same string or double backslash instead of a single one.

Edit:
After reading @MrFlick response i was able to solve my issue

html = gsub("/","sa\\\\/",html)
html = gsub("sa\\\\",'\\\\',html)

was enough to create the desired effect since R would interpret it twice, but it was only visible using cat().
after a lot of hours doing the html to json parse i learnt that toJson(), if properly used could do exactly what i needed from the beginning...


问:
Why the finally section is not executed in this official C# code?
This example took from the official documentation does not behave as it says (does not execute the finally) because it just prints:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Int32'.
at ThrowTestA.Main() in C:\repos\Sandbox\Console\Console\Program.cs:line 14

```<code>using System;

public class ThrowTestA
{
    public static void Main()
    {
        int i = 123;
        string s = "Some string";
        object obj = s;

        try
        {
            // Invalid conversion; obj contains a string, not a numeric type.
            i = (int)obj;

            // The following statement is not run.
            Console.WriteLine("WriteLine at the end of the try block.");
        }
        finally
        {
            // To run the program in Visual Studio, type CTRL+F5. Then
            // click Cancel in the error dialog.
            Console.WriteLine("\nExecution of the finally block after an unhandled\n" +
                "error depends on how the exception unwind operation is triggered.");
            Console.WriteLine("i = {0}", i);
        }
    }
    // Output:
    // Unhandled Exception: System.InvalidCastException: Specified cast is not valid.
    //
    // Execution of the finally block after an unhandled
    // error depends on how the exception unwind operation is triggered.
    // i = 123
}
</code>```

This is my Program project:

```<code>  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

</Project>
</code>```

Body:
This example took from the official documentation does not behave as it says (does not execute the finally) because it just prints:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Int32'.
at ThrowTestA.Main() in C:\repos\Sandbox\Console\Console\Program.cs:line 14

using System;

public class ThrowTestA
{
    public static void Main()
    {
        int i = 123;
        string s = "Some string";
        object obj = s;

        try
        {
            // Invalid conversion; obj contains a string, not a numeric type.
            i = (int)obj;

            // The following statement is not run.
            Console.WriteLine("WriteLine at the end of the try block.");
        }
        finally
        {
            // To run the program in Visual Studio, type CTRL+F5. Then
            // click Cancel in the error dialog.
            Console.WriteLine("\nExecution of the finally block after an unhandled\n" +
                "error depends on how the exception unwind operation is triggered.");
            Console.WriteLine("i = {0}", i);
        }
    }
    // Output:
    // Unhandled Exception: System.InvalidCastException: Specified cast is not valid.
    //
    // Execution of the finally block after an unhandled
    // error depends on how the exception unwind operation is triggered.
    // i = 123
}

This is my Program project:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

</Project>


问:
How to return an image as a response in Django
Doing a POST request to GPT-3 in order to get code completion output when I send some input.

I seem to be getting the response I expect, but cannot actually get the code written by GPT-3. This is the response I get:

```<code>".\n\n## Challenge\n\nWrite a function called `preOrder` which takes a binary tree as its only input. Without utilizing
any of the built-in methods available to your language, return an array of the values, ordered from left to right as
they would be if the tree were represented by a pre-order traversal.\n\n## Approach & Efficiency\n\nI used a recursive
approach to solve this problem. I created a function called `preOrder` that takes in a binary tree as its only input. I
then created a variable called `output` that is an empty array. I then created a function called `_walk` that takes in a
node as its only input. I then created a base case that checks if the node is null. If it is, it returns. If it is not,
it pushes the value of the node into the `output` array. It then recursively calls the `_walk` function on the left and
right nodes of the node. It then returns the `output` array.\n\n## Solution\n\n![Whiteboard](./assets/pre-order.jpg)"
</code>```

I assume the actual code written falls under the Solution header, but cannot for the life of me figure out how to get and view this image ie. if I just return the image link, nothing opens.

UPDATE
I assume this response is markdown and used a markdown parser to return the response as markdown and this is what I get:

```<code><p>.</p>
<h2>Challenge</h2>
<p>Write a function called <code>preOrder</code> which takes a binary tree as its only input. Without utilizing any of
    the built-in methods available to your language, return an array of the values, ordered from left to right as they
    would be if you traversed the tree using a pre-order traversal.</p>
<h2>Solution</h2>
<p><img alt="" src="./assets/pre-order.jpg" /></p>
</code>```

Body:
Doing a POST request to GPT-3 in order to get code completion output when I send some input.

I seem to be getting the response I expect, but cannot actually get the code written by GPT-3. This is the response I get:

".\n\n## Challenge\n\nWrite a function called `preOrder` which takes a binary tree as its only input. Without utilizing
any of the built-in methods available to your language, return an array of the values, ordered from left to right as
they would be if the tree were represented by a pre-order traversal.\n\n## Approach & Efficiency\n\nI used a recursive
approach to solve this problem. I created a function called `preOrder` that takes in a binary tree as its only input. I
then created a variable called `output` that is an empty array. I then created a function called `_walk` that takes in a
node as its only input. I then created a base case that checks if the node is null. If it is, it returns. If it is not,
it pushes the value of the node into the `output` array. It then recursively calls the `_walk` function on the left and
right nodes of the node. It then returns the `output` array.\n\n## Solution\n\n![Whiteboard](./assets/pre-order.jpg)"

I assume the actual code written falls under the Solution header, but cannot for the life of me figure out how to get and view this image ie. if I just return the image link, nothing opens.

UPDATE
I assume this response is markdown and used a markdown parser to return the response as markdown and this is what I get:

.

Challenge

Write a function called preOrder which takes a binary tree as its only input. Without utilizing any of
    the built-in methods available to your language, return an array of the values, ordered from left to right as they
    would be if you traversed the tree using a pre-order traversal.

Solution


问:
Problem with getting users from firebase realtime database on unity engine
I am trying to get all the users from firebase realtime database on the unity engine (c#)
but for some reason the foreach will only return the first one 8 times and he won't go to another what I am doing wrong?

I checked with ChildrenCount and it does have 8 children (All of the users)

private IEnumerator InitPlayerList()
{
    var task = db.Child("Users").Child(gm.currentLobbyInfo.pinCode.ToString()).OrderByChild("score").GetValueAsync();

    yield return new WaitUntil(predicate: () => task.IsCompleted);

    if (task.Exception != null)
    {
        Debug.Log("Something wrong");
        yield break;
    }
    else
    {
        DataSnapshot data = task.Result;
        foreach (Transform child in playersLeaderboardPerant)
        {
            Destroy(child.gameObject);
        }

        foreach (DataSnapshot childSnap in data.Children) // Won't move to the other users
        {
            Debug.Log(childSnap.Child("username").Value.ToString());
            PlayerLeaderBoard instance = Instantiate<PlayerLeaderBoard>(playerLeaderBoardPrefab, playersLeaderboardPerant);
            instance.SetupPlayerLeaderboardInstance(childSnap.Child("username").Value.ToString(), 0, "test");
        }
    }
}
```

with the childSnap.key it does get all the keys of te different users

Body:
I am trying to get all the users from firebase realtime database on the unity engine (c#)
but for some reason the foreach will only return the first one 8 times and he won't go to another what I am doing wrong?

I checked with ChildrenCount and it does have 8 children (All of the users)

private IEnumerator InitPlayerList()
{
    var task = db.Child("Users").Child(gm.currentLobbyInfo.pinCode.ToString()).OrderByChild("score").GetValueAsync();

    yield return new WaitUntil(predicate: () => task.IsCompleted);

    if (task.Exception != null)
    {
        Debug.Log("Something wrong");
        yield break;
    }
    else
    {
        DataSnapshot data = task.Result;
        foreach (Transform child in playersLeaderboardPerant)
        {
            Destroy(child.gameObject);
        }

        foreach (DataSnapshot childSnap in data.Children) // Won't move to the other users
        {
            Debug.Log(childSnap.Child("username").Value.ToString());
            PlayerLeaderBoard instance = Instantiate<PlayerLeaderBoard>(playerLeaderBoardPrefab, playersLeaderboardPerant);
            instance.SetupPlayerLeaderboardInstance(childSnap.Child("username").Value.ToString(), 0, "test");
        }
    }
}

with the childSnap.key it does get all the keys of te different users


问:
make 2nd column within array after some rows in React.js
I have more then 50 rows in my JSON array. I want to display 25 in one column and others in Second Colum. At the moment all displaying in one column. please check my code and help with thanks

```<code> <Row>
   <Col md="6">
    <Table>

   formsList.map((item, index) => {

    return(
     <tr>
      <td>
          <div className="custom-control custom-control-alternative custom-checkbox mb-3">
            <input
              className="custom-control-input"
              id= {item.id}
              name= {item.checkBoxfieldName}
              type="checkbox"
              value={item.id}
            />
            <label className="custom-control-label" htmlFor={item.id}>
               {item.form_title}
            </label>
          </div>
       </td>
      </tr>
      )
    })}

    </Table>
    </Col>
 </Row>
</code>```

I want to display my extra rows in 2nd < Col md="6" > after 25 rows. please help with thanks

Body:
I have more then 50 rows in my JSON array. I want to display 25 in one column and others in Second Colum. At the moment all displaying in one column. please check my code and help with thanks

 <Row>
   <Col md="6">

   formsList.map((item, index) => {

    return(

            <input
              className="custom-control-input"
              id= {item.id}
              name= {item.checkBoxfieldName}
              type="checkbox"
              value={item.id}
            />

               {item.form_title}

      )
    })}

    </Col>
 </Row>

I want to display my extra rows in 2nd < Col md="6" > after 25 rows. please help with thanks


问:
Should I write my own back-end code to use npm packages on website?
I use npm packages on node and it works well. But I am building website and I want to use those packages on it. How it works, should i write backend to be able to use npm installed packages on website? For example I got package for summing 2 numbers, I want to input my numbers on website through input fields and than use my package to calculate it and than result will display on website.

I saw some "hacks" how to use npm installed packages on website but I want to know right way to use it


问:
generateLexer/generateParser gradle tasks problem in intellij idea plugin build
I try to extend some old IntelliJ plug-in

And there is my build.gradle

```<code>    buildscript {
    ext.kotlin_version = '1.6.0'

    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io'}
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
        maven {
            url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "org.jetbrains.intellij" version "0.5.0"
    id "org.jetbrains.grammarkit" version "2022.3"

}

group 'com.interfaced'
version '0.2.7'

apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'

sourceSets {
    all {
        java.srcDirs += ['src/main/gen']
        kotlin.srcDirs += ['src/main/kotlin']
        resources.srcDirs = ['src/main/resources']
    }
}

grammarKit {
    jflexRelease = '1.7.0-2'
}

repositories {
    mavenCentral()
    maven {
        url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/"
    }
}

dependencies {
    // https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
    implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.7.22'

    implementation group: 'junit', name: 'junit', version: '4.12'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"

}

intellij {

    pluginName 'BrightScript'

    version '2022.3'

}

patchPluginXml {
    changeNotes """
      <ul>
        <li>Support for 2020.2</li>
      </ul>
      """
}

import org.jetbrains.grammarkit.tasks.*

def GENERATE_GROUP = 'Generate'

task generateLexer(type: GenerateLexer) {
    source = "src/main/grammar/BrightScript.flex"
    targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
    targetClass = "_BrsLexer"
    skeleton = "src/main/grammar/idea-flex.skeleton"
    purgeOldFiles = true

    description = 'Generate Lexer Java sources for BrightScript'
    group = GENERATE_GROUP
}

task generateParser(type: GenerateParser) {
    source = "src/main/grammar/BrightScript.bnf"
    targetRoot = 'src/main/gen'
    pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
    pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
    purgeOldFiles = true

    description = 'Generate Parser Java sources for BrightScript'
    group = GENERATE_GROUP

    // patch up to date check
    outputs.upToDateWhen { false }
}

compileKotlin {
    kotlinOptions.jvmTarget = "17"
}

compileKotlin.dependsOn(generateLexer, generateParser)
</code>```

When I try to run it have the following output

org.gradle.api.GradleScriptException: A problem occurred evaluating
root project 'brs-plugin'.    at  ... Caused by:
groovy.lang.MissingPropertyException: Could not get unknown property
'GenerateLexer' for root project 'brs-plugin' of type
org.gradle.api.Project.

But when I try to change my buildLexer/buildParser tasks as following

```<code>generateLexer {
    source = "src/main/grammar/BrightScript.flex"
    targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
    targetClass = "_BrsLexer"
    skeleton = "src/main/grammar/idea-flex.skeleton"
    purgeOldFiles = true

    description = 'Generate Lexer Java sources for BrightScript'
    group = GENERATE_GROUP
}

generateParser {
    source = "src/main/grammar/BrightScript.bnf"
    targetRoot = 'src/main/gen'
    pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
    pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
    purgeOldFiles = true

    description = 'Generate Parser Java sources for BrightScript'
    group = GENERATE_GROUP

    // patch up to date check
    outputs.upToDateWhen { false }
}
</code>```

have another one problem

A problem occurred evaluating root project 'brs-plugin'. ... Caused
by: java.lang.IllegalArgumentException: Cannot set the value of task
':generateLexer' property 'skeleton' of type
org.gradle.api.file.RegularFile

How to fix my problem?
Regards

Body:
I try to extend some old IntelliJ plug-in

And there is my build.gradle

    buildscript {
    ext.kotlin_version = '1.6.0'

    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io'}
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
        maven {
            url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "org.jetbrains.intellij" version "0.5.0"
    id "org.jetbrains.grammarkit" version "2022.3"

}

group 'com.interfaced'
version '0.2.7'

apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'

sourceSets {
    all {
        java.srcDirs += ['src/main/gen']
        kotlin.srcDirs += ['src/main/kotlin']
        resources.srcDirs = ['src/main/resources']
    }
}

grammarKit {
    jflexRelease = '1.7.0-2'
}

repositories {
    mavenCentral()
    maven {
        url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/"
    }
}

dependencies {
    // https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
    implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.7.22'

    implementation group: 'junit', name: 'junit', version: '4.12'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"

}

intellij {

    pluginName 'BrightScript'

    version '2022.3'

}

patchPluginXml {
    changeNotes """

Support for 2020.2

      """
}

import org.jetbrains.grammarkit.tasks.*

def GENERATE_GROUP = 'Generate'

task generateLexer(type: GenerateLexer) {
    source = "src/main/grammar/BrightScript.flex"
    targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
    targetClass = "_BrsLexer"
    skeleton = "src/main/grammar/idea-flex.skeleton"
    purgeOldFiles = true

    description = 'Generate Lexer Java sources for BrightScript'
    group = GENERATE_GROUP
}

task generateParser(type: GenerateParser) {
    source = "src/main/grammar/BrightScript.bnf"
    targetRoot = 'src/main/gen'
    pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
    pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
    purgeOldFiles = true

    description = 'Generate Parser Java sources for BrightScript'
    group = GENERATE_GROUP

    // patch up to date check
    outputs.upToDateWhen { false }
}

compileKotlin {
    kotlinOptions.jvmTarget = "17"
}

compileKotlin.dependsOn(generateLexer, generateParser)

When I try to run it have the following output

org.gradle.api.GradleScriptException: A problem occurred evaluating
root project 'brs-plugin'.    at  ... Caused by:
groovy.lang.MissingPropertyException: Could not get unknown property
'GenerateLexer' for root project 'brs-plugin' of type
org.gradle.api.Project.

But when I try to change my buildLexer/buildParser tasks as following

generateLexer {
    source = "src/main/grammar/BrightScript.flex"
    targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
    targetClass = "_BrsLexer"
    skeleton = "src/main/grammar/idea-flex.skeleton"
    purgeOldFiles = true

    description = 'Generate Lexer Java sources for BrightScript'
    group = GENERATE_GROUP
}

generateParser {
    source = "src/main/grammar/BrightScript.bnf"
    targetRoot = 'src/main/gen'
    pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
    pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
    purgeOldFiles = true

    description = 'Generate Parser Java sources for BrightScript'
    group = GENERATE_GROUP

    // patch up to date check
    outputs.upToDateWhen { false }
}

have another one problem

A problem occurred evaluating root project 'brs-plugin'. ... Caused
by: java.lang.IllegalArgumentException: Cannot set the value of task
':generateLexer' property 'skeleton' of type
org.gradle.api.file.RegularFile

How to fix my problem?
Regards


问:
It is possible to return an error when using pipe?
How can I return an error from my php file?
For example, write what can not be sent from the current domain?
Now it always gives 250 Ok
Even if pipe ended with error 550

my master.cf

```<code>submission inet n - - - - smtpd
  -o syslog_name=postfix/submission
  -o content_filter=webhook:dummy
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtp_send_xforward_command=yes
  -o smtpd_recipient_restrictions=reject_unverified_recipient,reject_unknown_recipient_domain,reject_non_fqdn_recipient,permit_sasl_authenticated,reject

webhook unix - n n - - pipe
  flags=Rq user=www-data argv=/usr/bin/php8.1 -f /home/test/www/artisan mail:send ${sasl_username}
</code>```

commands:

```<code>public function handle()
    {
        ...
            fputs(STDERR, "550 From domain " . $domain . " is not confirmed.");
            exit(0);
        ...
    }
</code>```

enter image description here

now always returns 250, although the script works.

Body:
How can I return an error from my php file?
For example, write what can not be sent from the current domain?
Now it always gives 250 Ok
Even if pipe ended with error 550

my master.cf

submission inet n - - - - smtpd
  -o syslog_name=postfix/submission
  -o content_filter=webhook:dummy
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtp_send_xforward_command=yes
  -o smtpd_recipient_restrictions=reject_unverified_recipient,reject_unknown_recipient_domain,reject_non_fqdn_recipient,permit_sasl_authenticated,reject

webhook unix - n n - - pipe
  flags=Rq user=www-data argv=/usr/bin/php8.1 -f /home/test/www/artisan mail:send ${sasl_username}

commands:

public function handle()
    {
        ...
            fputs(STDERR, "550 From domain " . $domain . " is not confirmed.");
            exit(0);
        ...
    }

enter image description here

now always returns 250, although the script works.


问:
Why autofocus not working on opened modal that created by flowbite modal?
I am trying to use autofocus functionality in my input area. I have a modal open when I click on a button. Inside modal component I have a input area that created using react-hook-forms for validation. I tried to use useRef to check if my modal rendered, after render completed, I am trying to use autofocus using setFocus from react-hook-forms but it is not working.

Here my some part of my code

export const FileListContextModal = <InputName extends string>({
  inputProps: { defaultValue, ...inputProps },
  title,
  onClose,
  onSubmit,
  cancelLabel,
  saveLabel,
  ...modalProps
}: FileListContextModalProps<InputName>) => {
  const { handleSubmit, control, setError, setFocus } = useForm<
    Record<string, string>
  >({
    defaultValues: { [inputProps.name]: defaultValue || '' },
  });

  const inputRef = useRef<HTMLInputElement>(null);

  useEffect(() => {
    if (inputRef.current) {
      setFocus(inputProps.name);
    }
  }, [inputRef]);

  return (
    <Modal {...modalProps} onClose={onClose} onClick={preventPropagation}>
      <Modal.Header>{title}</Modal.Header>
      <form onSubmit={handleSubmit(onSubmitHandler)}>
        <Modal.Body>
          <FormTextInput control={control} {...inputProps} ref={inputRef} />
        </Modal.Body>
        <Modal.Footer>
          <Button type="button" color="light" onClick={onClose}>
            {cancelLabel}
          </Button>
          <Button type="submit">{saveLabel}</Button>
        </Modal.Footer>
      </form>
    </Modal>
  );
};

```
<p>as you see it is not focusing in my input area
<img src="https://i.stack.imgur.com/joHLl.png" alt="enter image description here" /></p>
<p>I used <strong>setTimeOut</strong> inside <strong>useEffect</strong> but I dont know how much it is right to give time and focus on the input area after a while. Here the working code snippet</p>
<pre class="lang-js prettyprint-override"><code>useEffect(() => {
    setTimeout(() => {
   setFocus(inputProps.name);
    }, 5);
  }, [setFocus, inputProps.name]);
</code>```

Is there any other solution other than using setTimeOut here ??

Body:
I am trying to use autofocus functionality in my input area. I have a modal open when I click on a button. Inside modal component I have a input area that created using react-hook-forms for validation. I tried to use useRef to check if my modal rendered, after render completed, I am trying to use autofocus using setFocus from react-hook-forms but it is not working.

Here my some part of my code

export const FileListContextModal = <InputName extends string>({
  inputProps: { defaultValue, ...inputProps },
  title,
  onClose,
  onSubmit,
  cancelLabel,
  saveLabel,
  ...modalProps
}: FileListContextModalProps<InputName>) => {
  const { handleSubmit, control, setError, setFocus } = useForm<
    Record<string, string>
  >({
    defaultValues: { [inputProps.name]: defaultValue || '' },
  });

  const inputRef = useRef<HTMLInputElement>(null);

  useEffect(() => {
    if (inputRef.current) {
      setFocus(inputProps.name);
    }
  }, [inputRef]);

  return (
    <Modal {...modalProps} onClose={onClose} onClick={preventPropagation}>
      <Modal.Header>{title}</Modal.Header>
      <form onSubmit={handleSubmit(onSubmitHandler)}>
        <Modal.Body>
          <FormTextInput control={control} {...inputProps} ref={inputRef} />
        </Modal.Body>
        <Modal.Footer>
          <Button type="button" color="light" onClick={onClose}>
            {cancelLabel}
          </Button>
          <Button type="submit">{saveLabel}</Button>
        </Modal.Footer>
      </form>
    </Modal>
  );
};

as you see it is not focusing in my input area

I used setTimeOut inside useEffect but I dont know how much it is right to give time and focus on the input area after a while. Here the working code snippet

useEffect(() => {
    setTimeout(() => {
   setFocus(inputProps.name);
    }, 5);
  }, [setFocus, inputProps.name]);

Is there any other solution other than using setTimeOut here ??


问:
cakephp: login form not redirecting
When I click the login button on the login form, nothing happens. It is not redirecting to /merry_parents/report_card. I have specified $this->Auth->loginRedirect in beforeFilter. Does anyone know on what i'm doing wrong? thanks in advance.

Following is my merry_parents controller, login view and report_card view

app_controller.php

```<code>   class AppController extends Controller {

var $components=array('Auth','Session');

function beforeFilter(){
  if (isset($this->Auth)){
        $this->Auth->userModel='MerryParent';
        $this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'login');
        $this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card');
        $this->Auth->allow('signup','login','logout');
        $this->Auth->authorize='controller';
        //$this->Auth->actionPath='controllers/';
      }
   else
        $this->Session->setFlash('Auth has not been set');

}

function isAuthorized(){
    return true;
}
   }
</code>```

merry_parents_controller.php

```<code>    class MerryParentsController extends AppController{

var $name='MerryParents';
var $components=array('Acl','Auth','Session');

function report_card(){
}

function register(){

}

function login(){

}

function logout(){
$this->redirect($this->Auth->logout());
}

function signup(){
        print_r($this->data);

    if (!empty($this->data)){
        //$this->Auth->password($this->data['MerryParent']['password2'] used to get what the hashed password2 would look like.
        $this->MerryParent->set($this->data);
         //validates calls invalidFields methods which in turn populates validationErrors arrays. Validates is used to validate a record prior to updating. Needed only when you want to update certain fields in an existing record.
         if ($this->MerryParent->validates(array('fieldList'=>array('username','email','password','password2')))){

             if ($this->data['MerryParent']['password']==$this->Auth->password($this->data['MerryParent']['password2'])){

                     $this->MerryParent->id=$this->MerryParent->field('id',
                                                    array('MerryParent.username'=>$this->data['MerryParent']['username'],
                                                    'MerryParent.email'=>$this->data['MerryParent']['email'])
                                                    );
                    echo $this->MerryParent->id;

                    //die(debug($this->MerryParent->validationErrors));
                    if ($this->MerryParent->save($this->data,false))//record with $this->MerryParent->id is updated
                        {
                                                    $this->Auth->login($this->data); //automatically logs a user in after registration

                        $this->redirect('/merry_parents/report_card');
                        }
                    else
                        echo $this->Session->setFlash(__('Your admission could not be saved, please try again!',true));

                }//end if ($this->data['MerryParent']['password']....
                else
                    echo $this->Session->setFlash('Typed passwords did not match');
            }//if ($this->MerryParent->validates
    }//end if (!empty($this->data))
}
 }
 ?>
</code>```

login.ctp

```<code>  <?php
       echo $this->Form->create('MerryParent',array('action'=>'login'));
      echo $this->Form->input('username',array('label'=>'Name'));
      echo $this->Form->input('password', array('value'=>''));
      echo $this->Form->end('Login');
   ?>
</code>```

report_card.ctp

```<code> <?php
 echo 'HALLO';

 ?>
</code>```

ContentLicense: CC BY-SA 3.0

Title: cakephp: login form not redirecting

Body:
When I click the login button on the login form, nothing happens. It is not redirecting to /merry_parents/report_card. I have specified $this->Auth->loginRedirect in beforeFilter. Does anyone know on what i'm doing wrong? thanks in advance.

Following is my merry_parents controller, login view and report_card view

app_controller.php

   class AppController extends Controller {

var $components=array('Auth','Session');

function beforeFilter(){
  if (isset($this->Auth)){
        $this->Auth->userModel='MerryParent';
        $this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'login');
        $this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card');
        $this->Auth->allow('signup','login','logout');
        $this->Auth->authorize='controller';
        //$this->Auth->actionPath='controllers/';
      }
   else
        $this->Session->setFlash('Auth has not been set');

}

function isAuthorized(){
    return true;
}
   }

merry_parents_controller.php

    class MerryParentsController extends AppController{

var $name='MerryParents';
var $components=array('Acl','Auth','Session');

function report_card(){
}

function register(){

}

function login(){

}

function logout(){
$this->redirect($this->Auth->logout());
}

function signup(){
        print_r($this->data);

    if (!empty($this->data)){
        //$this->Auth->password($this->data['MerryParent']['password2'] used to get what the hashed password2 would look like.
        $this->MerryParent->set($this->data);
         //validates calls invalidFields methods which in turn populates validationErrors arrays. Validates is used to validate a record prior to updating. Needed only when you want to update certain fields in an existing record.
         if ($this->MerryParent->validates(array('fieldList'=>array('username','email','password','password2')))){

             if ($this->data['MerryParent']['password']==$this->Auth->password($this->data['MerryParent']['password2'])){

                     $this->MerryParent->id=$this->MerryParent->field('id',
                                                    array('MerryParent.username'=>$this->data['MerryParent']['username'],
                                                    'MerryParent.email'=>$this->data['MerryParent']['email'])
                                                    );
                    echo $this->MerryParent->id;

                    //die(debug($this->MerryParent->validationErrors));
                    if ($this->MerryParent->save($this->data,false))//record with $this->MerryParent->id is updated
                        {
                                                    $this->Auth->login($this->data); //automatically logs a user in after registration

                        $this->redirect('/merry_parents/report_card');
                        }
                    else
                        echo $this->Session->setFlash(__('Your admission could not be saved, please try again!',true));

                }//end if ($this->data['MerryParent']['password']....
                else
                    echo $this->Session->setFlash('Typed passwords did not match');
            }//if ($this->MerryParent->validates
    }//end if (!empty($this->data))
}
 }
 ?>

login.ctp

  <?php
       echo $this->Form->create('MerryParent',array('action'=>'login'));
      echo $this->Form->input('username',array('label'=>'Name'));
      echo $this->Form->input('password', array('value'=>''));
      echo $this->Form->end('Login');
   ?>

report_card.ctp

 <?php
 echo 'HALLO';

 ?>


问:
Bug in derivative calculation GI type GAM
I have many hierarchical GAMs fitted with the brm() function of the brms package. Some of my GAMs have a 'I type' structure :

```<code>y ~ 1 + s(year, by = site, bs = "tp", m = 2) + s(level, bs = "tp") + (1|r|transect),
        zi ~ 1 + s(year, by = site, bs = "tp", m = 2) + s(level, bs = "tp") +(1|r|transect)
</code>```

Where year and level are continuous and site and level are categorical. I also have GAMs with the 'GI type' structure:

```<code>y ~ 1 + s(year,bs = "tp")+ s(year, by = site, bs="tp") + s(level, bs = "tp") + s(site, bs = "re") +(1|r|intertidal_transect),
        zi ~ 1 + s(year,bs = "tp")+ s(year, by = site, bs="tp") + s(level, bs = "tp") + s(site, bs = "re") +(1|r|intertidal_transect)
</code>```

I want to calculate the derivative of the splines with 95% confidence intervals. To do so, I extracted posterior predictions of 1000 draws with:

```<code>msms <- conditional_smooths(model, spaghetti = T)
</code>```

Extracting each draw as data a frame and making a data frame for each spline (each site and the global trend for the GS model) with something like that plus some data manipulation to have a draw per column and time in the first column:

```<code>f <- attributes(msms_count_4$mu_y: s(YEAR,by=SITE,m=1,bs="tp"))$spaghetti
f_SW <- filter(f, cond__ == "SITE_SW")
f_NW <- filter(f, cond__ == "SITE_NW")
</code>```

I get these draws for the site-specific posterior prediction of the GI modes:

```<code>structure(list(year = c(1982, 1982.38383838384, 1982.76767676768,
1983.15151515152, 1983.53535353535, 1983.91919191919, 1984.30303030303,
1984.68686868687, 1985.07070707071, 1985.45454545455, 1985.83838383838,
1986.22222222222, 1986.60606060606, 1986.9898989899, 1987.37373737374,
1987.75757575758, 1988.14141414141, 1988.52525252525, 1988.90909090909,
1989.29292929293, 1989.67676767677, 1990.06060606061, 1990.44444444444,
1990.82828282828, 1991.21212121212, 1991.59595959596, 1991.9797979798,
1992.36363636364, 1992.74747474747, 1993.13131313131, 1993.51515151515,
1993.89898989899, 1994.28282828283, 1994.66666666667, 1995.05050505051,
1995.43434343434, 1995.81818181818, 1996.20202020202, 1996.58585858586,
1996.9696969697, 1997.35353535354, 1997.73737373737, 1998.12121212121,
1998.50505050505, 1998.88888888889, 1999.27272727273, 1999.65656565657,
2000.0404040404, 2000.42424242424, 2000.80808080808, 2001.19191919192,
2001.57575757576, 2001.9595959596, 2002.34343434343, 2002.72727272727,
2003.11111111111, 2003.49494949495, 2003.87878787879, 2004.26262626263,
2004.64646464646, 2005.0303030303, 2005.41414141414, 2005.79797979798,
2006.18181818182, 2006.56565656566, 2006.94949494949, 2007.33333333333,
2007.71717171717, 2008.10101010101, 2008.48484848485, 2008.86868686869,
2009.25252525253, 2009.63636363636, 2010.0202020202, 2010.40404040404,
2010.78787878788, 2011.17171717172, 2011.55555555556, 2011.93939393939,
2012.32323232323, 2012.70707070707, 2013.09090909091, 2013.47474747475,
2013.85858585859, 2014.24242424242, 2014.62626262626, 2015.0101010101,
2015.39393939394, 2015.77777777778, 2016.16161616162, 2016.54545454545,
2016.92929292929, 2017.31313131313, 2017.69696969697, 2018.08080808081,
2018.46464646465, 2018.84848484848, 2019.23232323232, 2019.61616161616,
2020), `1` = c(0.0903901438415091, 0.102171563196727, 0.113952982551945,
0.129014020398404, 0.149103806598073, 0.169193592797743, 0.191117621275084,
0.213530781026471, 0.235097627348092, 0.252916514194966, 0.270735401041841,
0.282408024975746, 0.289610639518398, 0.296813254061055, 0.2902458944272,
0.283306373329117, 0.271128354990156, 0.249970055666827, 0.228811756343484,
0.199417802015595, 0.167467954755259, 0.134773132363749, 0.0981051092726421,
0.0614370861815133, 0.0261287888687987, -0.00807877805188554,
-0.0422863449725695, -0.0680311864152342, -0.0933058764424676,
-0.11409845247677, -0.1262715785247, -0.13844470457263, -0.140297494457864,
-0.138464449999272, -0.135109382021439, -0.121708958816611, -0.108308535611782,
-0.0914434142869732, -0.0714600646541677, -0.051476715021374,
-0.031052940336138, -0.0105914149321213, 0.00825495044447179,
0.0236018024283193, 0.0389486544121578, 0.0480260680379783, 0.0545492660364586,
0.0600291597020738, 0.0566409665383091, 0.0532527733745464, 0.0456414389225931,
0.0338069631824496, 0.0219724874423062, 0.00546466821953165,
-0.0115929561188369, -0.0290745116954201, -0.0475966257658035,
-0.0661187398361978, -0.0835478313887446, -0.100472451009983,
-0.117150683727973, -0.130954402574742, -0.144758121421519, -0.157185149748638,
-0.168082521942813, -0.178979894136988, -0.189877266331164, -0.200774638525346,
-0.211688584495069, -0.222648937036328, -0.233609289577587, -0.24520100413079,
-0.257121026930209, -0.269072787916266, -0.2815958362619, -0.294118884607533,
-0.306130253196955, -0.317509546793416, -0.32888884038987, -0.337055347879519,
-0.344619457974144, -0.350646697044373, -0.351721796147105, -0.352796895249835,
-0.348754056481851, -0.34172575395595, -0.33449119001513, -0.319624953722208,
-0.304758717429294, -0.287607586291897, -0.267314724743337, -0.247021863194777,
-0.22567487363744, -0.20408985517491, -0.183252248402289, -0.165217435466824,
-0.14718262253136, -0.133864392469005, -0.123622194715213, -0.113379996961422
), `2` = c(0.0281589447753082, 0.0360228847553418, 0.0438868247353754,
0.0542065220785714, 0.0682917140452664, 0.0823769060119616, 0.0990794558874814,
0.116479967872021, 0.133800230892946, 0.150765105646378, 0.167729980399809,
0.18214865686438, 0.194715552755233, 0.207282448646093, 0.212271721394666,
0.217056193517774, 0.218234485136086, 0.213230753031891, 0.208227020927692,
0.195733806596412, 0.18091627019466, 0.164887189511126, 0.142396539324755,
0.11990588913837, 0.0953530003646379, 0.06913068035352, 0.0429083603424022,
0.0177391720305717, -0.00737150896464664, -0.0305577749798716,
-0.050043242956679, -0.069528710933486, -0.0826863717986276,
-0.0935841015524644, -0.103275101184265, -0.105001682010679,
-0.106728262837092, -0.104648921431536, -0.0991442500172005,
-0.0936395786028685, -0.0850102188719535, -0.076113028713903,
-0.0675699556156343, -0.0597941361468887, -0.0520183166781475,
-0.0477026543788269, -0.0447966857411216, -0.0425926203390234,
-0.0463547324396034, -0.050116844540181, -0.0568723517603612,
-0.0666212541001435, -0.0763701564399258, -0.0889238481726288,
-0.101807515128021, -0.114445937172545, -0.12648239443585, -0.138518851699162,
-0.147442691700809, -0.154929939120153, -0.161889368679005, -0.162690923198772,
-0.163492477718539, -0.161194439863554, -0.155452410481069, -0.149710381098584,
-0.143968351716099, -0.138226322333611, -0.131983419557772, -0.124338071280545,
-0.116692723003317, -0.109620461991288, -0.102846206357157, -0.0962364745144016,
-0.0925881709163024, -0.0889398673182031, -0.0871389645791802,
-0.0876201452543117, -0.088101325929443, -0.0916514779767321,
-0.0957770621563005, -0.100373400438514, -0.106486613051482,
-0.112599825664444, -0.118637332497359, -0.124630677625246, -0.130575331305669,
-0.134718401429927, -0.138861471554181, -0.141911821692888, -0.143459681851466,
-0.145007542010045, -0.144765806376384, -0.144119968467057, -0.1432689308015,
-0.141648394050079, -0.140027857298658, -0.138648923662264, -0.137427557274803,
-0.136206190887341), `3` = c(-0.0539709293028476, -0.0537496486563462,
-0.0535283680098447, -0.0522786240455355, -0.0494519029939236,
-0.0466251819423118, -0.0391992632840588, -0.0305468919307008,
-0.0204744488785012, -0.00411311687432633, 0.012248215129849,
0.0323498353609559, 0.0551716652116509, 0.0779934950623591, 0.102357980235101,
0.126764158794924, 0.149058589751514, 0.167732881959705, 0.186407174167906,
0.195190131244194, 0.200903363624378, 0.20390162164128, 0.192420016387331,
0.180938411133375, 0.160428244631795, 0.132609242834518, 0.10479024103724,
0.0674567551735125, 0.0295946868616242, -0.00826605904612237,
-0.0461242618690254, -0.0839824646919283, -0.114022138115743,
-0.141269479611326, -0.16611936316185, -0.175146024275105, -0.184172685388359,
-0.182546736516697, -0.171333438658595, -0.1601201408005, -0.134141380135618,
-0.106897008373012, -0.0773884635227222, -0.0429742103157592,
-0.00855995710881638, 0.0236217573947781, 0.0548939190933054,
0.0849778245533993, 0.104961551986795, 0.124945279420179, 0.137628477017008,
0.143011144777282, 0.148393812537556, 0.142732296530229, 0.135771464785536,
0.127093455002492, 0.114200553670764, 0.101307652339029, 0.0895675478807852,
0.0783595035179952, 0.0677226764786005, 0.0637500515454905, 0.0597774266123786,
0.0598004232658113, 0.0642629994598431, 0.0687255756538748, 0.0731881518479065,
0.0776507280419409, 0.0824611632887457, 0.0882456038833142, 0.0940300444778826,
0.0973139227929918, 0.0992975087227821, 0.100846136701156, 0.0945655215540797,
0.0882849064070032, 0.0774710464544904, 0.0610572958599553, 0.0446435452654299,
0.0210351933610963, -0.00392214628882514, -0.0298341358608949,
-0.0588222196265737, -0.0878103033922348, -0.115712683511179,
-0.142981736502873, -0.170077615674274, -0.190766063494826, -0.211454511315367,
-0.228409357364048, -0.240230500976425, -0.252051644588802, -0.257338274195062,
-0.261149368380579, -0.263958087453723, -0.263007899855467, -0.262057712257211,
-0.260596000222232, -0.258800685293739, -0.257005370365246)), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"))
</code>```

And this is site-specific with the I model:

```<code>structure(list(year = c(1982, 1982.38383838384, 1982.76767676768,
1983.15151515152, 1983.53535353535, 1983.91919191919, 1984.30303030303,
1984.68686868687, 1985.07070707071, 1985.45454545455, 1985.83838383838,
1986.22222222222, 1986.60606060606, 1986.9898989899, 1987.37373737374,
1987.75757575758, 1988.14141414141, 1988.52525252525, 1988.90909090909,
1989.29292929293, 1989.67676767677, 1990.06060606061, 1990.44444444444,
1990.82828282828, 1991.21212121212, 1991.59595959596, 1991.9797979798,
1992.36363636364, 1992.74747474747, 1993.13131313131, 1993.51515151515,
1993.89898989899, 1994.28282828283, 1994.66666666667, 1995.05050505051,
1995.43434343434, 1995.81818181818, 1996.20202020202, 1996.58585858586,
1996.9696969697, 1997.35353535354, 1997.73737373737, 1998.12121212121,
1998.50505050505, 1998.88888888889, 1999.27272727273, 1999.65656565657,
2000.0404040404, 2000.42424242424, 2000.80808080808, 2001.19191919192,
2001.57575757576, 2001.9595959596, 2002.34343434343, 2002.72727272727,
2003.11111111111, 2003.49494949495, 2003.87878787879, 2004.26262626263,
2004.64646464646, 2005.0303030303, 2005.41414141414, 2005.79797979798,
2006.18181818182, 2006.56565656566, 2006.94949494949, 2007.33333333333,
2007.71717171717, 2008.10101010101, 2008.48484848485, 2008.86868686869,
2009.25252525253, 2009.63636363636, 2010.0202020202, 2010.40404040404,
2010.78787878788, 2011.17171717172, 2011.55555555556, 2011.93939393939,
2012.32323232323, 2012.70707070707, 2013.09090909091, 2013.47474747475,
2013.85858585859, 2014.24242424242, 2014.62626262626, 2015.0101010101,
2015.39393939394, 2015.77777777778, 2016.16161616162, 2016.54545454545,
2016.92929292929, 2017.31313131313, 2017.69696969697, 2018.08080808081,
2018.46464646465, 2018.84848484848, 2019.23232323232, 2019.61616161616,
2020), `1` = c(-0.000282416573603693, -0.00271591733455456, -0.00516199276939573,
-0.00763317487364931, -0.0101402837408418, -0.01269188461781,
-0.0152950907197726, -0.0179470899003348, -0.0206404685928068,
-0.0233625756144517, -0.0260886006877375, -0.0287915737231001,
-0.031437529963855, -0.0339868139836993, -0.036399445019488,
-0.0386347491982104, -0.0406519674557182, -0.0424151739981505,
-0.0438952673011647, -0.0450652167105189, -0.045910951429386,
-0.046424850317861, -0.0466048619383107, -0.0464628167632121,
-0.0460130873752293, -0.0452772390725702, -0.0442831064189103,
-0.0430590363960309, -0.0416347932713879, -0.0400404976146581,
-0.0383029757461397, -0.0364440659241958, -0.0344842706185839,
-0.032435721440793, -0.0303060775005323, -0.0281003022315046,
-0.0258161655729922, -0.0234501743005459, -0.0209976917685226,
-0.0184530137867315, -0.0158114123798943, -0.0130733195957459,
-0.0102408732690352, -0.00732122639306472, -0.00432967830237086,
-0.00128303518770019, 0.00179432791763776, 0.00487369521893103,
0.00792538944203596, 0.0109170705038135, 0.0138160888004594,
0.0165938183520947, 0.0192256568027686, 0.0216894482731145, 0.0239755222428691,
0.0260785671039841, 0.0280010274528969, 0.0297588681317019, 0.0313703301860457,
0.0328636713810393, 0.0342733156479352, 0.0356346133760946, 0.0369855582747931,
0.0383644502188473, 0.0398039785036263, 0.0413308230683103, 0.0429713691168698,
0.0447520018532761, 0.0466990099638965, 0.0488283941309507, 0.0511368816299008,
0.0536177739273218, 0.0562486839040952, 0.0589968627764145, 0.0618266563341742,
0.0646931096016521, 0.0675493345034615, 0.0703499950485326, 0.0730515359489744,
0.0756122918458651, 0.0780021869538043, 0.0801958101461476, 0.0821751680228707,
0.0839371812497683, 0.0854814166872423, 0.0868187774408077, 0.0879681955145901,
0.088950472444891, 0.0897926924122859, 0.0905233522093606, 0.091169613195777,
0.0917569952883759, 0.0923098773939077, 0.0928453286771147, 0.0933772651590566,
0.0939160138803542, 0.0944641526576321, 0.0950230238032931, 0.0955907167807124,
0.0961628514579845), `2` = c(-0.0893638592715282, -0.0875317466764431,
-0.0856958539552433, -0.0838523737545187, -0.0819964065877801,
-0.080121614455885, -0.0782214608016236, -0.0762886414261416,
-0.0743154988298857, -0.072294645465396, -0.0702193278776524,
-0.068083006882641, -0.0658811632845179, -0.0636109212944955,
-0.0612704321011602, -0.0588620858596529, -0.0563894802637761,
-0.0538590859979185, -0.0512814301960677, -0.0486677649179678,
-0.0460328295545333, -0.0433930961160075, -0.0407654030739626,
-0.0381674785115223, -0.035617065089155, -0.0331296702143186,
-0.0307188530185536, -0.0283967465072349, -0.0261691074381822,
-0.0240397453046267, -0.0220078796109846, -0.0200657802894222,
-0.0182044146607224, -0.01640816753255, -0.0146579078505463,
-0.0129331035313241, -0.0112095140996819, -0.00946231584134767,
-0.00766748096428189, -0.00580172478182936, -0.00384289673934499,
-0.00177445567984667, 0.000418299642416235, 0.002745604596645,
0.00521044063815636, 0.0078144028256126, 0.0105519025043017,
0.0134132303961086, 0.0163869166070966, 0.0194564825092788, 0.0226045179116448,
0.0258131458624685, 0.0290640226493096, 0.0323394097864151, 0.0356250069233987,
0.0389077235804468, 0.042177410412913, 0.0454290455924111, 0.0486585497860806,
0.0518665074960122, 0.0550563743888019, 0.0582324619655299, 0.0614016542174202,
0.0645713089873207, 0.0677479168036409, 0.0709370392352279, 0.0741441922891273,
0.077374891972387, 0.080634624839924, 0.083925738085757, 0.0872446976679729,
0.0905869194747165, 0.0939429757375555, 0.0973002396652585, 0.10064529044772,
0.103962187748657, 0.107234489740723, 0.110446837286768, 0.113585113417898,
0.116636018636522, 0.119591098484954, 0.122443847080729, 0.12519065289008,
0.127833723088064, 0.13037627958946, 0.13282573317239, 0.135192461376869,
0.137487432629253, 0.13972356747589, 0.141914210342991, 0.144071772628747,
0.146207518903139, 0.148332146487061, 0.150452861424054, 0.152575364192648,
0.154703722761441, 0.156838480820587, 0.158979625635534, 0.161125745294678,
0.163274365617306), `3` = c(0.0731504541724651, 0.0656497283632369,
0.0581727946194858, 0.0507434571968103, 0.0433860093175434, 0.0361253882507971,
0.028985514791221, 0.0219822021524561, 0.015127504610437, 0.00842913405350016,
0.00188472084093085, -0.00450979591794638, -0.0107626558146839,
-0.016885498117432, -0.022889051724781, -0.0287796775341719,
-0.0345623829106009, -0.0402340542407231, -0.0457801116431233,
-0.0511830953713278, -0.0564087665136821, -0.0614145396640546,
-0.0661521388573141, -0.0705591368971187, -0.0745707637001095,
-0.078119434617396, -0.08113511178774, -0.0835500802414415, -0.0853078934650334,
-0.0863556510074676, -0.0866544696675715, -0.0861866898203826,
-0.0849395803451227, -0.0829291581710035, -0.080186801986411,
-0.0767543113394985, -0.072701343191673, -0.0681028188942274,
-0.0630456864047119, -0.0576281222096396, -0.051948432096607,
-0.0461033962912715, -0.0401891661019579, -0.0342918951241707,
-0.0284814954648778, -0.0228237871778161, -0.017358673878057,
-0.0121111901579864, -0.00709633925879568, -0.00230028798482445,
0.00229664856665519, 0.00672807767697247, 0.0110415290060614,
0.0152856516752799, 0.0195119207479934, 0.0237726904150084, 0.0281130007957383,
0.0325651349262517, 0.0371580086377128, 0.0418977759216758, 0.0467765761386907,
0.0517774864620065, 0.0568555866974089, 0.0619599024250542, 0.0670254724478584,
0.0719723546693145, 0.0767198722389097, 0.0811873483061336, 0.0852941659477631,
0.0889660960106614, 0.0921408761030976, 0.0947595169893155, 0.0967865269064204,
0.0982019339356302, 0.0989959634901983, 0.0991927480185298, 0.0988243466086145,
0.0979434195877062, 0.0966262630430475, 0.0949532795258985, 0.0930230203521725,
0.0909412626037069, 0.0888144800044607, 0.0867505119293326, 0.0848563383917516,
0.0832253911771243, 0.0819415064348888, 0.0810803616636772, 0.0806882260354935,
0.0808039343542264, 0.0814442566921647, 0.0825988423321457, 0.0842517372796568,
0.0863593151278179, 0.0888660537100147, 0.0917104862462849, 0.0948183657654647,
0.0981143443513779, 0.101531436833672, 0.105009007121677)), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"))
</code>```

I put one data frame at a time in this function to calculate the derivative with forward difference for draws of each spline and calculate the estimate and confidence interval of the derivative from the 1000 draws:

```<code>Deriv <- function(data){
mty1 <- data[,-1]

#calculate delta y

mty2 <- mty1[-1,]
mty1 <- mty1[-nrow(data),]
m_delta_y <- mty2 - mty1

#calculate delta x
x1 <- data$year[-nrow(data)]
x2 <- data$year[-1]
m_delta_x <- x2-x1

#calculate derivative
mt_deriv <- as.data.frame(matrix(ncol = ncol(mty1), nrow = nrow(m_delta_y)))

for (i in c(1:ncol(m_delta_y))) {
mt_deriv[,i] <- m_delta_y[,i]/m_delta_x
}
deriv <-  as.data.frame(matrix(nrow = nrow(mt_deriv), ncol = 5))
  names(deriv) <- c("year","y_deriv_estim","sd", "upper_CI", "lower_CI")
  deriv$year <- (x1 + m_delta_x/2)

for(i in c(1:nrow(deriv))) {
deriv$y_deriv_estim[i] <- mean(as.numeric(mt_deriv[i,]))
  deriv$sd[i] <- sd(as.numeric(mt_deriv[i,]))
  deriv$upper_CI[i] <- ci(as.numeric(mt_deriv[i,]))$CI_high
  deriv$lower_CI[i] <- ci(as.numeric(mt_deriv[i,]))$CI_low
}

return(deriv)
}
</code>```

It works super well for the site-specific trends of the I-type model and the global trend of the GI-type model, but the site-specific trend of the GI model is not very smooth, which is a big problem for me because I want to calculate the second derivative and each default in smoothness is a value close to zero.

What would be the cause of the difference in smoothness? What is the solution?
Thank you!

P.S. the required packages to run the derivative calculation function are library(bayestestR) and library(tidyverse)

Body:
I have many hierarchical GAMs fitted with the brm() function of the brms package. Some of my GAMs have a 'I type' structure :

y ~ 1 + s(year, by = site, bs = "tp", m = 2) + s(level, bs = "tp") + (1|r|transect),
        zi ~ 1 + s(year, by = site, bs = "tp", m = 2) + s(level, bs = "tp") +(1|r|transect)

Where year and level are continuous and site and level are categorical. I also have GAMs with the 'GI type' structure:

y ~ 1 + s(year,bs = "tp")+ s(year, by = site, bs="tp") + s(level, bs = "tp") + s(site, bs = "re") +(1|r|intertidal_transect),
        zi ~ 1 + s(year,bs = "tp")+ s(year, by = site, bs="tp") + s(level, bs = "tp") + s(site, bs = "re") +(1|r|intertidal_transect)

I want to calculate the derivative of the splines with 95% confidence intervals. To do so, I extracted posterior predictions of 1000 draws with:

msms <- conditional_smooths(model, spaghetti = T)

Extracting each draw as data a frame and making a data frame for each spline (each site and the global trend for the GS model) with something like that plus some data manipulation to have a draw per column and time in the first column:

f <- attributes(msms_count_4$mu_y: s(YEAR,by=SITE,m=1,bs="tp"))$spaghetti
f_SW <- filter(f, cond__ == "SITE_SW")
f_NW <- filter(f, cond__ == "SITE_NW")

I get these draws for the site-specific posterior prediction of the GI modes:

structure(list(year = c(1982, 1982.38383838384, 1982.76767676768,
1983.15151515152, 1983.53535353535, 1983.91919191919, 1984.30303030303,
1984.68686868687, 1985.07070707071, 1985.45454545455, 1985.83838383838,
1986.22222222222, 1986.60606060606, 1986.9898989899, 1987.37373737374,
1987.75757575758, 1988.14141414141, 1988.52525252525, 1988.90909090909,
1989.29292929293, 1989.67676767677, 1990.06060606061, 1990.44444444444,
1990.82828282828, 1991.21212121212, 1991.59595959596, 1991.9797979798,
1992.36363636364, 1992.74747474747, 1993.13131313131, 1993.51515151515,
1993.89898989899, 1994.28282828283, 1994.66666666667, 1995.05050505051,
1995.43434343434, 1995.81818181818, 1996.20202020202, 1996.58585858586,
1996.9696969697, 1997.35353535354, 1997.73737373737, 1998.12121212121,
1998.50505050505, 1998.88888888889, 1999.27272727273, 1999.65656565657,
2000.0404040404, 2000.42424242424, 2000.80808080808, 2001.19191919192,
2001.57575757576, 2001.9595959596, 2002.34343434343, 2002.72727272727,
2003.11111111111, 2003.49494949495, 2003.87878787879, 2004.26262626263,
2004.64646464646, 2005.0303030303, 2005.41414141414, 2005.79797979798,
2006.18181818182, 2006.56565656566, 2006.94949494949, 2007.33333333333,
2007.71717171717, 2008.10101010101, 2008.48484848485, 2008.86868686869,
2009.25252525253, 2009.63636363636, 2010.0202020202, 2010.40404040404,
2010.78787878788, 2011.17171717172, 2011.55555555556, 2011.93939393939,
2012.32323232323, 2012.70707070707, 2013.09090909091, 2013.47474747475,
2013.85858585859, 2014.24242424242, 2014.62626262626, 2015.0101010101,
2015.39393939394, 2015.77777777778, 2016.16161616162, 2016.54545454545,
2016.92929292929, 2017.31313131313, 2017.69696969697, 2018.08080808081,
2018.46464646465, 2018.84848484848, 2019.23232323232, 2019.61616161616,
2020), `1` = c(0.0903901438415091, 0.102171563196727, 0.113952982551945,
0.129014020398404, 0.149103806598073, 0.169193592797743, 0.191117621275084,
0.213530781026471, 0.235097627348092, 0.252916514194966, 0.270735401041841,
0.282408024975746, 0.289610639518398, 0.296813254061055, 0.2902458944272,
0.283306373329117, 0.271128354990156, 0.249970055666827, 0.228811756343484,
0.199417802015595, 0.167467954755259, 0.134773132363749, 0.0981051092726421,
0.0614370861815133, 0.0261287888687987, -0.00807877805188554,
-0.0422863449725695, -0.0680311864152342, -0.0933058764424676,
-0.11409845247677, -0.1262715785247, -0.13844470457263, -0.140297494457864,
-0.138464449999272, -0.135109382021439, -0.121708958816611, -0.108308535611782,
-0.0914434142869732, -0.0714600646541677, -0.051476715021374,
-0.031052940336138, -0.0105914149321213, 0.00825495044447179,
0.0236018024283193, 0.0389486544121578, 0.0480260680379783, 0.0545492660364586,
0.0600291597020738, 0.0566409665383091, 0.0532527733745464, 0.0456414389225931,
0.0338069631824496, 0.0219724874423062, 0.00546466821953165,
-0.0115929561188369, -0.0290745116954201, -0.0475966257658035,
-0.0661187398361978, -0.0835478313887446, -0.100472451009983,
-0.117150683727973, -0.130954402574742, -0.144758121421519, -0.157185149748638,
-0.168082521942813, -0.178979894136988, -0.189877266331164, -0.200774638525346,
-0.211688584495069, -0.222648937036328, -0.233609289577587, -0.24520100413079,
-0.257121026930209, -0.269072787916266, -0.2815958362619, -0.294118884607533,
-0.306130253196955, -0.317509546793416, -0.32888884038987, -0.337055347879519,
-0.344619457974144, -0.350646697044373, -0.351721796147105, -0.352796895249835,
-0.348754056481851, -0.34172575395595, -0.33449119001513, -0.319624953722208,
-0.304758717429294, -0.287607586291897, -0.267314724743337, -0.247021863194777,
-0.22567487363744, -0.20408985517491, -0.183252248402289, -0.165217435466824,
-0.14718262253136, -0.133864392469005, -0.123622194715213, -0.113379996961422
), `2` = c(0.0281589447753082, 0.0360228847553418, 0.0438868247353754,
0.0542065220785714, 0.0682917140452664, 0.0823769060119616, 0.0990794558874814,
0.116479967872021, 0.133800230892946, 0.150765105646378, 0.167729980399809,
0.18214865686438, 0.194715552755233, 0.207282448646093, 0.212271721394666,
0.217056193517774, 0.218234485136086, 0.213230753031891, 0.208227020927692,
0.195733806596412, 0.18091627019466, 0.164887189511126, 0.142396539324755,
0.11990588913837, 0.0953530003646379, 0.06913068035352, 0.0429083603424022,
0.0177391720305717, -0.00737150896464664, -0.0305577749798716,
-0.050043242956679, -0.069528710933486, -0.0826863717986276,
-0.0935841015524644, -0.103275101184265, -0.105001682010679,
-0.106728262837092, -0.104648921431536, -0.0991442500172005,
-0.0936395786028685, -0.0850102188719535, -0.076113028713903,
-0.0675699556156343, -0.0597941361468887, -0.0520183166781475,
-0.0477026543788269, -0.0447966857411216, -0.0425926203390234,
-0.0463547324396034, -0.050116844540181, -0.0568723517603612,
-0.0666212541001435, -0.0763701564399258, -0.0889238481726288,
-0.101807515128021, -0.114445937172545, -0.12648239443585, -0.138518851699162,
-0.147442691700809, -0.154929939120153, -0.161889368679005, -0.162690923198772,
-0.163492477718539, -0.161194439863554, -0.155452410481069, -0.149710381098584,
-0.143968351716099, -0.138226322333611, -0.131983419557772, -0.124338071280545,
-0.116692723003317, -0.109620461991288, -0.102846206357157, -0.0962364745144016,
-0.0925881709163024, -0.0889398673182031, -0.0871389645791802,
-0.0876201452543117, -0.088101325929443, -0.0916514779767321,
-0.0957770621563005, -0.100373400438514, -0.106486613051482,
-0.112599825664444, -0.118637332497359, -0.124630677625246, -0.130575331305669,
-0.134718401429927, -0.138861471554181, -0.141911821692888, -0.143459681851466,
-0.145007542010045, -0.144765806376384, -0.144119968467057, -0.1432689308015,
-0.141648394050079, -0.140027857298658, -0.138648923662264, -0.137427557274803,
-0.136206190887341), `3` = c(-0.0539709293028476, -0.0537496486563462,
-0.0535283680098447, -0.0522786240455355, -0.0494519029939236,
-0.0466251819423118, -0.0391992632840588, -0.0305468919307008,
-0.0204744488785012, -0.00411311687432633, 0.012248215129849,
0.0323498353609559, 0.0551716652116509, 0.0779934950623591, 0.102357980235101,
0.126764158794924, 0.149058589751514, 0.167732881959705, 0.186407174167906,
0.195190131244194, 0.200903363624378, 0.20390162164128, 0.192420016387331,
0.180938411133375, 0.160428244631795, 0.132609242834518, 0.10479024103724,
0.0674567551735125, 0.0295946868616242, -0.00826605904612237,
-0.0461242618690254, -0.0839824646919283, -0.114022138115743,
-0.141269479611326, -0.16611936316185, -0.175146024275105, -0.184172685388359,
-0.182546736516697, -0.171333438658595, -0.1601201408005, -0.134141380135618,
-0.106897008373012, -0.0773884635227222, -0.0429742103157592,
-0.00855995710881638, 0.0236217573947781, 0.0548939190933054,
0.0849778245533993, 0.104961551986795, 0.124945279420179, 0.137628477017008,
0.143011144777282, 0.148393812537556, 0.142732296530229, 0.135771464785536,
0.127093455002492, 0.114200553670764, 0.101307652339029, 0.0895675478807852,
0.0783595035179952, 0.0677226764786005, 0.0637500515454905, 0.0597774266123786,
0.0598004232658113, 0.0642629994598431, 0.0687255756538748, 0.0731881518479065,
0.0776507280419409, 0.0824611632887457, 0.0882456038833142, 0.0940300444778826,
0.0973139227929918, 0.0992975087227821, 0.100846136701156, 0.0945655215540797,
0.0882849064070032, 0.0774710464544904, 0.0610572958599553, 0.0446435452654299,
0.0210351933610963, -0.00392214628882514, -0.0298341358608949,
-0.0588222196265737, -0.0878103033922348, -0.115712683511179,
-0.142981736502873, -0.170077615674274, -0.190766063494826, -0.211454511315367,
-0.228409357364048, -0.240230500976425, -0.252051644588802, -0.257338274195062,
-0.261149368380579, -0.263958087453723, -0.263007899855467, -0.262057712257211,
-0.260596000222232, -0.258800685293739, -0.257005370365246)), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"))

And this is site-specific with the I model:

structure(list(year = c(1982, 1982.38383838384, 1982.76767676768,
1983.15151515152, 1983.53535353535, 1983.91919191919, 1984.30303030303,
1984.68686868687, 1985.07070707071, 1985.45454545455, 1985.83838383838,
1986.22222222222, 1986.60606060606, 1986.9898989899, 1987.37373737374,
1987.75757575758, 1988.14141414141, 1988.52525252525, 1988.90909090909,
1989.29292929293, 1989.67676767677, 1990.06060606061, 1990.44444444444,
1990.82828282828, 1991.21212121212, 1991.59595959596, 1991.9797979798,
1992.36363636364, 1992.74747474747, 1993.13131313131, 1993.51515151515,
1993.89898989899, 1994.28282828283, 1994.66666666667, 1995.05050505051,
1995.43434343434, 1995.81818181818, 1996.20202020202, 1996.58585858586,
1996.9696969697, 1997.35353535354, 1997.73737373737, 1998.12121212121,
1998.50505050505, 1998.88888888889, 1999.27272727273, 1999.65656565657,
2000.0404040404, 2000.42424242424, 2000.80808080808, 2001.19191919192,
2001.57575757576, 2001.9595959596, 2002.34343434343, 2002.72727272727,
2003.11111111111, 2003.49494949495, 2003.87878787879, 2004.26262626263,
2004.64646464646, 2005.0303030303, 2005.41414141414, 2005.79797979798,
2006.18181818182, 2006.56565656566, 2006.94949494949, 2007.33333333333,
2007.71717171717, 2008.10101010101, 2008.48484848485, 2008.86868686869,
2009.25252525253, 2009.63636363636, 2010.0202020202, 2010.40404040404,
2010.78787878788, 2011.17171717172, 2011.55555555556, 2011.93939393939,
2012.32323232323, 2012.70707070707, 2013.09090909091, 2013.47474747475,
2013.85858585859, 2014.24242424242, 2014.62626262626, 2015.0101010101,
2015.39393939394, 2015.77777777778, 2016.16161616162, 2016.54545454545,
2016.92929292929, 2017.31313131313, 2017.69696969697, 2018.08080808081,
2018.46464646465, 2018.84848484848, 2019.23232323232, 2019.61616161616,
2020), `1` = c(-0.000282416573603693, -0.00271591733455456, -0.00516199276939573,
-0.00763317487364931, -0.0101402837408418, -0.01269188461781,
-0.0152950907197726, -0.0179470899003348, -0.0206404685928068,
-0.0233625756144517, -0.0260886006877375, -0.0287915737231001,
-0.031437529963855, -0.0339868139836993, -0.036399445019488,
-0.0386347491982104, -0.0406519674557182, -0.0424151739981505,
-0.0438952673011647, -0.0450652167105189, -0.045910951429386,
-0.046424850317861, -0.0466048619383107, -0.0464628167632121,
-0.0460130873752293, -0.0452772390725702, -0.0442831064189103,
-0.0430590363960309, -0.0416347932713879, -0.0400404976146581,
-0.0383029757461397, -0.0364440659241958, -0.0344842706185839,
-0.032435721440793, -0.0303060775005323, -0.0281003022315046,
-0.0258161655729922, -0.0234501743005459, -0.0209976917685226,
-0.0184530137867315, -0.0158114123798943, -0.0130733195957459,
-0.0102408732690352, -0.00732122639306472, -0.00432967830237086,
-0.00128303518770019, 0.00179432791763776, 0.00487369521893103,
0.00792538944203596, 0.0109170705038135, 0.0138160888004594,
0.0165938183520947, 0.0192256568027686, 0.0216894482731145, 0.0239755222428691,
0.0260785671039841, 0.0280010274528969, 0.0297588681317019, 0.0313703301860457,
0.0328636713810393, 0.0342733156479352, 0.0356346133760946, 0.0369855582747931,
0.0383644502188473, 0.0398039785036263, 0.0413308230683103, 0.0429713691168698,
0.0447520018532761, 0.0466990099638965, 0.0488283941309507, 0.0511368816299008,
0.0536177739273218, 0.0562486839040952, 0.0589968627764145, 0.0618266563341742,
0.0646931096016521, 0.0675493345034615, 0.0703499950485326, 0.0730515359489744,
0.0756122918458651, 0.0780021869538043, 0.0801958101461476, 0.0821751680228707,
0.0839371812497683, 0.0854814166872423, 0.0868187774408077, 0.0879681955145901,
0.088950472444891, 0.0897926924122859, 0.0905233522093606, 0.091169613195777,
0.0917569952883759, 0.0923098773939077, 0.0928453286771147, 0.0933772651590566,
0.0939160138803542, 0.0944641526576321, 0.0950230238032931, 0.0955907167807124,
0.0961628514579845), `2` = c(-0.0893638592715282, -0.0875317466764431,
-0.0856958539552433, -0.0838523737545187, -0.0819964065877801,
-0.080121614455885, -0.0782214608016236, -0.0762886414261416,
-0.0743154988298857, -0.072294645465396, -0.0702193278776524,
-0.068083006882641, -0.0658811632845179, -0.0636109212944955,
-0.0612704321011602, -0.0588620858596529, -0.0563894802637761,
-0.0538590859979185, -0.0512814301960677, -0.0486677649179678,
-0.0460328295545333, -0.0433930961160075, -0.0407654030739626,
-0.0381674785115223, -0.035617065089155, -0.0331296702143186,
-0.0307188530185536, -0.0283967465072349, -0.0261691074381822,
-0.0240397453046267, -0.0220078796109846, -0.0200657802894222,
-0.0182044146607224, -0.01640816753255, -0.0146579078505463,
-0.0129331035313241, -0.0112095140996819, -0.00946231584134767,
-0.00766748096428189, -0.00580172478182936, -0.00384289673934499,
-0.00177445567984667, 0.000418299642416235, 0.002745604596645,
0.00521044063815636, 0.0078144028256126, 0.0105519025043017,
0.0134132303961086, 0.0163869166070966, 0.0194564825092788, 0.0226045179116448,
0.0258131458624685, 0.0290640226493096, 0.0323394097864151, 0.0356250069233987,
0.0389077235804468, 0.042177410412913, 0.0454290455924111, 0.0486585497860806,
0.0518665074960122, 0.0550563743888019, 0.0582324619655299, 0.0614016542174202,
0.0645713089873207, 0.0677479168036409, 0.0709370392352279, 0.0741441922891273,
0.077374891972387, 0.080634624839924, 0.083925738085757, 0.0872446976679729,
0.0905869194747165, 0.0939429757375555, 0.0973002396652585, 0.10064529044772,
0.103962187748657, 0.107234489740723, 0.110446837286768, 0.113585113417898,
0.116636018636522, 0.119591098484954, 0.122443847080729, 0.12519065289008,
0.127833723088064, 0.13037627958946, 0.13282573317239, 0.135192461376869,
0.137487432629253, 0.13972356747589, 0.141914210342991, 0.144071772628747,
0.146207518903139, 0.148332146487061, 0.150452861424054, 0.152575364192648,
0.154703722761441, 0.156838480820587, 0.158979625635534, 0.161125745294678,
0.163274365617306), `3` = c(0.0731504541724651, 0.0656497283632369,
0.0581727946194858, 0.0507434571968103, 0.0433860093175434, 0.0361253882507971,
0.028985514791221, 0.0219822021524561, 0.015127504610437, 0.00842913405350016,
0.00188472084093085, -0.00450979591794638, -0.0107626558146839,
-0.016885498117432, -0.022889051724781, -0.0287796775341719,
-0.0345623829106009, -0.0402340542407231, -0.0457801116431233,
-0.0511830953713278, -0.0564087665136821, -0.0614145396640546,
-0.0661521388573141, -0.0705591368971187, -0.0745707637001095,
-0.078119434617396, -0.08113511178774, -0.0835500802414415, -0.0853078934650334,
-0.0863556510074676, -0.0866544696675715, -0.0861866898203826,
-0.0849395803451227, -0.0829291581710035, -0.080186801986411,
-0.0767543113394985, -0.072701343191673, -0.0681028188942274,
-0.0630456864047119, -0.0576281222096396, -0.051948432096607,
-0.0461033962912715, -0.0401891661019579, -0.0342918951241707,
-0.0284814954648778, -0.0228237871778161, -0.017358673878057,
-0.0121111901579864, -0.00709633925879568, -0.00230028798482445,
0.00229664856665519, 0.00672807767697247, 0.0110415290060614,
0.0152856516752799, 0.0195119207479934, 0.0237726904150084, 0.0281130007957383,
0.0325651349262517, 0.0371580086377128, 0.0418977759216758, 0.0467765761386907,
0.0517774864620065, 0.0568555866974089, 0.0619599024250542, 0.0670254724478584,
0.0719723546693145, 0.0767198722389097, 0.0811873483061336, 0.0852941659477631,
0.0889660960106614, 0.0921408761030976, 0.0947595169893155, 0.0967865269064204,
0.0982019339356302, 0.0989959634901983, 0.0991927480185298, 0.0988243466086145,
0.0979434195877062, 0.0966262630430475, 0.0949532795258985, 0.0930230203521725,
0.0909412626037069, 0.0888144800044607, 0.0867505119293326, 0.0848563383917516,
0.0832253911771243, 0.0819415064348888, 0.0810803616636772, 0.0806882260354935,
0.0808039343542264, 0.0814442566921647, 0.0825988423321457, 0.0842517372796568,
0.0863593151278179, 0.0888660537100147, 0.0917104862462849, 0.0948183657654647,
0.0981143443513779, 0.101531436833672, 0.105009007121677)), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"))

I put one data frame at a time in this function to calculate the derivative with forward difference for draws of each spline and calculate the estimate and confidence interval of the derivative from the 1000 draws:

Deriv <- function(data){
mty1 <- data[,-1]

#calculate delta y

mty2 <- mty1[-1,]
mty1 <- mty1[-nrow(data),]
m_delta_y <- mty2 - mty1

#calculate delta x
x1 <- data$year[-nrow(data)]
x2 <- data$year[-1]
m_delta_x <- x2-x1

#calculate derivative
mt_deriv <- as.data.frame(matrix(ncol = ncol(mty1), nrow = nrow(m_delta_y)))

for (i in c(1:ncol(m_delta_y))) {
mt_deriv[,i] <- m_delta_y[,i]/m_delta_x
}
deriv <-  as.data.frame(matrix(nrow = nrow(mt_deriv), ncol = 5))
  names(deriv) <- c("year","y_deriv_estim","sd", "upper_CI", "lower_CI")
  deriv$year <- (x1 + m_delta_x/2)

for(i in c(1:nrow(deriv))) {
deriv$y_deriv_estim[i] <- mean(as.numeric(mt_deriv[i,]))
  deriv$sd[i] <- sd(as.numeric(mt_deriv[i,]))
  deriv$upper_CI[i] <- ci(as.numeric(mt_deriv[i,]))$CI_high
  deriv$lower_CI[i] <- ci(as.numeric(mt_deriv[i,]))$CI_low
}

return(deriv)
}

It works super well for the site-specific trends of the I-type model and the global trend of the GI-type model, but the site-specific trend of the GI model is not very smooth, which is a big problem for me because I want to calculate the second derivative and each default in smoothness is a value close to zero.

What would be the cause of the difference in smoothness? What is the solution?
Thank you!

P.S. the required packages to run the derivative calculation function are library(bayestestR) and library(tidyverse)


问:
Call function each index (docs) in Listview.Builder - flutter
I want to set "checked" or "not checked" text front of member, When I show member list.

I will explain what I did step by step

First, I created bool value

```<code>bool isChecked = false;
</code>```

and, I have ListView for show member list

```<code>ListView.builder(
            shrinkWrap: true,
            itemCount: membersSnapshot!.docs.length,
            itemBuilder: (context, index) {
              return groupTile( // <---- widget
                widget.userName,
                widget.fileName,
              );
            },
          )
</code>```

groupTile is a widget, This is codings

```<code>Widget groupTile(
      String userName, String fileName) {
    // ---------------------------------------------------------
    // This is what I did for check it
    CheckedOrNot(userName,fileName); // <--- Call this function
    return ListTile(
      title: Text("File"),
      trailing: InkWell(
        onTap: () {},
        child: isOpened
            ? Container(
                  color: Colors.black,
                child: const Text(
                  "Checked"
                ),
              )
            : Container(
                  color: Colors.black,
                child: const Text(
                  "Check it!"
                ),
              )
      ),
    );
  }
</code>```

CheckedOrNot function codings

```<code>CheckedOrNot(String userName, String fileName) async {
    await DatabaseMethods()
        .isUserChecked(userName,fileName)
        .then((value) {
      setState(() {
        isJoined = value;
      });
    });
  }
</code>```

Codes of DatabaseMethods().isUserChecked

```<code>Future<bool> isUserChecked(
       String userName, String fileName) async {
    DocumentReference userDocRef = userCol.doc(_auth.currentUser!.uid);
    DocumentSnapshot documentSnapshot = await userDocRef.get();

    List<dynamic> groups = await documentSnapshot['groups'];
    if (groups.contains("fileName")) {
      return true;
    } else {
      return false;
    }
  }
</code>```

This work for when have 1 file, If enter more files, That function not working properly.

There is a picture of my database

Body:
I want to set "checked" or "not checked" text front of member, When I show member list.

I will explain what I did step by step

First, I created bool value

bool isChecked = false;

and, I have ListView for show member list

ListView.builder(
            shrinkWrap: true,
            itemCount: membersSnapshot!.docs.length,
            itemBuilder: (context, index) {
              return groupTile( // <---- widget
                widget.userName,
                widget.fileName,
              );
            },
          )

groupTile is a widget, This is codings

Widget groupTile(
      String userName, String fileName) {
    // ---------------------------------------------------------
    // This is what I did for check it
    CheckedOrNot(userName,fileName); // <--- Call this function
    return ListTile(
      title: Text("File"),
      trailing: InkWell(
        onTap: () {},
        child: isOpened
            ? Container(
                  color: Colors.black,
                child: const Text(
                  "Checked"
                ),
              )
            : Container(
                  color: Colors.black,
                child: const Text(
                  "Check it!"
                ),
              )
      ),
    );
  }

CheckedOrNot function codings

CheckedOrNot(String userName, String fileName) async {
    await DatabaseMethods()
        .isUserChecked(userName,fileName)
        .then((value) {
      setState(() {
        isJoined = value;
      });
    });
  }

Codes of DatabaseMethods().isUserChecked

Future<bool> isUserChecked(
       String userName, String fileName) async {
    DocumentReference userDocRef = userCol.doc(_auth.currentUser!.uid);
    DocumentSnapshot documentSnapshot = await userDocRef.get();

    List<dynamic> groups = await documentSnapshot['groups'];
    if (groups.contains("fileName")) {
      return true;
    } else {
      return false;
    }
  }

This work for when have 1 file, If enter more files, That function not working properly.

There is a picture of my database


问:
How to intercept graphql request responses happening via rest api
I've Springboot Application that interacts with client system via Graphql request/responses  through RestTemplate (rest api) call.

I want to build interceptor to log these request response (without PHI & PII data) in it.

I tried to create my custom interceptor with ClientHttpRequestInterceptor, but not able to understand how do I decode the Http request and identify PHI & PII fields from it.


问:
Using URL parameters for webforms that seem to be resistant to them?
I'm attempting to write a little script that, as part of it, would automatically complete a webform using data from a dictionary.

I've developed this script for other forms in the past with a pretty simple setup: the elements in the form are identified with a line like...

```<code><input type="text" name="full_name" id="full_name_id" maxlength="80" value="">
<input type="text" name="title" id="title_id" maxlength="80" value="">
</code>```

So, I'd navigate to www.theformsite.com/theform.php?full_name_id=David&title_id=Stuff and find those slots already filled in.

For a couple new forms I've been working with though, that doesn't seem to work: there's no response to these parameters. Are there any general things that could prevent this from working that I should check on?

Body:
I'm attempting to write a little script that, as part of it, would automatically complete a webform using data from a dictionary.

I've developed this script for other forms in the past with a pretty simple setup: the elements in the form are identified with a line like...

<input type="text" name="full_name" id="full_name_id" maxlength="80" value="">
<input type="text" name="title" id="title_id" maxlength="80" value="">

So, I'd navigate to www.theformsite.com/theform.php?full_name_id=David&title_id=Stuff and find those slots already filled in.

For a couple new forms I've been working with though, that doesn't seem to work: there's no response to these parameters. Are there any general things that could prevent this from working that I should check on?


问:
Exponential smoothening giving NaN values
I have written a function to find the values for alpha, beta and gamma for ExponentialSmoothening. When I run this code without the gamma values, it works fine but when i give values for gamma, it gives me an error.
The function is outputting NaN values but for only a specific combination of the three values.

Code:

```<code>import numpy as np
from sklearn.metrics import mean_absolute_error
from statsmodels.tsa.holtwinters import ExponentialSmoothing

# In[2]:

def auto_hwm(timeseries, val_split_date, alpha=[None], beta=[None], gamma=[None], phi=[None],
              trend=None, seasonal=None, periods=None, verbose=False):

    '''The auto_hwm (short for auto holt winters model) function to search for the best possible parameter
        combination for the Exponential Smoothing model i.e. smoothing level, smoothing slope,
        smoothing seasonal and damping slope based on mean absolute error.

        ****Paramters****

        timeseries: array-like

                  Time-Series

        val_split_date: str

                  The datetime to split the time-series for validation

        alpha: list of floats (optional)

                  The list of alpha values for the simple exponential smoothing parameter

        beta: list of floats (optional)

                  The list of beta values for the Holt’s trend method parameter

        gamma: list of floats (optional)

                  The list of gamma values for the holt winters seasonal method parameter

        phi: list of floats (optional)

                  The list of phi values for the damped method parameter

        trend: {“add”, “mul”, “additive”, “multiplicative”, None} (optional)

                  Type of trend component.

        seasonal: {“add”, “mul”, “additive”, “multiplicative”, None} (optional)

                  Type of seasonal component.

        periods: int (optional)

                  The number of periods in a complete seasonal cycle

        ****Returns****

        best_params: dict

                  The values of alpha, beta, gamma and phi for which the
                  validation data (val_split_date) gives the least mean absolute error
    '''

    best_params = []
    actual = timeseries[val_split_date:]

    print('Evaluating Exponential Smoothing model for', len(alpha) * len(beta) * len(gamma) * len(phi), 'fits\n')

    for a in alpha:
        for b in beta:
            for g in gamma:
                for p in phi:

                    if(verbose == True):
                        print('Checking for', {'alpha': a, 'beta': b, 'gamma': g, 'phi': p})

                    model = ExponentialSmoothing(timeseries, trend=trend, seasonal=seasonal, seasonal_periods=periods)
                    model.fit(smoothing_level=a, smoothing_slope=b, smoothing_seasonal=g, damping_slope=p)
                    f_cast = model.predict(model.params, start=actual.index[0])
                    score = np.where(np.float64(mean_absolute_error(actual, f_cast)/actual).mean()>0,np.float64(mean_absolute_error(actual, f_cast)/actual).mean(),0)

                    best_params.append({'alpha': a, 'beta': b, 'gamma': g, 'phi': p, 'mae': score})

    return min(best_params, key=lambda x: x['mae'])

</code>```

auto_hwm(ts, val_split_date = '2018-10-01', alpha = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], beta = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], gamma = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], trend='mul', seasonal='mul', periods=12, verbose=True)

It is giving NaN values for a specific combination of three values. There are no missing values in the series

Body:
I have written a function to find the values for alpha, beta and gamma for ExponentialSmoothening. When I run this code without the gamma values, it works fine but when i give values for gamma, it gives me an error.
The function is outputting NaN values but for only a specific combination of the three values.

Code:

import numpy as np
from sklearn.metrics import mean_absolute_error
from statsmodels.tsa.holtwinters import ExponentialSmoothing

# In[2]:

def auto_hwm(timeseries, val_split_date, alpha=[None], beta=[None], gamma=[None], phi=[None],
              trend=None, seasonal=None, periods=None, verbose=False):

    '''The auto_hwm (short for auto holt winters model) function to search for the best possible parameter
        combination for the Exponential Smoothing model i.e. smoothing level, smoothing slope,
        smoothing seasonal and damping slope based on mean absolute error.

        ****Paramters****

        timeseries: array-like

                  Time-Series

        val_split_date: str

                  The datetime to split the time-series for validation

        alpha: list of floats (optional)

                  The list of alpha values for the simple exponential smoothing parameter

        beta: list of floats (optional)

                  The list of beta values for the Holt’s trend method parameter

        gamma: list of floats (optional)

                  The list of gamma values for the holt winters seasonal method parameter

        phi: list of floats (optional)

                  The list of phi values for the damped method parameter

        trend: {“add”, “mul”, “additive”, “multiplicative”, None} (optional)

                  Type of trend component.

        seasonal: {“add”, “mul”, “additive”, “multiplicative”, None} (optional)

                  Type of seasonal component.

        periods: int (optional)

                  The number of periods in a complete seasonal cycle

        ****Returns****

        best_params: dict

                  The values of alpha, beta, gamma and phi for which the
                  validation data (val_split_date) gives the least mean absolute error
    '''

    best_params = []
    actual = timeseries[val_split_date:]

    print('Evaluating Exponential Smoothing model for', len(alpha) * len(beta) * len(gamma) * len(phi), 'fits\n')

    for a in alpha:
        for b in beta:
            for g in gamma:
                for p in phi:

                    if(verbose == True):
                        print('Checking for', {'alpha': a, 'beta': b, 'gamma': g, 'phi': p})

                    model = ExponentialSmoothing(timeseries, trend=trend, seasonal=seasonal, seasonal_periods=periods)
                    model.fit(smoothing_level=a, smoothing_slope=b, smoothing_seasonal=g, damping_slope=p)
                    f_cast = model.predict(model.params, start=actual.index[0])
                    score = np.where(np.float64(mean_absolute_error(actual, f_cast)/actual).mean()>0,np.float64(mean_absolute_error(actual, f_cast)/actual).mean(),0)

                    best_params.append({'alpha': a, 'beta': b, 'gamma': g, 'phi': p, 'mae': score})

    return min(best_params, key=lambda x: x['mae'])

auto_hwm(ts, val_split_date = '2018-10-01', alpha = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], beta = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], gamma = [0.1, 0.2, 0.3,0.4, 0.5, 0.6, 0.8, 0.9], trend='mul', seasonal='mul', periods=12, verbose=True)

It is giving NaN values for a specific combination of three values. There are no missing values in the series


问:
How to make Unity OVR hand collide with objects?
I want to make the OVRCameraRig hands from the Oculus Integration SDK sample to collide with objects. I mean I want it to use realistic physics and have the hand stopped by a cube or any gameobject without going throught it to make it much more realistic.

I tried to use the "Hand Physics Capsules" built in script for the right and left hand, that puts colliders and rigidbodys on the hand but it does not works as I want it. This method just pushes away the cube but does not stops the vr hands from going throught the cube and I don't want the cube to do any movement.

Thank you all for the help in advance.

Unity version: 2021.3.15f1

Oculus Integration SDK: 46.0


问:
Check if a variable is a color SCSS
I'm trying to pass in the background color variable to a function to get the contrast text color

@function get-contrast($background-color) {
    @if lightness($background-color) > 50% {
        @return black;
    } @else {
        @return white;
    }
}
```

However, I am trying to pass in a linear gradient as the color, but the lightness function throws an error. I am fine just returning black for linear gradients, but is there a way to check if what I'm passing in is a color or any other way to go about this?

Title: Check if a variable is a color SCSS

Body:
I'm trying to pass in the background color variable to a function to get the contrast text color

@function get-contrast($background-color) {
    @if lightness($background-color) > 50% {
        @return black;
    } @else {
        @return white;
    }
}

However, I am trying to pass in a linear gradient as the color, but the lightness function throws an error. I am fine just returning black for linear gradients, but is there a way to check if what I'm passing in is a color or any other way to go about this?


问:
Untar *tar.gz files in s3, then compress them as *.gz and finally move those new compressed files to a new location in s3
As the noted title I'm trying to untar/uncompress several tar.gz files for a given path in s3 (those are JSON files) and then (in memory) compress them as .gz and finally move to another location in s3 again.

This is the code I've tried so far.

`

```<code>s3_resource = resource('s3')

tar_file = s3_resource.Object(bucket_name=bucketname, key=key_path)
file_object = BytesIO(tar_file.get()["Body"].read())

with tarfile.open(fileobj=file_object, mode=('r:gz')) as z:
    for filename in z.getmembers():
        #print(filename)

        if (filename.isfile()):
            logger.info(f'current file in zipfile: {filename.name}')
            final_file_path = f"{filename.name}.gzip"

            #print(final_file_path)

            gzipped_content = gzip.compress(z.extractfile(filename))

            s3_resource.meta.client.upload_fileobj(
                io.BytesIO(gzipped_content),
                Bucket=bucket_name,
                Key=f'{key_path_untar}/{final_file_path}'
            )
</code>```

`

The problem specifically is with the gzipped_content = gzip.compress(z.extractfile(filename)) part.

But I'm receiving the error

```<code>a bytes-like object is required, not 'ExFileObject'
</code>```

Body:
As the noted title I'm trying to untar/uncompress several tar.gz files for a given path in s3 (those are JSON files) and then (in memory) compress them as .gz and finally move to another location in s3 again.

This is the code I've tried so far.

`

s3_resource = resource('s3')

tar_file = s3_resource.Object(bucket_name=bucketname, key=key_path)
file_object = BytesIO(tar_file.get()["Body"].read())

with tarfile.open(fileobj=file_object, mode=('r:gz')) as z:
    for filename in z.getmembers():
        #print(filename)

        if (filename.isfile()):
            logger.info(f'current file in zipfile: {filename.name}')
            final_file_path = f"{filename.name}.gzip"

            #print(final_file_path)

            gzipped_content = gzip.compress(z.extractfile(filename))

            s3_resource.meta.client.upload_fileobj(
                io.BytesIO(gzipped_content),
                Bucket=bucket_name,
                Key=f'{key_path_untar}/{final_file_path}'
            )

`

The problem specifically is with the gzipped_content = gzip.compress(z.extractfile(filename)) part.

But I'm receiving the error

a bytes-like object is required, not 'ExFileObject'