问:
SwiftUI Add Plot Points to Graph
I have a graph that I want to add plot points to but not sure how to go about it. I'm not sure if the plot point should go in the implementation or in the ZStack in the usage. Is it possible to add a View using that CGPoint?

This is my graph implementation:

```<code>struct LineGraph: Shape {
    var dataPoints: [CGFloat]
    var closed: Bool = false
    var max: CGFloat

    func path(in rect: CGRect) -> Path {

        func point(index: Int) -> CGPoint {
            let point: CGFloat = dataPoints[index] / max
            let xCord: CGFloat = rect.width * CGFloat(index) / CGFloat(dataPoints.count - 1)
            let yCord: CGFloat = (1 - point) * rect.height
            return CGPoint(x: xCord, y: yCord)
        }

        return Path { path in

            guard dataPoints.count > 1 else {return}

            let start: CGFloat = dataPoints[0] / max
            path.move(to: CGPoint(x: 0, y: (1 - start) * rect.height))

            for index in dataPoints.indices {
                path.addLine(to: point(index: index))
            }

            if closed {
                path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
                path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
                path.closeSubpath()
            }
        }
    }
}
</code>```

and usage:

```<code>ZStack {
    LinearGradient(
                    gradient: Gradient(colors: [.POI.blue, .clear]),
                    startPoint: .top,
                    endPoint: .bottom
                )
                .clipShape(LineGraph(dataPoints: viewModel.endingBalance.map { CGFloat($0) }, closed: true, max: max))

                LineGraph(dataPoints: viewModel.endingBalance.map { CGFloat($0) }, max: max)
                    .stroke(Color.POI.blue, lineWidth: 1)

}
</code>```

Title: SwiftUI Add Plot Points to Graph

Body:
I have a graph that I want to add plot points to but not sure how to go about it. I'm not sure if the plot point should go in the implementation or in the ZStack in the usage. Is it possible to add a View using that CGPoint?

This is my graph implementation:

struct LineGraph: Shape {
    var dataPoints: [CGFloat]
    var closed: Bool = false
    var max: CGFloat

    func path(in rect: CGRect) -> Path {

        func point(index: Int) -> CGPoint {
            let point: CGFloat = dataPoints[index] / max
            let xCord: CGFloat = rect.width * CGFloat(index) / CGFloat(dataPoints.count - 1)
            let yCord: CGFloat = (1 - point) * rect.height
            return CGPoint(x: xCord, y: yCord)
        }

        return Path { path in

            guard dataPoints.count > 1 else {return}

            let start: CGFloat = dataPoints[0] / max
            path.move(to: CGPoint(x: 0, y: (1 - start) * rect.height))

            for index in dataPoints.indices {
                path.addLine(to: point(index: index))
            }

            if closed {
                path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
                path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
                path.closeSubpath()
            }
        }
    }
}

and usage:

ZStack {
    LinearGradient(
                    gradient: Gradient(colors: [.POI.blue, .clear]),
                    startPoint: .top,
                    endPoint: .bottom
                )
                .clipShape(LineGraph(dataPoints: viewModel.endingBalance.map { CGFloat($0) }, closed: true, max: max))

                LineGraph(dataPoints: viewModel.endingBalance.map { CGFloat($0) }, max: max)
                    .stroke(Color.POI.blue, lineWidth: 1)

}


来源: stackexchange

问:
Compose ModalBottomSheet sheetContent is taking up space in UI even when not shown
When I use the ModalBottomSheetLayout, it seems to cause the UI to take up space for the bottomSheet content, even when the bottomSheet isn't being displayed.

val modalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
val coroutineScope = rememberCoroutineScope()
    ModalBottomSheetLayout(
        sheetState = modalBottomSheetState,
        sheetContent = {
            SomeBottomSheetContent() //seems to be taking up space in the UI even when bottomSheet isn't visible
        }
    ) {
            MyRow(
                ... // uses some dynamic data known only at runtime
            )
      }
}
```

This is what is desired:

but instead, I get this:

*** Update ***

I think maybe this is happening because the ModalBottomSheetLayout was designed to be used at the page level, and so the sheetContent would need to be defined at compile time. If that's the case, how do I populate the sheetContent using dynamic data obtained at runtime?

ContentLicense: CC BY-SA 4.0

Body:
When I use the ModalBottomSheetLayout, it seems to cause the UI to take up space for the bottomSheet content, even when the bottomSheet isn't being displayed.

val modalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
val coroutineScope = rememberCoroutineScope()
    ModalBottomSheetLayout(
        sheetState = modalBottomSheetState,
        sheetContent = {
            SomeBottomSheetContent() //seems to be taking up space in the UI even when bottomSheet isn't visible
        }
    ) {
            MyRow(
                ... // uses some dynamic data known only at runtime
            )
      }
}

This is what is desired:

but instead, I get this:

*** Update ***

I think maybe this is happening because the ModalBottomSheetLayout was designed to be used at the page level, and so the sheetContent would need to be defined at compile time. If that's the case, how do I populate the sheetContent using dynamic data obtained at runtime?


问:
PHP: Forward NTLM credentials from browser to curl request
So not sure if this is actually feasible or not. But putting a page together for our techs that they can generate certificates with, feed in all the details which creates a CSR then fires off the request to CertSrv to issue the certificate.

I have all that working, but what I'd like to do is feed the clients NTLM through to the curl request so that only users who are permitted to issue X certificate can do so.
This also means I don't need to bake credentials into the script.

The page gets NTLM auth from the user with this:

```<code>$headers = getallheaders();

if(!isset($headers['Authorization']))
{
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: NTLM');
}
</code>```

and I can see the NTLM auth header, but I can't feed that into my curl request,
I even tried just setting the Authorization header to the value in the received headers but that doesn't work.

I figure it'd be difficult by design to stop people doing this sort of thing maliciously but is there actually a way around it?

Thanks for any help on this.

Body:
So not sure if this is actually feasible or not. But putting a page together for our techs that they can generate certificates with, feed in all the details which creates a CSR then fires off the request to CertSrv to issue the certificate.

I have all that working, but what I'd like to do is feed the clients NTLM through to the curl request so that only users who are permitted to issue X certificate can do so.
This also means I don't need to bake credentials into the script.

The page gets NTLM auth from the user with this:

$headers = getallheaders();

if(!isset($headers['Authorization']))
{
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: NTLM');
}

and I can see the NTLM auth header, but I can't feed that into my curl request,
I even tried just setting the Authorization header to the value in the received headers but that doesn't work.

I figure it'd be difficult by design to stop people doing this sort of thing maliciously but is there actually a way around it?

Thanks for any help on this.


问:
geolocation.getCurrentPosition() fails in sporadic "spurts"
I'm experiencing an issue in a React application with getCurrentPosition (example code below) where I will experience bouts of timeout failures.

```<code>navigator.geolocation.getCurrentPosition(
  p => console.log(p),
  e => console.log(e),
  {
    timeout: 7000,
    enableHighAccuracy: false,
    maximumAge: 1000 * 60 * 60 * 24
  }
)
</code>```

It's quite inconsistent, and succeeds a lot, but when it does happen, it will also occur when just pasting the command in the dev tools console in Chrome, Brave, and Firefox (tested only on MacOS so far), regardless of what domain I'm currently navigated to there. Also when it does fail it fails repeatedly, despite page refreshing.

Edit:
For clarification, the issue is sporadic and reproducible from the F12 console (literally was able to get it just now from this page; though had to reload once to see it fail), but within the codebase, it's used like the below

```<code>export function getBrowserLocation() {
  return new Promise((res, rej) => {
    navigator.geolocation.getCurrentPosition(res, rej, options)
  });
}

// inside a component
<button onClick={async () => {
    try {
      const location = await getBrowserLocation();
      // do something with location
    } catch (e) {
      // error handling e.g. console.log(e)
}}}>GetLocation</button>
</code>```

Body:
I'm experiencing an issue in a React application with getCurrentPosition (example code below) where I will experience bouts of timeout failures.

navigator.geolocation.getCurrentPosition(
  p => console.log(p),
  e => console.log(e),
  {
    timeout: 7000,
    enableHighAccuracy: false,
    maximumAge: 1000 * 60 * 60 * 24
  }
)

It's quite inconsistent, and succeeds a lot, but when it does happen, it will also occur when just pasting the command in the dev tools console in Chrome, Brave, and Firefox (tested only on MacOS so far), regardless of what domain I'm currently navigated to there. Also when it does fail it fails repeatedly, despite page refreshing.

Edit:
For clarification, the issue is sporadic and reproducible from the F12 console (literally was able to get it just now from this page; though had to reload once to see it fail), but within the codebase, it's used like the below

export function getBrowserLocation() {
  return new Promise((res, rej) => {
    navigator.geolocation.getCurrentPosition(res, rej, options)
  });
}

// inside a component
<button onClick={async () => {
    try {
      const location = await getBrowserLocation();
      // do something with location
    } catch (e) {
      // error handling e.g. console.log(e)
}}}>GetLocation</button>


问:
Running httpd and php-fpm under supervisord process in docker does not work
I have this set up where I'm trying to run httpd and php-fpm in a docker container via a supervisord process.

My supervisord.conf is like so:

```<code>[supervisord]
nodaemon=true

[program:httpd]
command=httpd -DFOREGROUND
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

</code>```

Here is my Dockerfile Entrypoint for the command:

```<code>ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"]
</code>```

Notice above that I'm not running supervisord in foreground mode. Does it need to run in the foreground?

I bring up the entire app with

```<code>docker-compose up -d
</code>```

In my dockerfile, the CMD is set to supervisord and I feed it the supervisord.conf file. The problem is, when I define both httpd and php-fpm in the supervisord.conf file, I find that supervisor fails to run the httpd program but is able to run php-fpm. I get this error:

```<code>2022-12-15 22:35:23,437 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-12-15 22:35:23,439 INFO supervisord started with pid 1
2022-12-15 22:35:24,443 INFO spawned: 'httpd' with pid 10
2022-12-15 22:35:24,445 INFO spawned: 'php-fpm' with pid 11
httpd (pid 11) already running
2022-12-15 22:35:24,537 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:25,540 INFO spawned: 'httpd' with pid 14
2022-12-15 22:35:25,540 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
httpd (pid 11) already running
2022-12-15 22:35:25,628 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:27,632 INFO spawned: 'httpd' with pid 15
httpd (pid 11) already running
2022-12-15 22:35:27,716 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:30,721 INFO spawned: 'httpd' with pid 16
httpd (pid 11) already running
2022-12-15 22:35:30,802 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:31,803 INFO gave up: httpd entered FATAL state, too many start retries too quickly
</code>```

But when I remove the php-fpm configuration from supervisord.conf, the app work fine. For some reason these two apps can't work together? The strange thing is that this used to work for me but all of a sudden after some code changes, it's not working anymore. I don't get much in the way of error messages. I just know that httpd will not start, but php-fpm does. Any idea what is causing this?

Another strange thing is that this will work like 1/10 times. Why is it intermittent?

And I know that for Docker it's good to have one process per container, but for my specific use-case, I need these two on the same container.

I tried all kinds of different options for the supervisord config, like setting the priority to be lower and turning off autorestat or setting the expected error code to be 1, with no change.

I read from PHPfpm and Nginx not working in Docker with Supervisord that apps that daemonize tell supervisord they they've exited, and thus supervisord counts this as the app failing. But as you can see in my config, I've ran the programs in the foreground, unless I have the syntax wrong. It's the same syntax I've used before though and it works.

Body:
I have this set up where I'm trying to run httpd and php-fpm in a docker container via a supervisord process.

My supervisord.conf is like so:

[supervisord]
nodaemon=true

[program:httpd]
command=httpd -DFOREGROUND
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

Here is my Dockerfile Entrypoint for the command:

ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"]

Notice above that I'm not running supervisord in foreground mode. Does it need to run in the foreground?

I bring up the entire app with

docker-compose up -d

In my dockerfile, the CMD is set to supervisord and I feed it the supervisord.conf file. The problem is, when I define both httpd and php-fpm in the supervisord.conf file, I find that supervisor fails to run the httpd program but is able to run php-fpm. I get this error:

2022-12-15 22:35:23,437 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-12-15 22:35:23,439 INFO supervisord started with pid 1
2022-12-15 22:35:24,443 INFO spawned: 'httpd' with pid 10
2022-12-15 22:35:24,445 INFO spawned: 'php-fpm' with pid 11
httpd (pid 11) already running
2022-12-15 22:35:24,537 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:25,540 INFO spawned: 'httpd' with pid 14
2022-12-15 22:35:25,540 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
httpd (pid 11) already running
2022-12-15 22:35:25,628 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:27,632 INFO spawned: 'httpd' with pid 15
httpd (pid 11) already running
2022-12-15 22:35:27,716 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:30,721 INFO spawned: 'httpd' with pid 16
httpd (pid 11) already running
2022-12-15 22:35:30,802 INFO exited: httpd (exit status 0; not expected)
2022-12-15 22:35:31,803 INFO gave up: httpd entered FATAL state, too many start retries too quickly

But when I remove the php-fpm configuration from supervisord.conf, the app work fine. For some reason these two apps can't work together? The strange thing is that this used to work for me but all of a sudden after some code changes, it's not working anymore. I don't get much in the way of error messages. I just know that httpd will not start, but php-fpm does. Any idea what is causing this?

Another strange thing is that this will work like 1/10 times. Why is it intermittent?

And I know that for Docker it's good to have one process per container, but for my specific use-case, I need these two on the same container.

I tried all kinds of different options for the supervisord config, like setting the priority to be lower and turning off autorestat or setting the expected error code to be 1, with no change.

I read from PHPfpm and Nginx not working in Docker with Supervisord that apps that daemonize tell supervisord they they've exited, and thus supervisord counts this as the app failing. But as you can see in my config, I've ran the programs in the foreground, unless I have the syntax wrong. It's the same syntax I've used before though and it works.


问:
Why don't fade out and fade in effects for music work in WPF?
```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace Summer
{
    public class AudioPlayer
    {
        public enum Repetition
        {
            ONCE,
            REPEAT
        }
        MediaPlayer MediaPlayer { get; } = new MediaPlayer();
        public string? SoundPath { get; set; }
        public double Volume { get; set; }
        public AudioPlayer() { }

        public void Play(Repetition repetition)
        {
            if(SoundPath != null)
            {
                MediaPlayer.Open(new Uri(SoundPath, UriKind.Relative));
                MediaPlayer.MediaEnded -= RepeatSound;
                if(repetition == Repetition.REPEAT)
                    MediaPlayer.MediaEnded += RepeatSound;
                GraduallyPlay();
            }
        }
        void GraduallyPlay()
        {
            double currentVolume = 0.005;
            MediaPlayer.Volume = currentVolume;
            MediaPlayer.Play();
            MediaPlayer.Dispatcher.InvokeAsync(async () =>
            {
                while ((currentVolume += 0.000005) <= Volume)
                {
                    MediaPlayer.Volume = currentVolume;
                    await Task.Delay(20);
                }
            });
        }

        void RepeatSound(object sender, EventArgs args)
        {
            MediaPlayer.Position = TimeSpan.Zero;
            MediaPlayer.Play();
        }

        public void Stop()
        {
            MediaPlayer.Dispatcher.BeginInvoke(async () =>
            {
                while (MediaPlayer.Volume >= 0)
                {
                    MediaPlayer.Volume -= 0.00005;
                    await Task.Delay(20);
                }
                MediaPlayer.Stop();
            });
        }

    }
}
</code>```

Hello, I have the following class for playing my audio clips. I want my music volume to fade out when I stop playing. I am using Dispatcher class to achieve this, however it does not work for some reason, only double currentVolume = 0.005; line is executed when I use Play method. When I use Stop method, it does not stop the music. Why is this happening?

Body:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace Summer
{
    public class AudioPlayer
    {
        public enum Repetition
        {
            ONCE,
            REPEAT
        }
        MediaPlayer MediaPlayer { get; } = new MediaPlayer();
        public string? SoundPath { get; set; }
        public double Volume { get; set; }
        public AudioPlayer() { }

        public void Play(Repetition repetition)
        {
            if(SoundPath != null)
            {
                MediaPlayer.Open(new Uri(SoundPath, UriKind.Relative));
                MediaPlayer.MediaEnded -= RepeatSound;
                if(repetition == Repetition.REPEAT)
                    MediaPlayer.MediaEnded += RepeatSound;
                GraduallyPlay();
            }
        }
        void GraduallyPlay()
        {
            double currentVolume = 0.005;
            MediaPlayer.Volume = currentVolume;
            MediaPlayer.Play();
            MediaPlayer.Dispatcher.InvokeAsync(async () =>
            {
                while ((currentVolume += 0.000005) <= Volume)
                {
                    MediaPlayer.Volume = currentVolume;
                    await Task.Delay(20);
                }
            });
        }

        void RepeatSound(object sender, EventArgs args)
        {
            MediaPlayer.Position = TimeSpan.Zero;
            MediaPlayer.Play();
        }

        public void Stop()
        {
            MediaPlayer.Dispatcher.BeginInvoke(async () =>
            {
                while (MediaPlayer.Volume >= 0)
                {
                    MediaPlayer.Volume -= 0.00005;
                    await Task.Delay(20);
                }
                MediaPlayer.Stop();
            });
        }

    }
}

Hello, I have the following class for playing my audio clips. I want my music volume to fade out when I stop playing. I am using Dispatcher class to achieve this, however it does not work for some reason, only double currentVolume = 0.005; line is executed when I use Play method. When I use Stop method, it does not stop the music. Why is this happening?


问:
How to inverse transform a 3rd order difference?
I'm trying to create a function that will do the inverse difference for 3rd order difference of a forecasted result. Currently, I have a function that will provide the inverse transform of the 2nd difference. Is there a way for me to edit this function to do the 3rd order difference?</p>
```<code>def invert_transformation(df_train, df_forecast, second_diff=False):
    """Revert back the differencing to get the forecast to original scale."""
    df_fc = df_forecast.copy()
    columns = df_train.columns
    for col in columns:
        # Roll back 2nd Diff
        if second_diff:
            df_fc[str(col)+'_1d'] = (df_train[col].iloc[-1]-df_train[col].iloc[-2]) + df_fc[str(col)+'_2d'].cumsum()
        # Roll back 1st Diff
        df_fc[str(col)+'_forecast'] = df_train[col].iloc[-1] + df_fc[str(col)+'_1d'].cumsum()
    return df_fc
</code>```

Body:
I'm trying to create a function that will do the inverse difference for 3rd order difference of a forecasted result. Currently, I have a function that will provide the inverse transform of the 2nd difference. Is there a way for me to edit this function to do the 3rd order difference?

def invert_transformation(df_train, df_forecast, second_diff=False):
    """Revert back the differencing to get the forecast to original scale."""
    df_fc = df_forecast.copy()
    columns = df_train.columns
    for col in columns:
        # Roll back 2nd Diff
        if second_diff:
            df_fc[str(col)+'_1d'] = (df_train[col].iloc[-1]-df_train[col].iloc[-2]) + df_fc[str(col)+'_2d'].cumsum()
        # Roll back 1st Diff
        df_fc[str(col)+'_forecast'] = df_train[col].iloc[-1] + df_fc[str(col)+'_1d'].cumsum()
    return df_fc


问:
I am getting expr syntax errors for a simple equations
here is the code:

```<code>lidarachynska@MacBook-Air-Lida ~ % cd rachynska
lidarachynska@MacBook-Air-Lida rachynska % vim bin/com2
lidarachynska@MacBook-Air-Lida rachynska % chmod a+x bin/com2
lidarachynska@MacBook-Air-Lida rachynska % PATH=$PATH:~/rachynska/bin
lidarachynska@MacBook-Air-Lida rachynska % com2
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
</code>```

I've tried two ways of writing expr in com2, but both of them didn't work

No1

```<code>a=`expr $3`
b=`expr $2 - $1`
c=`expr $2 + $1`
d=`expr $b \* $c`
a=`expr $d / 7`
echo $a
</code>```

No2

```<code>a=$(expr $3)
b=$(expr $2 - $1)
c=$(expr $2 + $1)
d=$(expr $b \* $c)
a=$(expr $d / 7)
echo $a
</code>```

Body:
here is the code:

lidarachynska@MacBook-Air-Lida ~ % cd rachynska
lidarachynska@MacBook-Air-Lida rachynska % vim bin/com2
lidarachynska@MacBook-Air-Lida rachynska % chmod a+x bin/com2
lidarachynska@MacBook-Air-Lida rachynska % PATH=$PATH:~/rachynska/bin
lidarachynska@MacBook-Air-Lida rachynska % com2
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error

I've tried two ways of writing expr in com2, but both of them didn't work

No1

a=`expr $3`
b=`expr $2 - $1`
c=`expr $2 + $1`
d=`expr $b \* $c`
a=`expr $d / 7`
echo $a

No2

a=$(expr $3)
b=$(expr $2 - $1)
c=$(expr $2 + $1)
d=$(expr $b \* $c)
a=$(expr $d / 7)
echo $a


问:
How to train string feature as word embedding vectors as part of a Linear Regression Tensorflow model?
How do I train string feature as word embedding vectors as part of a linear regression Tensorflow model? I found example online about how to uses Tensorflow to vectorize strings and use these vectors as the x-inputs to train the model like below:

```<code>tokenizer = Tokenizer(oov_token=oov_token,num_words=num_words)
tokenizer.fit_on_texts(sentences)
word_index = tokenizer.word_index
sequences = tokenizer.texts_to_sequences(sentences)
padded_sequences = pad_sequences(sequences, padding='post', maxlen=maxlen)

model = tf.keras.Sequential([
        tf.keras.layers.Embedding(num_words, embedding_dim, input_length=maxlen),
        tf.keras.layers.GlobalAveragePooling1D(),
        tf.keras.layers.Dense(32, activation='relu'),
        tf.keras.layers.Dropout(0.3),
        tf.keras.layers.Dense(5, activation="softmax")
    ])

</code>```

But I want to train the word embedding vector along with other features/x-inputs (integers, floats) and not only with word embedding vector like the example above... How should I do this? Is there a way to vectorize individual string so I can replace the columns (in my datset) that have string values with new columns that have vector values?

I want to train 17 features/x-inputs (including the word embedding feature) to produce 2 output features. I had prepared my train_data_set as below so far:

```<code>
import pandas as pd
import numpy as np

dataset = pd.read_sql_query(all_data.statement, engine)
train_dataset = dataset.sample(frac=0.8, random_state=0)
train_x_inputs = np.copy(train_dataset)
train_x_inputs = np.delete(train_x_inputs,[0,1,3,4,5,6],axis=1).astype(np.float32)
normalizer = tf.keras.layers.Normalization(axis=-1)
normalizer.adapt(train_x_inputs)

</code>```

I'm following this basic linear regression example from Tensorflow, so I'm thinking of building an ML model as below:

```<code>
def build_and_compile_model(norm):
  model = keras.Sequential([
      norm,
      layers.Dense(64, activation='relu'),
      layers.Dense(64, activation='relu'),
      layers.Dense(2)
  ])

  model.compile(loss='mean_absolute_error',
                optimizer=tf.keras.optimizers.Adam(0.001))
  return model

</code>```

But I really don't know how to fit the Embedding vectors into the model above...Or maybe Word Embedding is no need for my case, if so, could you recommend me the best method to convert string features into numerical values that I can use to train with Tensorflow Model? (Should I uses Label Encoder instead of Word Embedding?)

Thank you!

Body:
How do I train string feature as word embedding vectors as part of a linear regression Tensorflow model? I found example online about how to uses Tensorflow to vectorize strings and use these vectors as the x-inputs to train the model like below:

tokenizer = Tokenizer(oov_token=oov_token,num_words=num_words)
tokenizer.fit_on_texts(sentences)
word_index = tokenizer.word_index
sequences = tokenizer.texts_to_sequences(sentences)
padded_sequences = pad_sequences(sequences, padding='post', maxlen=maxlen)

model = tf.keras.Sequential([
        tf.keras.layers.Embedding(num_words, embedding_dim, input_length=maxlen),
        tf.keras.layers.GlobalAveragePooling1D(),
        tf.keras.layers.Dense(32, activation='relu'),
        tf.keras.layers.Dropout(0.3),
        tf.keras.layers.Dense(5, activation="softmax")
    ])

But I want to train the word embedding vector along with other features/x-inputs (integers, floats) and not only with word embedding vector like the example above... How should I do this? Is there a way to vectorize individual string so I can replace the columns (in my datset) that have string values with new columns that have vector values?

I want to train 17 features/x-inputs (including the word embedding feature) to produce 2 output features. I had prepared my train_data_set as below so far:

import pandas as pd
import numpy as np

dataset = pd.read_sql_query(all_data.statement, engine)
train_dataset = dataset.sample(frac=0.8, random_state=0)
train_x_inputs = np.copy(train_dataset)
train_x_inputs = np.delete(train_x_inputs,[0,1,3,4,5,6],axis=1).astype(np.float32)
normalizer = tf.keras.layers.Normalization(axis=-1)
normalizer.adapt(train_x_inputs)

I'm following this basic linear regression example from Tensorflow, so I'm thinking of building an ML model as below:

def build_and_compile_model(norm):
  model = keras.Sequential([
      norm,
      layers.Dense(64, activation='relu'),
      layers.Dense(64, activation='relu'),
      layers.Dense(2)
  ])

  model.compile(loss='mean_absolute_error',
                optimizer=tf.keras.optimizers.Adam(0.001))
  return model

But I really don't know how to fit the Embedding vectors into the model above...Or maybe Word Embedding is no need for my case, if so, could you recommend me the best method to convert string features into numerical values that I can use to train with Tensorflow Model? (Should I uses Label Encoder instead of Word Embedding?)

Thank you!


问:
ODBC ANSI_WARNINGS warning message is breaking stored procedures
I think ANSI warnings are somehow breaking my stored procedure calling, and I'm trying to figure out how to fix it.

DB Server:

MS SQL Server 2008
Client:

Ubuntu Bionic

unixODBC

Microsoft ODBC Driver 17 for SQL Server for Linux

nanodbc

I have a stored procedure that I am calling from a Linux machine. Somewhere in the stored procedure, there is a statement that causes the following warning:

Warning: Null value is eliminated by an aggregate or other SET operation.

This is because the author of the function did something like a count on a nullable column. Here's the stuff about that.

Here's a minimal example of a stored procedure that breaks:

```<code>USE [my_database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

create PROCEDURE [test_nanodbc]
AS
BEGIN
    SET NOCOUNT ON;

        select count(my_nullable_column) from Table_with_nullable_columns

        raiserror('fake error!',16,1)
END
</code>```

Here's the code that I'm running on the linux box:

```<code>try {
        nanodbc::connection connection(get_connection_string(),5);
        nanodbc::statement statement(connection);
        statement.timeout(5);
        prepare(statement,"{? = CALL [test_nanodbc]()};");
        int returnVal;
        statement.bind(0,&returnVal,nanodbc::statement::PARAM_RETURN);
        nanodbc::result r = statement.execute();

        print("returned" << returnVal);
    }
    catch(const std::exception& e) {
        print("Could not call procedure: " << e.what());
    }
</code>```

If the select statement in the stored procedure is commented out, the error will be raised as I'd expect.
However, if the select statement is there and the warning is present, the error will NOT be raised and the code has no idea that the c++ failed.

If I run the stored procedure in SQL Server management studio, I get the desired and expected output:

Warning: Null value is eliminated by an aggregate or other SET operation. Msg 50000, Level 16, State 1, Procedure test_nanodbc, Line 30 [Batch Start Line 2] fake error!

I don't really know odbc; I've just been using nanodbc, so I haven't really investigated much how it's doing stuff under the hood and am just delving into that. So maybe it's a nanodbc bug or something they haven't done or maybe it's a MS SQL server driver for linux bug. I tend to think a MS driver bug because of the output I got after turning debug messages on? It calls the function SQLExecute and it returns SQL_ERROR in the one case, but SQL_SUCCESS in the other.

Here's the output of nanodbc with debug messages on when the select statement causing the warning is commented out:

```<code>/path/to/nanodbc/nanodbc.cpp:759 SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:771 SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)NANODBC_ODBC_VERSION, SQL_IS_UINTEGER)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1021 SQLSetConnectAttr(dbc_, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1041 SQLDriverConnect(dbc_, 0, (NANODBC_SQLCHAR*)connection_string.c_str(), SQL_NTS, nullptr, 0, nullptr, SQL_DRIVER_NOPROMPT)
<-- rc: SQL_SUCCESS_WITH_INFO |
<-- rc: SQL_SUCCESS_WITH_INFO |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1395 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1439 SQLPrepare(stmt_, (NANODBC_SQLCHAR*)query.c_str(), (SQLINTEGER)query.size())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1838 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1895 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param_size, param.scale_, (SQLPOINTER)buffer.values_, value_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1658 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1676 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1682 SQLExecute(stmt_)
<-- rc: SQL_ERROR |
/path/to/nanodbc/nanodbc.cpp:369 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:387 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, sql_message.data(), (SQLSMALLINT)sql_message.size(), &total_bytes)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:369 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_NO_DATA |
/path/to/nanodbc/nanodbc.cpp:1358 SQLCancel(stmt_)
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1057 SQLDisconnect(dbc_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
1671142017.201946700[ERROR] /test_node: Could not call procedure: /path/to/nanodbc/nanodbc.cpp:1684: 0000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]fake error!
</code>```

Now here's the output with the statement that causes the null warning:

```<code>/path/to/nanodbc/nanodbc.cpp:759 SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:771 SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)NANODBC_ODBC_VERSION, SQL_IS_UINTEGER)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1021 SQLSetConnectAttr(dbc_, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1041 SQLDriverConnect(dbc_, 0, (NANODBC_SQLCHAR*)connection_string.c_str(), SQL_NTS, nullptr, 0, nullptr, SQL_DRIVER_NOPROMPT)
<-- rc: SQL_SUCCESS_WITH_INFO |
<-- rc: SQL_SUCCESS_WITH_INFO |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1395 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1439 SQLPrepare(stmt_, (NANODBC_SQLCHAR*)query.c_str(), (SQLINTEGER)query.size())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1838 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1895 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param_size, param.scale_, (SQLPOINTER)buffer.values_, value_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1658 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1676 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1682 SQLExecute(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2265 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2275 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1743 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2735 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2882 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS |
1671142773.036405035[ INFO] /test_node: returned -6
/path/to/nanodbc/nanodbc.cpp:1358 SQLCancel(stmt_)
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1057 SQLDisconnect(dbc_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
</code>```

Also curious: the return value for the procedure whenever there is an offending statment (that is, an ansi warning) is the return value that the procedure returned the last time it did not have a warning issued. So for example, if I change the proc to not raise an error nor do a bad select and run it, my c++ will run fine and will show returned 0. Then, if I add the offending select to the proc, whether I raise an exception or not, the return value shown by my c++ will be 0. However, if I change the proc to raise an error without an offending statement and return a value of -6, my c++ will catch the exception. Then, if I change the proc to have an offending select, my c++ will not throw an exception, but the return value will be -6, regardless of whether or not I raise an exception.

Body:
I think ANSI warnings are somehow breaking my stored procedure calling, and I'm trying to figure out how to fix it.

DB Server:

MS SQL Server 2008
Client:

Ubuntu Bionic

unixODBC

Microsoft ODBC Driver 17 for SQL Server for Linux

nanodbc

I have a stored procedure that I am calling from a Linux machine. Somewhere in the stored procedure, there is a statement that causes the following warning:

Warning: Null value is eliminated by an aggregate or other SET operation.

This is because the author of the function did something like a count on a nullable column. Here's the stuff about that.

Here's a minimal example of a stored procedure that breaks:

USE [my_database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

create PROCEDURE [test_nanodbc]
AS
BEGIN
    SET NOCOUNT ON;

        select count(my_nullable_column) from Table_with_nullable_columns

        raiserror('fake error!',16,1)
END

Here's the code that I'm running on the linux box:

try {
        nanodbc::connection connection(get_connection_string(),5);
        nanodbc::statement statement(connection);
        statement.timeout(5);
        prepare(statement,"{? = CALL [test_nanodbc]()};");
        int returnVal;
        statement.bind(0,&returnVal,nanodbc::statement::PARAM_RETURN);
        nanodbc::result r = statement.execute();

        print("returned" << returnVal);
    }
    catch(const std::exception& e) {
        print("Could not call procedure: " << e.what());
    }

If the select statement in the stored procedure is commented out, the error will be raised as I'd expect.
However, if the select statement is there and the warning is present, the error will NOT be raised and the code has no idea that the c++ failed.

If I run the stored procedure in SQL Server management studio, I get the desired and expected output:

Warning: Null value is eliminated by an aggregate or other SET operation. Msg 50000, Level 16, State 1, Procedure test_nanodbc, Line 30 [Batch Start Line 2] fake error!

I don't really know odbc; I've just been using nanodbc, so I haven't really investigated much how it's doing stuff under the hood and am just delving into that. So maybe it's a nanodbc bug or something they haven't done or maybe it's a MS SQL server driver for linux bug. I tend to think a MS driver bug because of the output I got after turning debug messages on? It calls the function SQLExecute and it returns SQL_ERROR in the one case, but SQL_SUCCESS in the other.

Here's the output of nanodbc with debug messages on when the select statement causing the warning is commented out:

/path/to/nanodbc/nanodbc.cpp:759 SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:771 SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)NANODBC_ODBC_VERSION, SQL_IS_UINTEGER)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1021 SQLSetConnectAttr(dbc_, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1041 SQLDriverConnect(dbc_, 0, (NANODBC_SQLCHAR*)connection_string.c_str(), SQL_NTS, nullptr, 0, nullptr, SQL_DRIVER_NOPROMPT)
<-- rc: SQL_SUCCESS_WITH_INFO |
<-- rc: SQL_SUCCESS_WITH_INFO |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1395 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1439 SQLPrepare(stmt_, (NANODBC_SQLCHAR*)query.c_str(), (SQLINTEGER)query.size())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1838 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1895 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param_size, param.scale_, (SQLPOINTER)buffer.values_, value_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1658 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1676 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1682 SQLExecute(stmt_)
<-- rc: SQL_ERROR |
/path/to/nanodbc/nanodbc.cpp:369 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:387 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, sql_message.data(), (SQLSMALLINT)sql_message.size(), &total_bytes)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:369 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_NO_DATA |
/path/to/nanodbc/nanodbc.cpp:1358 SQLCancel(stmt_)
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1057 SQLDisconnect(dbc_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
1671142017.201946700[ERROR] /test_node: Could not call procedure: /path/to/nanodbc/nanodbc.cpp:1684: 0000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]fake error!

Now here's the output with the statement that causes the null warning:

/path/to/nanodbc/nanodbc.cpp:759 SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:771 SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)NANODBC_ODBC_VERSION, SQL_IS_UINTEGER)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:791 SQLAllocHandle(SQL_HANDLE_DBC, env, &conn)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1021 SQLSetConnectAttr(dbc_, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1041 SQLDriverConnect(dbc_, 0, (NANODBC_SQLCHAR*)connection_string.c_str(), SQL_NTS, nullptr, 0, nullptr, SQL_DRIVER_NOPROMPT)
<-- rc: SQL_SUCCESS_WITH_INFO |
<-- rc: SQL_SUCCESS_WITH_INFO |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1395 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1368 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1439 SQLPrepare(stmt_, (NANODBC_SQLCHAR*)query.c_str(), (SQLINTEGER)query.size())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1838 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1895 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param_size, param.scale_, (SQLPOINTER)buffer.values_, value_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1658 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1676 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1457 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1682 SQLExecute(stmt_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2265 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2275 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1743 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2735 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:2882 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS |
1671142773.036405035[ INFO] /test_node: returned -6
/path/to/nanodbc/nanodbc.cpp:1358 SQLCancel(stmt_)
/path/to/nanodbc/nanodbc.cpp:1749 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:1057 SQLDisconnect(dbc_)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |
/path/to/nanodbc/nanodbc.cpp:747 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS |

Also curious: the return value for the procedure whenever there is an offending statment (that is, an ansi warning) is the return value that the procedure returned the last time it did not have a warning issued. So for example, if I change the proc to not raise an error nor do a bad select and run it, my c++ will run fine and will show returned 0. Then, if I add the offending select to the proc, whether I raise an exception or not, the return value shown by my c++ will be 0. However, if I change the proc to raise an error without an offending statement and return a value of -6, my c++ will catch the exception. Then, if I change the proc to have an offending select, my c++ will not throw an exception, but the return value will be -6, regardless of whether or not I raise an exception.


问:
Flutter Reset/Change keys in firebase_options.dart?
So i mistakenly pushed to github this file, the app is a test app I've made so no big deal.
But is there a way to reset the keys in this file and generated new ones to make the old ones invalid for this firebase app?
Or do i need to create a new app completely?</p>


问:
How can i get firebase user id with a future? Flutter
I'm trying to get current user id through a future but I'm getting this error

Error: The argument type 'User? Function()' can't be assigned to the parameter type 'Future?'

What am I doing wrong?

```<code>import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:chat_app/widgets/chat/message_bubble.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';

class Messages extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final auth = FirebaseAuth.instance;
    return FutureBuilder(
      future: FirebaseAuth.instance.currentUser,
      builder: (context, AsyncSnapshot<User> snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(
            child: CircularProgressIndicator(),
          );
        }
        return StreamBuilder<QuerySnapshot>(
            stream: FirebaseFirestore.instance
                .collection('chat')
                .orderBy(
                  'createdAt',
                  descending: true,
                )
                .snapshots(),
            builder: (ctx, chatSnapshot) {
              if (chatSnapshot.connectionState == ConnectionState.waiting) {
                return const Center(
                  child: CircularProgressIndicator(),
                );
              }
              final chatDocs = chatSnapshot.data!.docs;
              return ListView.builder(
                reverse: true,
                itemCount: chatDocs.length,
                itemBuilder: (ctx, index) => MessageBubble(
                  chatDocs[index]['text'],
                  chatDocs[index]['userId'] == snapshot.data!.uid,
                ),
              );
            });
      },
    );
  }
}
</code>```

I tried to google this error but I can't find anything at all.

Body:
I'm trying to get current user id through a future but I'm getting this error

Error: The argument type 'User? Function()' can't be assigned to the parameter type 'Future?'

What am I doing wrong?

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:chat_app/widgets/chat/message_bubble.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';

class Messages extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final auth = FirebaseAuth.instance;
    return FutureBuilder(
      future: FirebaseAuth.instance.currentUser,
      builder: (context, AsyncSnapshot<User> snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(
            child: CircularProgressIndicator(),
          );
        }
        return StreamBuilder<QuerySnapshot>(
            stream: FirebaseFirestore.instance
                .collection('chat')
                .orderBy(
                  'createdAt',
                  descending: true,
                )
                .snapshots(),
            builder: (ctx, chatSnapshot) {
              if (chatSnapshot.connectionState == ConnectionState.waiting) {
                return const Center(
                  child: CircularProgressIndicator(),
                );
              }
              final chatDocs = chatSnapshot.data!.docs;
              return ListView.builder(
                reverse: true,
                itemCount: chatDocs.length,
                itemBuilder: (ctx, index) => MessageBubble(
                  chatDocs[index]['text'],
                  chatDocs[index]['userId'] == snapshot.data!.uid,
                ),
              );
            });
      },
    );
  }
}

I tried to google this error but I can't find anything at all.


问:
How to append page url to link in Wordpress
How do I add a link to a page in wordpress and it automatically appends the page url to it dynamically?

I basically want to add a link example www.link.com  and when i add the link to any page it will automatically append the page url to it so it looks like this  www.link.com/my-page-title to the reader.

Thanks
Red


问:
Google Colab Not Displaying Plots or Pandas Dataframe
Colab is not displaying plots or pandas dataframes in any of my browsers (Chrome, Firefox, Edge).  For example, display(df) gives the following error in a pop-up window:

```<code>Error
Could not load the JavaScript files needed to display output.
This is probably because your Google account login access has expired or because third-party cookies are not allowed by your browser.

Please reload this page.
</code>```

Arrays, Series, etc. will all display normally.  print(df) will also display the dataframe normally in a text-only format.  Also, running the same notebooks through binder (mybinder.org) displays the dataframes normally in all browsers.  I added [*.]googleusercontent.com to "allowed" third party cookies...no luck.  This issue seems isolated to displaying advanced objects in Colab.

Any solutions out there?  Appreciate the help.

Body:
Colab is not displaying plots or pandas dataframes in any of my browsers (Chrome, Firefox, Edge).  For example, display(df) gives the following error in a pop-up window:

Error
Could not load the JavaScript files needed to display output.
This is probably because your Google account login access has expired or because third-party cookies are not allowed by your browser.

Please reload this page.

Arrays, Series, etc. will all display normally.  print(df) will also display the dataframe normally in a text-only format.  Also, running the same notebooks through binder (mybinder.org) displays the dataframes normally in all browsers.  I added [*.]googleusercontent.com to "allowed" third party cookies...no luck.  This issue seems isolated to displaying advanced objects in Colab.

Any solutions out there?  Appreciate the help.


问:
Azure Data Studio Authentication Error logging into Synapse Serverless Pool
Am trying to login into Synapse Serverless from Azure Data Studio with Azure Active Directory - Universal with MFA Support, but unable to login throws error on Account selection in browser

"Unidentified error with azure authentication"

Update: changed to 'Device Authentication' and was able to authenticate myself in browser with User Code, but still Azure Data Studio doesn't recognise :(

Also can successfully login from SSMS (SQL Server Management Studio) with both SQL Login and Azure Active Directory :)

But works fine with login in Azure Storage Explorer

Any clues?


问:
Convert Alicat lib from python 3 to python 2
I am new at python and for work reason I have to use python 2. I found a library Alicat that I need to use but it only works for python 3, would it be difficult to try to convert it?

I've been trying to read the code but as of today it is hard for me to try converting it for python 2 because obviously now every documentation is more python 3 oriented


问:
Creating month to month visualization in Power BI when associated dates not provided
Below is a small representative sample of data that I have loaded into Power BI to display a visualization.  The "Monthly Savings" data changes with time. And whatever those numbers are at the end of each month, I will like to display their total using some sort of bar chart - so that we will have a bar chart that shows that totals value for January, February, March, etc. of the year 2023 (and same thing for subsequent years moving forward)

But the below data will not come with any date/time information. I just need to know that at each month end, I need to report what those month end totals are. And with time the totals will reflect in the bar chart showing Monthly Savings by Month

Question: How do I associate the month-end data to month-end dates in Power BI, if the source data does not come with any date/time information?


问:
Autopct in legend labels showing values as percentages, not actual percentages
I created a pie chart using lists, and since the graph itself is cramped I want to display the labels and percentages in a legend to the side. Everything is showing up, the only issue is that my percentages are just the numerical values in my list as percents (eg. "236%"), not the actual percent of 100 each item constituteg.

Here is my current code

grades = ["8th grade or less","High school graduate or GED completed",
         "Some college credit, but no degree", "9 - 12th grade, no diploma",
         "Bachelor’s degree", "Master’s degree", "Associate degree",
         "Unknown", "Doctorate or professional degree"]
deaths = [45, 236, 106, 106, 82, 24, 58, 11, 6]

labels = ['%s, %1.1f %%' % (g, d) for g, d in zip(grades, deaths)]
fig1, ax1 = plt.subplots()
ax1.pie(deaths)
plt.legend(labels = labels, bbox_to_anchor = (1.05,1))
plt.show()
```

My resulting pie chart and legend

Body:
I created a pie chart using lists, and since the graph itself is cramped I want to display the labels and percentages in a legend to the side. Everything is showing up, the only issue is that my percentages are just the numerical values in my list as percents (eg. "236%"), not the actual percent of 100 each item constituteg.

Here is my current code

grades = ["8th grade or less","High school graduate or GED completed",
         "Some college credit, but no degree", "9 - 12th grade, no diploma",
         "Bachelor’s degree", "Master’s degree", "Associate degree",
         "Unknown", "Doctorate or professional degree"]
deaths = [45, 236, 106, 106, 82, 24, 58, 11, 6]

labels = ['%s, %1.1f %%' % (g, d) for g, d in zip(grades, deaths)]
fig1, ax1 = plt.subplots()
ax1.pie(deaths)
plt.legend(labels = labels, bbox_to_anchor = (1.05,1))
plt.show()

My resulting pie chart and legend


问:
How to overwrite a saved field value with Gravity forms
When using gravity form's "Save And Continue", the gform_field_value hook does not overwrite saved data.

For example if the field user ID, is saved with a value of 4, but then a user with the value of 2 visits the saved form, I would like this field to update to 2.

I need a field that always outputs the value from a gform_field_value function, regardless of what the previously saved value might be.

Trying this on a text field does not work at all:

```<code>add_filter( 'gform_field_value_debug', 'gform_populate_debug' );
function gform_populate_debug( $value ) {
    return "debug";
}
</code>```

I noticed that using a radio or checkbox field almost does the trick, but the isSelected key does not work when the value changes, because the choice isSelected property is only used when the $_POST is empty.  So it requires the user to take action again, and I need this to work with the end-user doing anything.

```<code>add_filter( 'gform_pre_render_69', 'populate_new_userrole' );
add_filter( 'gform_pre_validation_69', 'populate_new_userrole' );
add_filter( 'gform_pre_submission_filter_69', 'populate_new_userrole' );
add_filter( 'gform_admin_pre_render_69', 'populate_new_userrole' );
function populate_new_userrole( $form ) {

    foreach( $form['fields'] as &$field )  {

        $field_id = 6;
        if ( $field->id != $field_id ) {
            continue;
        }

        $user = wp_get_current_user();
        $role = $user->roles;
        $commaList = implode(', ', $role);

        $choices[] = array( 'text' => $commaList, 'value' => $commaList, 'isSelected' => true );

        $field->choices = $choices;

    }

    print_r($choices);

    return $form;
}
</code>```

Any ideas?

Body:
When using gravity form's "Save And Continue", the gform_field_value hook does not overwrite saved data.

For example if the field user ID, is saved with a value of 4, but then a user with the value of 2 visits the saved form, I would like this field to update to 2.

I need a field that always outputs the value from a gform_field_value function, regardless of what the previously saved value might be.

Trying this on a text field does not work at all:

add_filter( 'gform_field_value_debug', 'gform_populate_debug' );
function gform_populate_debug( $value ) {
    return "debug";
}

I noticed that using a radio or checkbox field almost does the trick, but the isSelected key does not work when the value changes, because the choice isSelected property is only used when the $_POST is empty.  So it requires the user to take action again, and I need this to work with the end-user doing anything.

add_filter( 'gform_pre_render_69', 'populate_new_userrole' );
add_filter( 'gform_pre_validation_69', 'populate_new_userrole' );
add_filter( 'gform_pre_submission_filter_69', 'populate_new_userrole' );
add_filter( 'gform_admin_pre_render_69', 'populate_new_userrole' );
function populate_new_userrole( $form ) {

    foreach( $form['fields'] as &$field )  {

        $field_id = 6;
        if ( $field->id != $field_id ) {
            continue;
        }

        $user = wp_get_current_user();
        $role = $user->roles;
        $commaList = implode(', ', $role);

        $choices[] = array( 'text' => $commaList, 'value' => $commaList, 'isSelected' => true );

        $field->choices = $choices;

    }

    print_r($choices);

    return $form;
}

Any ideas?


问:
no python application found, check your startup logs for errors
My file structure looks like this:

```<code>nginx
`-- default.conf
mysql
client
server
|-- app
|   |-- db
|   |-- lib
|   |-- __init__.py
`-- app.ini
`-- dev.Dockerfile
`-- main.py
`-- requirements.txt
dev.yml
</code>```

this is my 'app.ini' file:

```<code>[uwsgi]
wsgi-file: /app/main.py
uid = www-data
gid = www-data
socket = :5555
processes = 1
threads = 1
master = true
chmod-socket = 660
vacuum = true
callable = app
die-on-term = true
</code>```

my 'main.py' file:

```<code>from app import create_app

app = create_app()

if __name__ == '__main__':
    app.run('0.0.0.0', 5000, False)
</code>```

my 'dev.Dockerfile' file:

```<code>FROM python:3.9.16

WORKDIR /app

COPY requirements.txt .
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN /usr/local/bin/python -m pip install -r requirements.txt

RUN  cd /app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

CMD ["uwsgi", "app.ini"]
</code>```

my 'app.init.py' file:

```<code>#!/usr/bin/python

import os
from datetime import timedelta
from flask import Flask, jsonify
from app.db import db, mm
from app.resourses import initialize_routes
from app.resourses.auth import AuthError
from app.error_handeler import handler
from app.lib import get_db_string
from dotenv import load_dotenv
from flask_cors import CORS
from app.db.models import get_user_by_id
from app.lib import set_default_companies

BASE_DIR = os.path.abspath(os.path.dirname(__file__))

if os.environ.get('ENV') == 'development':
    load_dotenv(f'{os.getcwd()}/.env.dev', override=True)
else:
    load_dotenv(f'{os.getcwd()}/.env', override=True)

def create_app():

    api = Flask(__name__)

    api.config['JWT_PRIVATE_KEY'] = os.environ.get("PRIVATE_KEY")
    api.config['JWT_PUBLIC_KEY'] = os.environ.get("PUB_KEY")
    api.config["JWT_SECRET_KEY"] = os.environ.get("JWT_SECRET")
    api.config["JWT_HEADER_NAME"] = "access_token"
    api.config["JWT_HEADER_TYPE"] = ""
    api.config["JWT_TOKEN_LOCATION"] = ["headers", "cookies", "json"]
    api.config["JWT_COOKIE_SECURE"] = os.environ.get('FLASK_ENV') == 'production'
    api.config['PROPAGATE_EXCEPTIONS'] = True
    api.config["JWT_ACCESS_TOKEN_EXPIRES"] = timedelta(minutes=1)
    api.config["JWT_REFRESH_TOKEN_EXPIRES"] = timedelta(days=90)
    api.config['JWT_ACCESS_COOKIE_PATH'] = '/api/'
    api.config['JWT_REFRESH_COOKIE_PATH'] = '/token/refresh'
    api.config['JWT_ACCESS_COOKIE_NAME'] = 'access_token'
    api.config['JWT_REFRESH_COOKIE_NAME'] = 'refresh_token'
    api.config['JWT_COOKIE_CSRF_PROTECT'] = False
    api.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    api.config["PROPAGATE_EXCEPTIONS"] = True
    api.config['SQLALCHEMY_DATABASE_URI'] = get_db_string()
    api.config['SQLALCHEMY_ECHO'] = True
    api.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
        'pool_size': 100,
    }
    api.config['SQLALCHEMY_POOL_SIZE'] = 100
    api.config['SQLALCHEMY_POOL_RECYCLE'] = 280
    api.secret_key = os.environ.get('FLASK_SECRET')

    db.init_app(api)
    mm.mm.init_app(api)
    with api.app_context():
        db.create_all()
        set_default_companies()

    handler(api)
    initialize_routes(api)
    CORS(api)
    api.config['TESTING'] = os.environ.get("TEST_MODE", default=False)

    @api.errorhandler(AuthError)
    def handle_auth_error(ex):
        response = jsonify(ex.error)
        response.status_code = ex.status_code
        return response
    return api

if __name__ == '__main__':
    create_app().run(port=5000, debug=True)

</code>```

my 'dev.yml' file:

```<code>version: "3.7"

services:

  nginx:
    build:
      context: ./nginx
      dockerfile: ./dev.Dockerfile
    container_name: nginx
    networks:
      - nginx_network
    restart: always
    depends_on:
      - backend
    ports:
      - "80:80"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./client/build:/usr/share/nginx/html

  db:
    container_name: db
    build: ./mysql
    restart: always
    command: '--authentication_policy=mysql_native_password'
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent" ]
      interval: 3s
      retries: 5
      start_period: 30s

    networks:
      mysql_net:
        aliases:
            - db
    ports:
      - "3306:3306"
    volumes:
      - ./data/data_volume:/var/lib/mysql

  backend:
    build:
      context: ./server
      dockerfile: ./dev.Dockerfile
    container_name: server
    restart: always
    networks:
      mysql_net:
        aliases:
          - server
      nginx_network:
        aliases:
          - server
    links:
      - db
    depends_on:
      - db
    env_file:
      - ./server/.env
    ports:
      - "5555:5555"
    volumes:
      - ./server:/app

  #  frontend:
  #    build: /app/client
  #    container_name: client
  #    restart: always
  #    volumes:
  #      - /app/nginx/html:/usr/share/nginx/html

  adminer:
    container_name: adminer
    image: adminer
    restart: always
    networks:
      mysql_net:
        aliases:
          - adminer
      nginx_network:
        aliases:
          - adminer
    ports:
      - "8080:8080"

volumes:
  data_volume:
    driver: local

networks:
  nginx_network:
    driver: bridge
  mysql_net:
    driver: bridge

</code>```

my 'default.conf' file:

```<code>underscores_in_headers on;

server {
    listen 0.0.0.0:80;
    server_name localhost;

#     location /api {
#         proxy_pass_header http://server:5000;
#         proxy_pass http://server:5000;
#     }

    location /api {
        include uwsgi_params;
        add_header  Content-Type    application/json;
        uwsgi_pass server:5555;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 300s;
        proxy_connect_timeout 75s;
    }

    location /adminer {
        proxy_set_header X-Forwarded-Prefix "/adminer";
        proxy_pass http://adminer:8080;
    }

   location ~* \.(?:css|js|json)$ {
        root /usr/share/nginx/html;
        try_files $uri $uri/;
    }

    location / {
        root /usr/share/nginx/html;
        index index.html;
        try_files $uri $uri/ /index.html =404;
    }
}

</code>```

Whenever I start the server,
docker-compose -f dev.yml up
I get the following output:

```<code>.....

db              | 2022-12-15T22:37:45.439021Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
db              | 2022-12-15T22:37:45.439178Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.28'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
server  | --- no python application found, check your startup logs for errors ---
server  | [pid: 7|app: -1|req: -1/1] 172.19.0.1 () {64 vars in 1258 bytes} [Thu Dec 15 22:45:44 2022] POST /api/users/login => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
nginx           | 172.19.0.1 - - [15/Dec/2022:22:45:44 +0000] "POST /api/users/login HTTP/1.1" 500 32 "http://localhost/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "-"

</code>```

Frontend works fine, but as soon as i send any requests for backend I get a status code 500

All solutions I was able to find do not help. Any suggestions? Thanks in advance...

I cannot find any info how to find startup log, so in app.ini i added line: logto = %n.log, this is output of file app.log (only one new)

```<code>*** Starting uWSGI 2.0.21 (64bit) on [Fri Dec 16 18:47:11 2022] ***
compiled with version: 10.2.1 20210110 on 15 December 2022 21:55:56
os: Linux-5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022
nodename: 5338311c006d
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 6
current working directory: /app
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :5555 fd 3
Python version: 3.9.16 (main, Dec  8 2022, 02:40:11)  [GCC 10.2.1 20210110]
Python main interpreter initialized at 0x55569cd5a090
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145840 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 7, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/1] 172.19.0.1 () {64 vars in 1239 bytes} [Fri Dec 16 18:47:51 2022] POST /api/users/login => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
</code>```

Body:
My file structure looks like this:

nginx
`-- default.conf
mysql
client
server
|-- app
|   |-- db
|   |-- lib
|   |-- __init__.py
`-- app.ini
`-- dev.Dockerfile
`-- main.py
`-- requirements.txt
dev.yml

this is my 'app.ini' file:

[uwsgi]
wsgi-file: /app/main.py
uid = www-data
gid = www-data
socket = :5555
processes = 1
threads = 1
master = true
chmod-socket = 660
vacuum = true
callable = app
die-on-term = true

my 'main.py' file:

from app import create_app

app = create_app()

if __name__ == '__main__':
    app.run('0.0.0.0', 5000, False)

my 'dev.Dockerfile' file:

FROM python:3.9.16

WORKDIR /app

COPY requirements.txt .
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN /usr/local/bin/python -m pip install -r requirements.txt

RUN  cd /app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

CMD ["uwsgi", "app.ini"]

my 'app.init.py' file:

#!/usr/bin/python

import os
from datetime import timedelta
from flask import Flask, jsonify
from app.db import db, mm
from app.resourses import initialize_routes
from app.resourses.auth import AuthError
from app.error_handeler import handler
from app.lib import get_db_string
from dotenv import load_dotenv
from flask_cors import CORS
from app.db.models import get_user_by_id
from app.lib import set_default_companies

BASE_DIR = os.path.abspath(os.path.dirname(__file__))

if os.environ.get('ENV') == 'development':
    load_dotenv(f'{os.getcwd()}/.env.dev', override=True)
else:
    load_dotenv(f'{os.getcwd()}/.env', override=True)

def create_app():

    api = Flask(__name__)

    api.config['JWT_PRIVATE_KEY'] = os.environ.get("PRIVATE_KEY")
    api.config['JWT_PUBLIC_KEY'] = os.environ.get("PUB_KEY")
    api.config["JWT_SECRET_KEY"] = os.environ.get("JWT_SECRET")
    api.config["JWT_HEADER_NAME"] = "access_token"
    api.config["JWT_HEADER_TYPE"] = ""
    api.config["JWT_TOKEN_LOCATION"] = ["headers", "cookies", "json"]
    api.config["JWT_COOKIE_SECURE"] = os.environ.get('FLASK_ENV') == 'production'
    api.config['PROPAGATE_EXCEPTIONS'] = True
    api.config["JWT_ACCESS_TOKEN_EXPIRES"] = timedelta(minutes=1)
    api.config["JWT_REFRESH_TOKEN_EXPIRES"] = timedelta(days=90)
    api.config['JWT_ACCESS_COOKIE_PATH'] = '/api/'
    api.config['JWT_REFRESH_COOKIE_PATH'] = '/token/refresh'
    api.config['JWT_ACCESS_COOKIE_NAME'] = 'access_token'
    api.config['JWT_REFRESH_COOKIE_NAME'] = 'refresh_token'
    api.config['JWT_COOKIE_CSRF_PROTECT'] = False
    api.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    api.config["PROPAGATE_EXCEPTIONS"] = True
    api.config['SQLALCHEMY_DATABASE_URI'] = get_db_string()
    api.config['SQLALCHEMY_ECHO'] = True
    api.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
        'pool_size': 100,
    }
    api.config['SQLALCHEMY_POOL_SIZE'] = 100
    api.config['SQLALCHEMY_POOL_RECYCLE'] = 280
    api.secret_key = os.environ.get('FLASK_SECRET')

    db.init_app(api)
    mm.mm.init_app(api)
    with api.app_context():
        db.create_all()
        set_default_companies()

    handler(api)
    initialize_routes(api)
    CORS(api)
    api.config['TESTING'] = os.environ.get("TEST_MODE", default=False)

    @api.errorhandler(AuthError)
    def handle_auth_error(ex):
        response = jsonify(ex.error)
        response.status_code = ex.status_code
        return response
    return api

if __name__ == '__main__':
    create_app().run(port=5000, debug=True)

my 'dev.yml' file:

version: "3.7"

services:

  nginx:
    build:
      context: ./nginx
      dockerfile: ./dev.Dockerfile
    container_name: nginx
    networks:
      - nginx_network
    restart: always
    depends_on:
      - backend
    ports:
      - "80:80"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./client/build:/usr/share/nginx/html

  db:
    container_name: db
    build: ./mysql
    restart: always
    command: '--authentication_policy=mysql_native_password'
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent" ]
      interval: 3s
      retries: 5
      start_period: 30s

    networks:
      mysql_net:
        aliases:
            - db
    ports:
      - "3306:3306"
    volumes:
      - ./data/data_volume:/var/lib/mysql

  backend:
    build:
      context: ./server
      dockerfile: ./dev.Dockerfile
    container_name: server
    restart: always
    networks:
      mysql_net:
        aliases:
          - server
      nginx_network:
        aliases:
          - server
    links:
      - db
    depends_on:
      - db
    env_file:
      - ./server/.env
    ports:
      - "5555:5555"
    volumes:
      - ./server:/app

  #  frontend:
  #    build: /app/client
  #    container_name: client
  #    restart: always
  #    volumes:
  #      - /app/nginx/html:/usr/share/nginx/html

  adminer:
    container_name: adminer
    image: adminer
    restart: always
    networks:
      mysql_net:
        aliases:
          - adminer
      nginx_network:
        aliases:
          - adminer
    ports:
      - "8080:8080"

volumes:
  data_volume:
    driver: local

networks:
  nginx_network:
    driver: bridge
  mysql_net:
    driver: bridge

my 'default.conf' file:

underscores_in_headers on;

server {
    listen 0.0.0.0:80;
    server_name localhost;

#     location /api {
#         proxy_pass_header http://server:5000;
#         proxy_pass http://server:5000;
#     }

    location /api {
        include uwsgi_params;
        add_header  Content-Type    application/json;
        uwsgi_pass server:5555;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 300s;
        proxy_connect_timeout 75s;
    }

    location /adminer {
        proxy_set_header X-Forwarded-Prefix "/adminer";
        proxy_pass http://adminer:8080;
    }

   location ~* \.(?:css|js|json)$ {
        root /usr/share/nginx/html;
        try_files $uri $uri/;
    }

    location / {
        root /usr/share/nginx/html;
        index index.html;
        try_files $uri $uri/ /index.html =404;
    }
}

Whenever I start the server,
docker-compose -f dev.yml up
I get the following output:

.....

db              | 2022-12-15T22:37:45.439021Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
db              | 2022-12-15T22:37:45.439178Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.28'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
server  | --- no python application found, check your startup logs for errors ---
server  | [pid: 7|app: -1|req: -1/1] 172.19.0.1 () {64 vars in 1258 bytes} [Thu Dec 15 22:45:44 2022] POST /api/users/login => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
nginx           | 172.19.0.1 - - [15/Dec/2022:22:45:44 +0000] "POST /api/users/login HTTP/1.1" 500 32 "http://localhost/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "-"

Frontend works fine, but as soon as i send any requests for backend I get a status code 500

All solutions I was able to find do not help. Any suggestions? Thanks in advance...

I cannot find any info how to find startup log, so in app.ini i added line: logto = %n.log, this is output of file app.log (only one new)

*** Starting uWSGI 2.0.21 (64bit) on [Fri Dec 16 18:47:11 2022] ***
compiled with version: 10.2.1 20210110 on 15 December 2022 21:55:56
os: Linux-5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022
nodename: 5338311c006d
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 6
current working directory: /app
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :5555 fd 3
Python version: 3.9.16 (main, Dec  8 2022, 02:40:11)  [GCC 10.2.1 20210110]
Python main interpreter initialized at 0x55569cd5a090
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145840 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 7, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/1] 172.19.0.1 () {64 vars in 1239 bytes} [Fri Dec 16 18:47:51 2022] POST /api/users/login => generated 21 bytes in 1 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)


问:
gsap and scroll trigger glitch while scrolling
while scrolling it is working but there is come glitch while scrolling I know where problem is coming with the text it is going smooth but when I put image in second section it start glitching but it is working I tried to fixed it but it is glitching I don't the solution for it please fix this issue if anyone knows the solution

code

html

```<code>    <div class="support-bg"></div>
    <div class="block">
        <div id="mainCardGroup" class="mainCard">
            <div class="bestUiGroup">
                <p class="hero-text bgBestIn">demo of</p>
                <p class="hero-text classText">scale</p>
                <p class="hero-text uiText">Animation</p>
            </div>
            <div class="bestUiDesignSec">
                <div class="uisImgs">
                    <img class="uiImg1 uiImgGroup greatManImg1" src="./Assets/Shape-1.png" width="380" />
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js" integrity="sha512-gmwBmiTVER57N3jYS3LinA9eb8aHrJua5iQD7yqYCKa5x6Jjc7VDVaEA0je0Lu0bP9j7tEjV3+1qUm6loO99Kw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/ScrollTrigger.min.js" integrity="sha512-tHvUcUQYi35zApvAa5TNR3fNhBQkVtkmWKfacnpxmix4/VTGz1lGjIVyLMp7gLgAvg+aKJjnVKokXJNS5GZ+/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/TextPlugin.min.js" integrity="sha512-kxpzL+7fsRR+rSVOZgukbSRNHafu/lT7F1pcHrHYcEtF+3uSEgdfaoYnyuvwolK6WrGZpCsd6I5msXTsPXTk+A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="./gsap.js"></script>
</body>
</html>
</code>```

css section

```<code>body {
    background-color: cornflowerblue;
    height: 1550px;
}

.support-bg {
    background-color: #4299e1;
    height: 700px;
}

.mainCard {
    height: 721px !important;
    width: 510px !important;
    border-radius: 34px;
    background-color: aliceblue;
}

.block {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 3000px;
}

.uiTextAm {

    text-align: center;
    font-family: 'Hachi Maru Pop', cursive;
    font-style: normal;
    font-weight: 500;
    font-size: 32px;
    line-height: 20px;
}

.bestUiGroup {
    text-align: center;
    position: absolute;
    top: 30%;
    left: 45%;
    margin: -50px 0 0 -50px;
}

.bgBestIn {
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #38b2ac;
    --gradient-from-color: #4299e1;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(66, 153, 225, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.classText {
    margin-top: -45px;
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #ed64a6;
    --gradient-from-color: #7f9cf5;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(127, 156, 245, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.uiText {
    margin-top: -42px;
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #ed8936;
    --gradient-from-color: #e53e3e;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(229, 62, 62, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.greatManSvg {
    left: 30%;
}

.bestUiDesignSec {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.greatManSvg {
    margin-top: 100px;
}

.triangleElementUi {
    left: 120px;
    width: 100px;
    transform: rotate(20deg);
    position: relative;
}

.linesElementUi {
    position: relative;
    top: 216px;
    left: -10px;
}

.circleElementUi {
    position: absolute;
    z-index: -1;
    width: 350px;
    left: -50px;
    ;
}

.uisImgs {
    position: relative;
    padding-top: 33px;
    padding-left: 60px;
}
</code>```

javascript section

```<code>gsap.registerPlugin(ScrollTrigger);

const tl = gsap.timeline( {
  scrollTrigger: {
    trigger: "#mainCardGroup",
    start: "top top",
    end: "bottom center",
    pin: true,
    scrub: true,
    markers: true,
  }
})
tl.fromTo(
  ".hero-text",
  { y: "50px", opacity: 0 },
  { y: "0px", opacity: 1, stagger: 0.5 },
  "+=1"
)
.to(".hero-text", { opacity: 0 }, "+=1")
.from(".greatManImg1", {scale: 5, opacity: 0, duration: 3}, "+=1")
</code>```

Body:
while scrolling it is working but there is come glitch while scrolling I know where problem is coming with the text it is going smooth but when I put image in second section it start glitching but it is working I tried to fixed it but it is glitching I don't the solution for it please fix this issue if anyone knows the solution

code

html

demo of

scale

Animation

css section

body {
    background-color: cornflowerblue;
    height: 1550px;
}

.support-bg {
    background-color: #4299e1;
    height: 700px;
}

.mainCard {
    height: 721px !important;
    width: 510px !important;
    border-radius: 34px;
    background-color: aliceblue;
}

.block {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 3000px;
}

.uiTextAm {

    text-align: center;
    font-family: 'Hachi Maru Pop', cursive;
    font-style: normal;
    font-weight: 500;
    font-size: 32px;
    line-height: 20px;
}

.bestUiGroup {
    text-align: center;
    position: absolute;
    top: 30%;
    left: 45%;
    margin: -50px 0 0 -50px;
}

.bgBestIn {
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #38b2ac;
    --gradient-from-color: #4299e1;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(66, 153, 225, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.classText {
    margin-top: -45px;
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #ed64a6;
    --gradient-from-color: #7f9cf5;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(127, 156, 245, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.uiText {
    margin-top: -42px;
    font-size: 50px;
    font-weight: 700;
    font-family: 'Kaushan Script', cursive;
    color: transparent;
    --gradient-to-color: #ed8936;
    --gradient-from-color: #e53e3e;
    --gradient-color-stops: var(--gradient-from-color),var(--gradient-to-color, rgba(229, 62, 62, 0));
    background-image: linear-gradient(to right,var(--gradient-color-stops));
    background-clip: text;
}

.greatManSvg {
    left: 30%;
}

.bestUiDesignSec {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.greatManSvg {
    margin-top: 100px;
}

.triangleElementUi {
    left: 120px;
    width: 100px;
    transform: rotate(20deg);
    position: relative;
}

.linesElementUi {
    position: relative;
    top: 216px;
    left: -10px;
}

.circleElementUi {
    position: absolute;
    z-index: -1;
    width: 350px;
    left: -50px;
    ;
}

.uisImgs {
    position: relative;
    padding-top: 33px;
    padding-left: 60px;
}

javascript section

gsap.registerPlugin(ScrollTrigger);

const tl = gsap.timeline( {
  scrollTrigger: {
    trigger: "#mainCardGroup",
    start: "top top",
    end: "bottom center",
    pin: true,
    scrub: true,
    markers: true,
  }
})
tl.fromTo(
  ".hero-text",
  { y: "50px", opacity: 0 },
  { y: "0px", opacity: 1, stagger: 0.5 },
  "+=1"
)
.to(".hero-text", { opacity: 0 }, "+=1")
.from(".greatManImg1", {scale: 5, opacity: 0, duration: 3}, "+=1")


问:
Recoding non-mutually exclusive variable categories with grepl()
When I try to use this code to recode non - mutually exclusive variable categories, it does not work how I would like. For example, the post with the caption, "this post is about both a dog and space" could go in either 'animal_post' or 'other_post'. However, no matter what it always codes it as an 'animal_post' - as seen in code block 1. It only recodes as 'other_post' if I switch the order of the recode instructions itself - as seen in code block 2. Is there a way to recode non-mutually exclusive data without it defaulting to the first option?</p>
```<code>#Code block 1

post_caption <- c("This post is about a dog", "This post is about a cat", "This post is about a walrus", "This post is about space", "this post is about both a dog and space")
post_name <- c("dog account", "dog_account", "walrus_account", "space_account", "space_account")

case_when(
  grepl(paste(c("dog", "cat", "walrus"), collapse = "|"), post_caption) ~ "animal_post",
  grepl(paste(c("space", "rocks", "trees"), collapse = ""), post_caption) &  grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_name)~ "other_post",
  TRUE ~ NA_character_
  )

[1] "animal_post" "animal_post" "animal_post" "other_post"  "animal_post"
</code>```
```<code>#Code block 2

post_caption <- c("This post is about a dog", "This post is about a cat", "This post is about a walrus", "This post is about space", "this post is about both a dog and space")
post_name <- c("dog account", "dog_account", "walrus_account", "space_account", "space_account")

case_when(
  grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_caption) & grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_name)~ "other_post",
  grepl(paste(c("dog", "cat", "walrus"), collapse = "|"), post_caption) ~ "animal_post",
  TRUE ~ NA_character_
  )

#[1] "animal_post" "animal_post" "animal_post" "other_post" "other_post"
</code>```

Body:
When I try to use this code to recode non - mutually exclusive variable categories, it does not work how I would like. For example, the post with the caption, "this post is about both a dog and space" could go in either 'animal_post' or 'other_post'. However, no matter what it always codes it as an 'animal_post' - as seen in code block 1. It only recodes as 'other_post' if I switch the order of the recode instructions itself - as seen in code block 2. Is there a way to recode non-mutually exclusive data without it defaulting to the first option?

#Code block 1

post_caption <- c("This post is about a dog", "This post is about a cat", "This post is about a walrus", "This post is about space", "this post is about both a dog and space")
post_name <- c("dog account", "dog_account", "walrus_account", "space_account", "space_account")

case_when(
  grepl(paste(c("dog", "cat", "walrus"), collapse = "|"), post_caption) ~ "animal_post",
  grepl(paste(c("space", "rocks", "trees"), collapse = ""), post_caption) &  grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_name)~ "other_post",
  TRUE ~ NA_character_
  )

[1] "animal_post" "animal_post" "animal_post" "other_post"  "animal_post"

#Code block 2

post_caption <- c("This post is about a dog", "This post is about a cat", "This post is about a walrus", "This post is about space", "this post is about both a dog and space")
post_name <- c("dog account", "dog_account", "walrus_account", "space_account", "space_account")

case_when(
  grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_caption) & grepl(paste(c("space", "rocks", "trees"), collapse = "|"), post_name)~ "other_post",
  grepl(paste(c("dog", "cat", "walrus"), collapse = "|"), post_caption) ~ "animal_post",
  TRUE ~ NA_character_
  )

#[1] "animal_post" "animal_post" "animal_post" "other_post" "other_post"