问:
Kotlin/Spring Boot Application Fails to Build in Maven using Docker
I am trying to build an image for Kotlin/Spring Boot application. But when I run docker build I get the following error:

```<code>[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.7.20:compile (compile) on project download-common: Compilation failure
[ERROR] java.lang.IllegalStateException: Unable to find extension point configuration extensions/compiler.xml (cp:
[ERROR]   null)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:612)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:587)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironment(KotlinCoreEnvironment.kt:518)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:499)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:443)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:192)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:143)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
[ERROR]         at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execCompiler(KotlinCompileMojoBase.java:228)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:237)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:55)
[ERROR]         at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:209)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execute(K2JVMCompileMojo.java:222)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] -> [Help 1]
</code>```

The code compiles just fine when I run the same mvn clean install -e on my local machine without docker. After a bit of Googling, I added the below entry to plugins. The requiresUnpack section.

```<code><plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
                <configuration>
                    <requiresUnpack>
                        <dependency>
                            <groupId>org.jetbrains.kotlin</groupId>
                            <artifactId>kotlin-compiler</artifactId>
                        </dependency>
                    </requiresUnpack>
                </configuration>
            </plugin>
</code>```

My Dockerfile is:

```<code># AS <NAME> to name this stage as maven
FROM scratch
LABEL MAINTAINER="Sam"

#SETUP Ubuntu ENVIRONMENT
FROM ubuntu:latest as ubuntu

RUN export http_proxy=MY_PROXY_URL && export https_proxy=MY_PROXY_HTTPS_URL

#INSTALL JAVA
FROM eclipse-temurin:11-jdk-alpine AS jdk

#INSTALL MAVEN
FROM maven:3.8.6-eclipse-temurin-11-alpine AS maven

COPY settings.xml /usr/share/maven/conf/

RUN apk update && apk add git && apk add net-tools procps openssh-client openssh-server

RUN mkdir -p $HOME/images/lib/ && cd $HOME/images/lib/

RUN git clone MY_GIT_URL

WORKDIR /download_code

RUN git checkout feature/docker-branch

RUN mvn clean install -e
</code>```

It is a SpringBoot Application with Kotlin. And if its of any use, I am on Windows 10.

But I still get the same error. Any pointers would be helpful.

Body:
I am trying to build an image for Kotlin/Spring Boot application. But when I run docker build I get the following error:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.7.20:compile (compile) on project download-common: Compilation failure
[ERROR] java.lang.IllegalStateException: Unable to find extension point configuration extensions/compiler.xml (cp:
[ERROR]   null)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:612)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:587)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironment(KotlinCoreEnvironment.kt:518)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:499)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:443)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:192)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:143)
[ERROR]         at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
[ERROR]         at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
[ERROR]         at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execCompiler(KotlinCompileMojoBase.java:228)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:237)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:55)
[ERROR]         at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:209)
[ERROR]         at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execute(K2JVMCompileMojo.java:222)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] -> [Help 1]

The code compiles just fine when I run the same mvn clean install -e on my local machine without docker. After a bit of Googling, I added the below entry to plugins. The requiresUnpack section.

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
                <configuration>
                    <requiresUnpack>
                        <dependency>
                            <groupId>org.jetbrains.kotlin</groupId>
                            <artifactId>kotlin-compiler</artifactId>
                        </dependency>
                    </requiresUnpack>
                </configuration>
            </plugin>

My Dockerfile is:

# AS <NAME> to name this stage as maven
FROM scratch
LABEL MAINTAINER="Sam"

#SETUP Ubuntu ENVIRONMENT
FROM ubuntu:latest as ubuntu

RUN export http_proxy=MY_PROXY_URL && export https_proxy=MY_PROXY_HTTPS_URL

#INSTALL JAVA
FROM eclipse-temurin:11-jdk-alpine AS jdk

#INSTALL MAVEN
FROM maven:3.8.6-eclipse-temurin-11-alpine AS maven

COPY settings.xml /usr/share/maven/conf/

RUN apk update && apk add git && apk add net-tools procps openssh-client openssh-server

RUN mkdir -p $HOME/images/lib/ && cd $HOME/images/lib/

RUN git clone MY_GIT_URL

WORKDIR /download_code

RUN git checkout feature/docker-branch

RUN mvn clean install -e

It is a SpringBoot Application with Kotlin. And if its of any use, I am on Windows 10.

But I still get the same error. Any pointers would be helpful.


来源: stackexchange

问:
How do I solve this csv file encoding in brazilian portuguese?
guys
I'm having trouble with discovering the right encoding for a csv file. I've tried reading that file in many different encodings, I've tried encoding detectors, but couldn't make it work.

```<code>�53310749;�21649341;�4888467;�Consulta;�Objetivo;�;�Exame físico;�set/22: glicemia 275/ glicada 7,2 (redução comparativa)\r\nCT 200/ LDL 127/ hdl 58\r\n\r\nECG julh/22: OK\r\nFO set/22: retinopatia diabetica nao proliferativa bilateral;�Presencial;;

</code>```

The text is in brazilian portuguese. But I don't know the specifications of the software that exported this file.

I need help to find the right way to read that file. It needs to be readable.

ContentLicense: CC BY-SA 4.0

Body:
guys
I'm having trouble with discovering the right encoding for a csv file. I've tried reading that file in many different encodings, I've tried encoding detectors, but couldn't make it work.

�53310749;�21649341;�4888467;�Consulta;�Objetivo;�;�Exame físico;�set/22: glicemia 275/ glicada 7,2 (redução comparativa)\r\nCT 200/ LDL 127/ hdl 58\r\n\r\nECG julh/22: OK\r\nFO set/22: retinopatia diabetica nao proliferativa bilateral;�Presencial;;

The text is in brazilian portuguese. But I don't know the specifications of the software that exported this file.

I need help to find the right way to read that file. It needs to be readable.


问:
Twitter Sentiment Analysis : TypeError: dropout(): argument 'input' (position 1) must be Tensor, not tuple in DistilBERT using huggingface library
The following is my Sentiment Analyser:

```<code>from transformers import DistilBertTokenizer, DistilBertModel
PRE_TRAINED_MODEL_NAME = 'distilbert-base-cased'
db_model = DistilBertModel.from_pretrained(PRE_TRAINED_MODEL_NAME, return_dict = False)
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased', return_dict = False, return_tensors="pt")

class SentimentClassifier(nn.Module):
  def __init__(self, n_classes):
    super(SentimentClassifier, self).__init__()
    self.db = DistilBertModel.from_pretrained(PRE_TRAINED_MODEL_NAME, return_dict = False)
    self.drop = nn.Dropout(p=0.3)
    self.out = nn.Linear(self.db.config.hidden_size, n_classes)

  def forward(self, input_ids, attention_mask):
    pooled_output = self.db(
      input_ids=input_ids,
      attention_mask=attention_mask
    )
    output = self.drop(pooled_output)
    return self.out(output)
</code>```

When I try to run :

```<code>F.softmax(model(input_ids, attention_mask), dim=1)
</code>```

I am getting the following error:

```<code>---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-191-96f6522cbd43> in <module>
----> 1 F.softmax(model(input_ids, attention_mask), dim=1)

4 frames
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py in dropout(input, p, training, inplace)
   1250     if p < 0.0 or p > 1.0:
   1251         raise ValueError("dropout probability has to be between 0 and 1, " "but got {}".format(p))
-> 1252     return _VF.dropout_(input, p, training) if inplace else _VF.dropout(input, p, training)
   1253
   1254

TypeError: dropout(): argument 'input' (position 1) must be Tensor, not tuple
</code>```

I applied the solution used in BERT model (ie, return_dict = False and return_tensor = 'pt') and it is still running into this error.
Any solution to this would be highly appreciated.

Body:
The following is my Sentiment Analyser:

from transformers import DistilBertTokenizer, DistilBertModel
PRE_TRAINED_MODEL_NAME = 'distilbert-base-cased'
db_model = DistilBertModel.from_pretrained(PRE_TRAINED_MODEL_NAME, return_dict = False)
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-cased', return_dict = False, return_tensors="pt")

class SentimentClassifier(nn.Module):
  def __init__(self, n_classes):
    super(SentimentClassifier, self).__init__()
    self.db = DistilBertModel.from_pretrained(PRE_TRAINED_MODEL_NAME, return_dict = False)
    self.drop = nn.Dropout(p=0.3)
    self.out = nn.Linear(self.db.config.hidden_size, n_classes)

  def forward(self, input_ids, attention_mask):
    pooled_output = self.db(
      input_ids=input_ids,
      attention_mask=attention_mask
    )
    output = self.drop(pooled_output)
    return self.out(output)

When I try to run :

F.softmax(model(input_ids, attention_mask), dim=1)

I am getting the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-191-96f6522cbd43> in <module>
----> 1 F.softmax(model(input_ids, attention_mask), dim=1)

4 frames
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py in dropout(input, p, training, inplace)
   1250     if p < 0.0 or p > 1.0:
   1251         raise ValueError("dropout probability has to be between 0 and 1, " "but got {}".format(p))
-> 1252     return _VF.dropout_(input, p, training) if inplace else _VF.dropout(input, p, training)
   1253
   1254

TypeError: dropout(): argument 'input' (position 1) must be Tensor, not tuple

I applied the solution used in BERT model (ie, return_dict = False and return_tensor = 'pt') and it is still running into this error.
Any solution to this would be highly appreciated.


问:
React Native: Animation plays only on first render
I am making an animation. There is a boxes array, that will contain seven boxes of info to render. Each box will appear at different times. Now the problem is that when the first box is being displayed, the animation plays as expected, but never runs again and all upcoming boxes is being displayed without animation. Where could be the problem? Here is my current code:</p>
```<code>
interface Styles {
    wrap: ViewStyle;
    front: ViewStyle;
    back: ViewStyle;
}

const styles: Styles = {
    wrap: {
        position: 'relative',
    },
    front: {
        width: '100%',
        height: '100%',
        position: 'absolute',
    },
    back: {
        width: '100%',
        height: '100%',
        backfaceVisibility: 'hidden',
    },
};

type Props = {
    boxes: Box;
}

export const Component: React.FC<Props> = ({ boxes }) => {
    const animation = useRef(new Animated.Value(0));

    useEffect(() => {
        const anim = Animated.timing(animation.current, {
            toValue: 180,
            duration: 2000,
            useNativeDriver: false,
        });
        if (anim) {
            anim.start();
        }
        return () => {
            anim.stop();
        };
    }, [ animation ]);

    return (
        <View>
            {boxes.map((box) => (
                <View key={box}>
                    <View style={styles.wrap}>
                        <Animated.View
                            style={[ styles.front, {
                                    transform: [ { rotateY: animation.current.interpolate({
                                        inputRange: [ 0, 180 ],
                                        outputRange: [ '180deg', '360deg' ],
                                    }) } ],
                                }]}
                        >
                            <FrontBox box={box} />
                        </Animated.View>
                        <Animated.View
                            style={[ styles.back, {
                                    transform: [ { rotateY: animation.current.interpolate({
                                        inputRange: [ 0, 180 ],
                                        outputRange: [ '360deg', '180deg' ],
                                    }) } ],
                                }]}
                        >
                            <BackBox />
                        </Animated.View>
                    </View>
                </View>
            ))}
        </View>
    );
};
</code>```

Body:
I am making an animation. There is a boxes array, that will contain seven boxes of info to render. Each box will appear at different times. Now the problem is that when the first box is being displayed, the animation plays as expected, but never runs again and all upcoming boxes is being displayed without animation. Where could be the problem? Here is my current code:

interface Styles {
    wrap: ViewStyle;
    front: ViewStyle;
    back: ViewStyle;
}

const styles: Styles = {
    wrap: {
        position: 'relative',
    },
    front: {
        width: '100%',
        height: '100%',
        position: 'absolute',
    },
    back: {
        width: '100%',
        height: '100%',
        backfaceVisibility: 'hidden',
    },
};

type Props = {
    boxes: Box;
}

export const Component: React.FC<Props> = ({ boxes }) => {
    const animation = useRef(new Animated.Value(0));

    useEffect(() => {
        const anim = Animated.timing(animation.current, {
            toValue: 180,
            duration: 2000,
            useNativeDriver: false,
        });
        if (anim) {
            anim.start();
        }
        return () => {
            anim.stop();
        };
    }, [ animation ]);

    return (
        <View>
            {boxes.map((box) => (
                <View key={box}>
                    <View style={styles.wrap}>
                        <Animated.View
                            style={[ styles.front, {
                                    transform: [ { rotateY: animation.current.interpolate({
                                        inputRange: [ 0, 180 ],
                                        outputRange: [ '180deg', '360deg' ],
                                    }) } ],
                                }]}
                        >
                            <FrontBox box={box} />
                        </Animated.View>
                        <Animated.View
                            style={[ styles.back, {
                                    transform: [ { rotateY: animation.current.interpolate({
                                        inputRange: [ 0, 180 ],
                                        outputRange: [ '360deg', '180deg' ],
                                    }) } ],
                                }]}
                        >
                            <BackBox />
                        </Animated.View>
                    </View>
                </View>
            ))}
        </View>
    );
};


问:
Using Typescript api create an object in specific pattern from array of object, How can i retrive data using for loop in typescript?
Here I attached my typescript API using MySQL database, I have use foreach method for execute those two query because I need to get from those two query attached corresponding ID. So I need modification in the foreach loop, I will show my output which I need.

let values = employerRes.reduce((prev: any, curr: any) => ({
  ...prev, [curr.issuer_id]: {
    issuer_id: curr.issuer_id,
    ...prev[curr.issuer_id], [(curr.name).replaceAll(' ', "_")]: curr[`${curr.datatype}_value`]

Object.values(values).forEach((x: any) => {
  Object.values(getEmployerDetail).forEach((Benefit: any) => {
    if (x.issuer_id == Benefit.issuer_id) {
      Object.assign(values[id],{getEmployerDetail} )
    }
  })
})
```
<p>I am getting this output all is coming in single object.</p>
<pre class="lang-json prettyprint-override"><code>[
    {
        "issuer_id": 2639,
        "job_title": "Sales Manager",
        "hr-contact": "9767865459",
        "adress": "bangalore",
        "image": "http://localhost:3003/public/uploads/company-logos/undefined",
        "job_type": "top",
        "company_name": "Limendo",
        "cover_image": "http://localhost:3003/public/uploads/company-logos/undefined",
        "number_of_employees": null,
        "overview": "What is a company overview? A company overview provides the reader of your business plan with basic background information about your company so they have an understanding of what you do, who the management team is and what customers your business serves.",
        "getEmployerDetail": [
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 111,
                "Section": "Communes",
                "Content": "Mühlwald",
                "foa_section_content_id": 111
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 112,
                "Section": "Communes",
                "Content": "Wolkenstein in Gröden",
                "foa_section_content_id": 112
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 113,
                "Section": "Communes",
                "Content": "Schnals",
                "foa_section_content_id": 113
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 150,
                "Section": "Professional field",
                "Content": "Marketing, Graphics, PR",
                "foa_section_content_id": 150
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 162,
                "Section": "Branch",
                "Content": "Banks, Finance, Insurance",
                "foa_section_content_id": 162
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 215,
                "Section": "Benefits",
                "Content": "Enrolment programme",
                "foa_section_content_id": 215
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 220,
                "Section": "Benefits",
                "Content": "Childcare",
                "foa_section_content_id": 220
            }
        ]
    }
]
</code>```

I need like this output.

{
    "tender_id": 8,
    "job_title": "React developer",
    "enterprise": "Limendo",
    "publishing_date": "2022-11-27T07:43:06.000Z",
    "job_description": "developer for React ",
    "hr-contact": "stefan@limendo.com",
    "adress": "bolzano/italy 5",
    "image": "http://20.216.184.59:3003/public/uploads/company-logos/image-1668363010612.png",
    "job_type": "FULL TIME",
    "employmentType": [
        {
            "id": 198,
            "Employment_type": "Freelancer"
        }
    ],
    "professionalField": [
        {
            "id": 150,
            "Professional_field": "Marketing, Graphics, PR"
        }
    ],
    "benefits": [
        {
            "id": 215,
            "Benefits": "Enrolment programme"
        },
        {
            "id": 219,
            "Benefits": "Canteen"
        },
        {
            "id": 220,
            "Benefits": "Childcare"
        },
        {
            "id": 221,
            "Benefits": "Employee events"
        },
        {
            "id": 222,
            "Benefits": "Employee mobile phone"
        },
        {
            "id": 223,
            "Benefits": "Employee notebook"
        },
        {
            "id": 224,
            "Benefits": "Employee bonuses"
        }
    ],
    "branch": [
        {
            "id": 162,
            "Branch": "Banks, Finance, Insurance"
        }
    ],
    "communes": [],
    "positionLevel": [],
    "skillSets": [],
    "languageSkills": [],
    "skillRepository": [],
    "jobCluster": [],
    "jobClusterDescription": []
}
```

Body:
Here I attached my typescript API using MySQL database, I have use foreach method for execute those two query because I need to get from those two query attached corresponding ID. So I need modification in the foreach loop, I will show my output which I need.

let values = employerRes.reduce((prev: any, curr: any) => ({
  ...prev, [curr.issuer_id]: {
    issuer_id: curr.issuer_id,
    ...prev[curr.issuer_id], [(curr.name).replaceAll(' ', "_")]: curr[`${curr.datatype}_value`]

Object.values(values).forEach((x: any) => {
  Object.values(getEmployerDetail).forEach((Benefit: any) => {
    if (x.issuer_id == Benefit.issuer_id) {
      Object.assign(values[id],{getEmployerDetail} )
    }
  })
})

I am getting this output all is coming in single object.

[
    {
        "issuer_id": 2639,
        "job_title": "Sales Manager",
        "hr-contact": "9767865459",
        "adress": "bangalore",
        "image": "http://localhost:3003/public/uploads/company-logos/undefined",
        "job_type": "top",
        "company_name": "Limendo",
        "cover_image": "http://localhost:3003/public/uploads/company-logos/undefined",
        "number_of_employees": null,
        "overview": "What is a company overview? A company overview provides the reader of your business plan with basic background information about your company so they have an understanding of what you do, who the management team is and what customers your business serves.",
        "getEmployerDetail": [
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 111,
                "Section": "Communes",
                "Content": "Mühlwald",
                "foa_section_content_id": 111
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 112,
                "Section": "Communes",
                "Content": "Wolkenstein in Gröden",
                "foa_section_content_id": 112
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 113,
                "Section": "Communes",
                "Content": "Schnals",
                "foa_section_content_id": 113
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 150,
                "Section": "Professional field",
                "Content": "Marketing, Graphics, PR",
                "foa_section_content_id": 150
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 162,
                "Section": "Branch",
                "Content": "Banks, Finance, Insurance",
                "foa_section_content_id": 162
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 215,
                "Section": "Benefits",
                "Content": "Enrolment programme",
                "foa_section_content_id": 215
            },
            {
                "issuer_id": 2639,
                "Field_of_activity": "Jobs",
                "id": 220,
                "Section": "Benefits",
                "Content": "Childcare",
                "foa_section_content_id": 220
            }
        ]
    }
]

I need like this output.

{
    "tender_id": 8,
    "job_title": "React developer",
    "enterprise": "Limendo",
    "publishing_date": "2022-11-27T07:43:06.000Z",
    "job_description": "developer for React ",
    "hr-contact": "stefan@limendo.com",
    "adress": "bolzano/italy 5",
    "image": "http://20.216.184.59:3003/public/uploads/company-logos/image-1668363010612.png",
    "job_type": "FULL TIME",
    "employmentType": [
        {
            "id": 198,
            "Employment_type": "Freelancer"
        }
    ],
    "professionalField": [
        {
            "id": 150,
            "Professional_field": "Marketing, Graphics, PR"
        }
    ],
    "benefits": [
        {
            "id": 215,
            "Benefits": "Enrolment programme"
        },
        {
            "id": 219,
            "Benefits": "Canteen"
        },
        {
            "id": 220,
            "Benefits": "Childcare"
        },
        {
            "id": 221,
            "Benefits": "Employee events"
        },
        {
            "id": 222,
            "Benefits": "Employee mobile phone"
        },
        {
            "id": 223,
            "Benefits": "Employee notebook"
        },
        {
            "id": 224,
            "Benefits": "Employee bonuses"
        }
    ],
    "branch": [
        {
            "id": 162,
            "Branch": "Banks, Finance, Insurance"
        }
    ],
    "communes": [],
    "positionLevel": [],
    "skillSets": [],
    "languageSkills": [],
    "skillRepository": [],
    "jobCluster": [],
    "jobClusterDescription": []
}


问:
C# Xamarin changing Background color of an Item programmatically using Binding
I'm trying to change the color of the background of a Object in a UserControl programmatically because I'm using different Dictionaries with different properties for each case using Binding. I've already done several of these and work perfectly the only difference with this .xaml is that it is used as a UserControl that shows up in the page instead of being a page itself.

Here is the code that works properly
`

```<code><Grid
   Grid.Row="1"
   Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=HeaderBackgroundColor, Mode=OneWay}">
       <TextBlock
                Margin="30, 40, 30, 13"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Top"
                Foreground="{StaticResource TertiaryColor}"
                FontFamily="{StaticResource PrimaryFont}">
                <TextBlock.Inlines>
                    <Run
                        FontSize="{StaticResource HeaderTitleSmallerFontSize}"
                        Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=SplashMessageRight, Converter={StaticResource UpperCaseConverter}, Mode=OneWay}" />
        </TextBlock.Inlines>
   </TextBlock>
</Grid>
</code>```

As you can see Im using `

```<code>Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=HeaderBackgroundColor, Mode=OneWay}">
</code>```

`To then set the color of the background programmaticaly like this

```<code>        public SolidColorBrush HeaderBackgroundColor
        {
            get
            {
                switch (KioskManager.ManagerInstance.InstanceConfiguration.Type)
                {
                    case KioskManagerConfiguration.ConfigurationType.TukTuk:
                        return (SolidColorBrush)new BrushConverter().ConvertFrom("#383943");
                    default:
                        return new SolidColorBrush(Colors.White);
                }
            }
        }
</code>```

So like I was saying this is a Page itself on the App, but when I try to to the same thing but in a UserControl that shows up on this page itself it doesn't work , the color just shows as transparent.

This is the code I use in the UserControl

`

```<code>    <Border
        HorizontalAlignment="Stretch"
        VerticalAlignment="Bottom"
        Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=ProductSuggestionsControlBackgroundColor, Mode=OneWay}"
        CornerRadius="{StaticResource OverlayCornerRadius}">
    </Border>
</code>```

`

And then this to change the Color depending on the Configuration
`

```<code>        public SolidColorBrush ProductSuggestionsControlBackgroundColor
        {
            get
            {
                switch (KioskManager.ManagerInstance.InstanceConfiguration.Type)
                {
                    case KioskManagerConfiguration.ConfigurationType.TukTuk:
                        return (SolidColorBrush)new BrushConverter().ConvertFrom("#d9645b");
                    default:
                        return new SolidColorBrush(Colors.White);
                }
            }
        }
</code>```

To sum , this second bit of code is a UserControl that gets called on the Page that I use the first bit of code in.

Hope someone can help , Thanks in Advance.

Body:
I'm trying to change the color of the background of a Object in a UserControl programmatically because I'm using different Dictionaries with different properties for each case using Binding. I've already done several of these and work perfectly the only difference with this .xaml is that it is used as a UserControl that shows up in the page instead of being a page itself.

Here is the code that works properly
`

<Grid
   Grid.Row="1"
   Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=HeaderBackgroundColor, Mode=OneWay}">
       <TextBlock
                Margin="30, 40, 30, 13"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Top"
                Foreground="{StaticResource TertiaryColor}"
                FontFamily="{StaticResource PrimaryFont}">
                <TextBlock.Inlines>
                    <Run
                        FontSize="{StaticResource HeaderTitleSmallerFontSize}"
                        Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=SplashMessageRight, Converter={StaticResource UpperCaseConverter}, Mode=OneWay}" />
        </TextBlock.Inlines>
   </TextBlock>
</Grid>

As you can see Im using `

Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=HeaderBackgroundColor, Mode=OneWay}">

`To then set the color of the background programmaticaly like this

        public SolidColorBrush HeaderBackgroundColor
        {
            get
            {
                switch (KioskManager.ManagerInstance.InstanceConfiguration.Type)
                {
                    case KioskManagerConfiguration.ConfigurationType.TukTuk:
                        return (SolidColorBrush)new BrushConverter().ConvertFrom("#383943");
                    default:
                        return new SolidColorBrush(Colors.White);
                }
            }
        }

So like I was saying this is a Page itself on the App, but when I try to to the same thing but in a UserControl that shows up on this page itself it doesn't work , the color just shows as transparent.

This is the code I use in the UserControl

`

    <Border
        HorizontalAlignment="Stretch"
        VerticalAlignment="Bottom"
        Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}, Path=ProductSuggestionsControlBackgroundColor, Mode=OneWay}"
        CornerRadius="{StaticResource OverlayCornerRadius}">
    </Border>

`

And then this to change the Color depending on the Configuration
`

        public SolidColorBrush ProductSuggestionsControlBackgroundColor
        {
            get
            {
                switch (KioskManager.ManagerInstance.InstanceConfiguration.Type)
                {
                    case KioskManagerConfiguration.ConfigurationType.TukTuk:
                        return (SolidColorBrush)new BrushConverter().ConvertFrom("#d9645b");
                    default:
                        return new SolidColorBrush(Colors.White);
                }
            }
        }

To sum , this second bit of code is a UserControl that gets called on the Page that I use the first bit of code in.

Hope someone can help , Thanks in Advance.


问:
Dynamic routing in ASP .NET Core based on data received from frontend
I am working on CMS which contains many domains (so our URLs can look like www.example.com/group or www.example.com/de). I want to make a call from frontend based on the current domain:

```<code>window.addEventListener('CookiebotOnAccept', (e) => {
    const domain = window.location.pathname.replace(/^\/([^\/]*).*$/, '$1');
    const URL = `${window.location.protocol}//${window.location.host}//${domain}/UpdateCookies`;
    console.log(domain)
    fetch(URL, {credentials: 'include'})
    .then((response) => {
        if (!response.ok) {
            throw new Error("Cookie consent update was not succesful")
        }
    })
    .catch((error) => {
        console.error('There has been a problem with your fetch operation: ', error)
    })
}, false)
</code>```

...and then I need to be able to send it to an endpoint in the backend, which needs to have a dynamic routing based on the domain it currently receives requests from.
Backend endpoint:

```<code>[Route("CookieHandler")]
    public class CookieHandlerController : Controller
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly ICookieService _cookieService;

        public CookieHandlerController(IHttpContextAccessor httpContextAccessor, ICookieService cookieService)
        {
            _httpContextAccessor = httpContextAccessor;
            _cookieService = cookieService;
        }

        [HttpGet]
        [Route("UpdateCookies")]
        public IActionResult UpdateCookies()
        {
            var requestCookies = _httpContextAccessor.HttpContext?.Request.Cookies;

            foreach (var cookie in requestCookies)
            {
                    _cookieService.UpdateCookiesAccordingToConsent(cookie.Key);
            }

            return Ok();
        }
    }
</code>```

So, basically, the endpoint routing needs to look like this:

www.example.com/group/updatecookies

or

www.example.com/fr/updatecookies

The reason for such a strange setup is that there are some Http-only cookies which have their specific path value based on their domain. One more thing to add is that there are so many domains that simply hardcoding them might not work.

Body:
I am working on CMS which contains many domains (so our URLs can look like www.example.com/group or www.example.com/de). I want to make a call from frontend based on the current domain:

window.addEventListener('CookiebotOnAccept', (e) => {
    const domain = window.location.pathname.replace(/^\/([^\/]*).*$/, '$1');
    const URL = `${window.location.protocol}//${window.location.host}//${domain}/UpdateCookies`;
    console.log(domain)
    fetch(URL, {credentials: 'include'})
    .then((response) => {
        if (!response.ok) {
            throw new Error("Cookie consent update was not succesful")
        }
    })
    .catch((error) => {
        console.error('There has been a problem with your fetch operation: ', error)
    })
}, false)

...and then I need to be able to send it to an endpoint in the backend, which needs to have a dynamic routing based on the domain it currently receives requests from.
Backend endpoint:

[Route("CookieHandler")]
    public class CookieHandlerController : Controller
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly ICookieService _cookieService;

        public CookieHandlerController(IHttpContextAccessor httpContextAccessor, ICookieService cookieService)
        {
            _httpContextAccessor = httpContextAccessor;
            _cookieService = cookieService;
        }

        [HttpGet]
        [Route("UpdateCookies")]
        public IActionResult UpdateCookies()
        {
            var requestCookies = _httpContextAccessor.HttpContext?.Request.Cookies;

            foreach (var cookie in requestCookies)
            {
                    _cookieService.UpdateCookiesAccordingToConsent(cookie.Key);
            }

            return Ok();
        }
    }

So, basically, the endpoint routing needs to look like this:

www.example.com/group/updatecookies

or

www.example.com/fr/updatecookies

The reason for such a strange setup is that there are some Http-only cookies which have their specific path value based on their domain. One more thing to add is that there are so many domains that simply hardcoding them might not work.


问:
Selenium - how to download list of links and click on download button
Newbie here. Trying to run a list of links (over 1000s) to files from 1GB to 50GB pr file.
The final link is in a button you click on.

So need help to setup selenium to parse a list of links and click on the download button to download the file in the link. I guess there needs to be some kind of pausing or timer or else the browser will crash with downloads. Maybe theres a smart way i'm just aiming for the stars.

the xcode of the button is: //*[@id="menu-75-option-3"]/div

thanks.

tried to get selenium to find all links on but failing


问:
Python 2.. to 3.9 - load and reload class dynamically by name
I have an old code I wrote a long time ago

It is supposed to load classes dynamically by parameters:

family and dclass are folders

then I execute that class with parameters x,y,dir,name

if class is already loaded, then I reload it

```<code>def load_device(self,x,y,name,family,dclass,dir,list=None):
    try:
        exec ("reload('.\\%s\\%s')"%(family,dclass))
    except:
        exec ("import %s"%dclass)
    exec ("d=%s.%s(%s,%s,%s,\"%s\")"%(dclass,dclass,x,y,dir,name))
</code>```

I already checked a couple of answers here and there, cant find anything similar

how do I do something similar in Python 3.9 ?

thanks

Body:
I have an old code I wrote a long time ago

It is supposed to load classes dynamically by parameters:

family and dclass are folders

then I execute that class with parameters x,y,dir,name

if class is already loaded, then I reload it

def load_device(self,x,y,name,family,dclass,dir,list=None):
    try:
        exec ("reload('.\\%s\\%s')"%(family,dclass))
    except:
        exec ("import %s"%dclass)
    exec ("d=%s.%s(%s,%s,%s,\"%s\")"%(dclass,dclass,x,y,dir,name))

I already checked a couple of answers here and there, cant find anything similar

how do I do something similar in Python 3.9 ?

thanks


问:
How to return an empty vector
This method finds all Alien objects in the AlienList object’s Vector whose humanoid field has the value false. It stores all matching Alien objects in a new Vector that is then returned from the method. The method must also remove all the matching Alien objects from the Vector of AlienList. If there are no matching Alien objects then an empty Vector must be returned.

The only problem with my method is that when i call the method for a second time, the same two (removed) non humanoids which were returned in the first method call, are actually in this list returned by the 2nd call. Which they should have not been because they were removed on the previous call.

Here is my class with the method i need help with at the bottom:

```<code>public class AlientList
{
    // instance variables - replace the example below with your own
    private Vector<Alien> aliens;
    private Vector<Alien> nonHumanoids;

    /**
     * Constructor for objects of class AlientList
     */
    public AlientList()
    {
        aliens = new Vector<>();
        nonHumanoids = new Vector<>();
    }

    public void addAlien(Alien alien)
    {
        aliens.add(alien);
    }

    public void printHumanoids()
    {
        for(Alien alien: aliens) {
            if(alien.getHumanoid() == true){
                System.out.println(alien.getDetails());
            }
        }
    }

    public Vector<Alien> getNonHumanoids()
    {
        Iterator<Alien> it = aliens.iterator();
        while(it.hasNext()){
            Alien alien = it.next();
            if(alien.getHumanoid() == false){
                it.remove();
                nonHumanoids.add(alien);
            }
        }
        return nonHumanoids;
    }
}
</code>```

Title: How to return an empty vector

Body:
This method finds all Alien objects in the AlienList object’s Vector whose humanoid field has the value false. It stores all matching Alien objects in a new Vector that is then returned from the method. The method must also remove all the matching Alien objects from the Vector of AlienList. If there are no matching Alien objects then an empty Vector must be returned.

The only problem with my method is that when i call the method for a second time, the same two (removed) non humanoids which were returned in the first method call, are actually in this list returned by the 2nd call. Which they should have not been because they were removed on the previous call.

Here is my class with the method i need help with at the bottom:

public class AlientList
{
    // instance variables - replace the example below with your own
    private Vector<Alien> aliens;
    private Vector<Alien> nonHumanoids;

    /**
     * Constructor for objects of class AlientList
     */
    public AlientList()
    {
        aliens = new Vector<>();
        nonHumanoids = new Vector<>();
    }

    public void addAlien(Alien alien)
    {
        aliens.add(alien);
    }

    public void printHumanoids()
    {
        for(Alien alien: aliens) {
            if(alien.getHumanoid() == true){
                System.out.println(alien.getDetails());
            }
        }
    }

    public Vector<Alien> getNonHumanoids()
    {
        Iterator<Alien> it = aliens.iterator();
        while(it.hasNext()){
            Alien alien = it.next();
            if(alien.getHumanoid() == false){
                it.remove();
                nonHumanoids.add(alien);
            }
        }
        return nonHumanoids;
    }
}


问:
Typo3 Form Elements "Login Form" Not Visible & showing error instead in 12 version
I am a beginner in Typo3 CMS.
I am getting issue in typo3 login form creating. its showing me error .
My system configurations are given bellow :

TYPO3 Version   12.0.0
Webserver   Apache/2.4.41 (Ubuntu)
PHP Version 8.1.13
Database (Default)  MySQL 10.3.37-MariaDB-0ubuntu0.20.04.1
Application Context Production
Composer mode   Enabled
Operating System    Linux 5.15.0-56-generic

I have tried this two way given bellow :-
1.I have tried by creating usergroup mapping that folder in login page .
2. fe-login extension is not available for version 12.


问:
CANVAS: It is not possible to completely delete arc if using ctx.globalCompositeOperation
First, I draw an arc with diameter at any position. I would then delete a circular area in another position so that it could cut the first arc, using ctx.globalCompositeOperation = 'destination-out' and draw an arc and then set ctx.globalCompositeOperation = 'source- over'. I'll end up drawing a similar arc at the exact spot I just deleted.
Its two func i used to:

```<code>const eraseDot = (ctx, { x, y, size }) => {
    ctx.globalCompositeOperation = 'destination-out';
    drawDot(ctx, { x, y, size, color: 'white' });
    ctx.globalCompositeOperation = 'source-over';
}
</code>```
```<code>const drawDot = (ctx, { x, y, size, color }) => {
    ctx.beginPath();
    ctx.arc(x, y, size / 2, 0, Math.PI * 2);
    ctx.closePath();
    ctx.fillStyle = color;
    ctx.fill();
};
</code>```

My desired result is to draw 2 intersecting arcs (like how to draw 2 normal arcs but I want to clear the image area before drawing the 2nd arc). But it appears that there is a gap between the intersection of the 2 arcs:
enter image description here

this means different erase and draw area sizes. please tell me the reason of this and how to solve it , thanks :

Body:
First, I draw an arc with diameter at any position. I would then delete a circular area in another position so that it could cut the first arc, using ctx.globalCompositeOperation = 'destination-out' and draw an arc and then set ctx.globalCompositeOperation = 'source- over'. I'll end up drawing a similar arc at the exact spot I just deleted.
Its two func i used to:

const eraseDot = (ctx, { x, y, size }) => {
    ctx.globalCompositeOperation = 'destination-out';
    drawDot(ctx, { x, y, size, color: 'white' });
    ctx.globalCompositeOperation = 'source-over';
}

const drawDot = (ctx, { x, y, size, color }) => {
    ctx.beginPath();
    ctx.arc(x, y, size / 2, 0, Math.PI * 2);
    ctx.closePath();
    ctx.fillStyle = color;
    ctx.fill();
};

My desired result is to draw 2 intersecting arcs (like how to draw 2 normal arcs but I want to clear the image area before drawing the 2nd arc). But it appears that there is a gap between the intersection of the 2 arcs:
enter image description here

this means different erase and draw area sizes. please tell me the reason of this and how to solve it , thanks :


问:
Send a request to an API with JWT token from iOS with an Blazor application gets error
I had this behaviour roughly a year ago. Now, in my new application, I'm facing the same issue, but the old solution didn't work. So, I have a Blazor application with NET6. To call the API, I add the user token. I have a function that read the token from the cache or from IAccessTokenProvider.

```<code>IAccessTokenProvider _accessToken;
private async Task<AccessToken> RequestUserToken()
{
    try
    {
        var tokenResult = await _accessToken.RequestAccessToken();
        tokenResult.TryGetToken(out var token);

        Console.WriteLine(token);

        return token;
    }
    catch (AccessTokenNotAvailableException aex)
    {
        throw new ApplicationException($"Exception {aex}");
    }
    catch (Exception ex)
    {
        throw new ApplicationException(
            $"AccessTokenNotAvailable Exception Exception {ex}");
    }
}
</code>```

The application sends successfully requests to the API from Windows and Android. When I run the application on iOS devices, the token is not found and then there is an error.

How can I get (retrieve) the token in Blazor from an iOS/macOS device?

Update

I'm running the web application on a Mac. The application is working fine with Microsoft Edge and Chrome but not with Safari.

On iPhone and iPad, I have issue with the token on Safari and Chrome. It works fine on Microsoft Edge.

Body:
I had this behaviour roughly a year ago. Now, in my new application, I'm facing the same issue, but the old solution didn't work. So, I have a Blazor application with NET6. To call the API, I add the user token. I have a function that read the token from the cache or from IAccessTokenProvider.

IAccessTokenProvider _accessToken;
private async Task<AccessToken> RequestUserToken()
{
    try
    {
        var tokenResult = await _accessToken.RequestAccessToken();
        tokenResult.TryGetToken(out var token);

        Console.WriteLine(token);

        return token;
    }
    catch (AccessTokenNotAvailableException aex)
    {
        throw new ApplicationException($"Exception {aex}");
    }
    catch (Exception ex)
    {
        throw new ApplicationException(
            $"AccessTokenNotAvailable Exception Exception {ex}");
    }
}

The application sends successfully requests to the API from Windows and Android. When I run the application on iOS devices, the token is not found and then there is an error.

How can I get (retrieve) the token in Blazor from an iOS/macOS device?

Update

I'm running the web application on a Mac. The application is working fine with Microsoft Edge and Chrome but not with Safari.

On iPhone and iPad, I have issue with the token on Safari and Chrome. It works fine on Microsoft Edge.


问:
how to malloc an int * in C
I want to make a fucntion that load a map in a char ** and return it.

To do this I need to make a function that return an int * with inside it, the length of each line in a char ** give as arguments.
my problem is, it keep segfault and I don't know how to fix this.

when I use valgrind the errors are :
Use of uninitialised value of size 8   ,

Invalid write of size 1

```<code>int *nb_cols_pline(char *filepath)             //length of each line in char **
{
    int x, y = 0;
    struct stat *size = malloc(sizeof(struct stat));
    stat(filepath, size);

    int *count = malloc(sizeof(int) * nb_lines(filepath));  //first errors may be here

    int fd = open(filepath, O_RDONLY);
    char *buffer = malloc(sizeof(char) * size->st_size);
    read(fd, buffer, size->st_size);

    for (y = 0; y < nb_lines(filepath); y++) {
        for (x = 0; buffer[x] != '\n'; x++) {
        }
        count[y] = x;           //maybe second error
    }
    close(fd);
    free(size); free(buffer);
    return count;
}

char **load_map(char *filepath)
{
    int i = 0;
    struct stat *size = malloc(sizeof(struct stat));
    stat(filepath, size);

    int *nb_cols = malloc(sizeof(int) * nb_lines(filepath));
    char *buffer = malloc(sizeof(char) * size->st_size);

    for (int x = 0; x < nb_lines(filepath); x++) {
        nb_cols[x] = nb_cols_pline(filepath)[x];
    }

    char **map = malloc(sizeof(char *) * nb_lines(filepath) + 1);
    for (int x = 0; x < nb_lines(filepath); x++) {
        map = malloc(sizeof(char) * nb_cols[x]);
    }

    int fd = open(filepath, O_RDONLY);
    read(fd, buffer, size->st_size);
    for (int y = 0; y < nb_lines(filepath); y++) {
        for (int x = 0; x < nb_cols[i]; x++) {
            map[y][x] = buffer[i];
            i += 1;
        }
        i += 1;
    }
    close(fd);
    free(buffer); free(nb_cols); free(size);
    return map;
}

</code>```

Title: how to malloc an int * in C

Body:
I want to make a fucntion that load a map in a char ** and return it.

To do this I need to make a function that return an int * with inside it, the length of each line in a char ** give as arguments.
my problem is, it keep segfault and I don't know how to fix this.

when I use valgrind the errors are :
Use of uninitialised value of size 8   ,

Invalid write of size 1

int *nb_cols_pline(char *filepath)             //length of each line in char **
{
    int x, y = 0;
    struct stat *size = malloc(sizeof(struct stat));
    stat(filepath, size);

    int *count = malloc(sizeof(int) * nb_lines(filepath));  //first errors may be here

    int fd = open(filepath, O_RDONLY);
    char *buffer = malloc(sizeof(char) * size->st_size);
    read(fd, buffer, size->st_size);

    for (y = 0; y < nb_lines(filepath); y++) {
        for (x = 0; buffer[x] != '\n'; x++) {
        }
        count[y] = x;           //maybe second error
    }
    close(fd);
    free(size); free(buffer);
    return count;
}

char **load_map(char *filepath)
{
    int i = 0;
    struct stat *size = malloc(sizeof(struct stat));
    stat(filepath, size);

    int *nb_cols = malloc(sizeof(int) * nb_lines(filepath));
    char *buffer = malloc(sizeof(char) * size->st_size);

    for (int x = 0; x < nb_lines(filepath); x++) {
        nb_cols[x] = nb_cols_pline(filepath)[x];
    }

    char **map = malloc(sizeof(char *) * nb_lines(filepath) + 1);
    for (int x = 0; x < nb_lines(filepath); x++) {
        map = malloc(sizeof(char) * nb_cols[x]);
    }

    int fd = open(filepath, O_RDONLY);
    read(fd, buffer, size->st_size);
    for (int y = 0; y < nb_lines(filepath); y++) {
        for (int x = 0; x < nb_cols[i]; x++) {
            map[y][x] = buffer[i];
            i += 1;
        }
        i += 1;
    }
    close(fd);
    free(buffer); free(nb_cols); free(size);
    return map;
}


问:
Python Tornado: What is the correct way to launch background tasks so they can be gracefully closed on shutdown?
I am trying to support graceful shutdown for a Tornado application.  I would like to stop receiving new requests and wait for the existing requests to complete before proceeding to close the connection pools and shutting down.  However, I don’t see a way to monitor which background tasks are running to know that they are complete.  What is the right way to do this with Tornado?

The other StackOverflow questions I found did not appear to address this issue.

The app code looks something like this:

```<code>class JobHandler(RequestHandler):

    async def post(self):
            ...
            IOLoop.instance().add_callback(self.backgroundtask, parameter)
            ...

server = None

async def shutdown():
    # stop listening for new requests
    server.stop()
    # wait for all open tasks to complete ???
    # close connection pools

def exit_handler(sig, frame):
    tornado.ioloop.IOLoop.instance().add_callback_from_signal(shutdown)

if __name__ == "__main__":
    uvloop.install()
    signal.signal(signal.SIGTERM, exit_handler)
    signal.signal(signal.SIGINT,  exit_handler)

    application = tornado.web.Application([
        (r"/request_work", JobHandler),
    ])

    server = HTTPServer(application)
    server.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
</code>```

Body:
I am trying to support graceful shutdown for a Tornado application.  I would like to stop receiving new requests and wait for the existing requests to complete before proceeding to close the connection pools and shutting down.  However, I don’t see a way to monitor which background tasks are running to know that they are complete.  What is the right way to do this with Tornado?

The other StackOverflow questions I found did not appear to address this issue.

The app code looks something like this:

class JobHandler(RequestHandler):

    async def post(self):
            ...
            IOLoop.instance().add_callback(self.backgroundtask, parameter)
            ...

server = None

async def shutdown():
    # stop listening for new requests
    server.stop()
    # wait for all open tasks to complete ???
    # close connection pools

def exit_handler(sig, frame):
    tornado.ioloop.IOLoop.instance().add_callback_from_signal(shutdown)

if __name__ == "__main__":
    uvloop.install()
    signal.signal(signal.SIGTERM, exit_handler)
    signal.signal(signal.SIGINT,  exit_handler)

    application = tornado.web.Application([
        (r"/request_work", JobHandler),
    ])

    server = HTTPServer(application)
    server.listen(8888)
    tornado.ioloop.IOLoop.instance().start()


问:
Kotlin cannot resolve non-nullability
When checking nullability directly Kotlin is able to find out that x is non-null inside the condidition

```<code>fun test(x: X?) {
 if(x!=null){
   x.callMethod()
 }
}
</code>```

But once I extract the condition into a dedicated method Kotlin is not able to do that anymore:

```<code>fun test(x: X?) {
 if(isNonNull(x)){
   x.callMethod()   // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type X?
 }
}
fun isNonNull(x:X?) = x!=null
</code>```

How can I achieve the same Kotlin behaviour as in the 1st code with extracted methods for conditions?

Title: Kotlin cannot resolve non-nullability

Body:
When checking nullability directly Kotlin is able to find out that x is non-null inside the condidition

fun test(x: X?) {
 if(x!=null){
   x.callMethod()
 }
}

But once I extract the condition into a dedicated method Kotlin is not able to do that anymore:

fun test(x: X?) {
 if(isNonNull(x)){
   x.callMethod()   // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type X?
 }
}
fun isNonNull(x:X?) = x!=null

How can I achieve the same Kotlin behaviour as in the 1st code with extracted methods for conditions?


问:
Automatically drag down data in Excel
I am looking to speed up one of my workbooks.

In sheet 1, I have a pasted data set for example:

```<code>Column A: Numbered 1,2,3,4,5,6,7..
Column B: data
</code>```

However, each day the length of the data is different, some days there are 50 entries, some days 300.

The next sheet takes this data and highlights special causes for me and calculates what I need to know.

I am manually highlighting the row on sheet 2, and dragging it down as far as there is data on sheet 1. Is there a way to do this automatically?

The cells in sheet 2 that I drag down already have a complex formula so I want to avoid adding to it if I can; I was hoping there was a way to use some VB code or Name Manager?

Sorry if my explanation is poor. I can attach my spreadsheet if it will help

EDITED TO ADD:

=IF(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<>"",IF(AND(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))>=E$7,INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<=E$8),"OK",(IF(AND(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))>=(E$6-((E$6-E$7)*1.5)),INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<=(E$6-((E$6-E$8)*1.5))),"C20","C50"))),"")

that is my current formula, it is there to look to see if a certain measurment on a data set is within spec, which is "OK" "C20" if it is just out of spec, or "C50" if it is 1.5* spec

i would just like this formula to work only if there is a number in row B higher than 0

i can upload a copy of my workbook if needed but will need to hide sensitive data first

Title: Automatically drag down data in Excel

Body:
I am looking to speed up one of my workbooks.

In sheet 1, I have a pasted data set for example:

Column A: Numbered 1,2,3,4,5,6,7..
Column B: data

However, each day the length of the data is different, some days there are 50 entries, some days 300.

The next sheet takes this data and highlights special causes for me and calculates what I need to know.

I am manually highlighting the row on sheet 2, and dragging it down as far as there is data on sheet 1. Is there a way to do this automatically?

The cells in sheet 2 that I drag down already have a complex formula so I want to avoid adding to it if I can; I was hoping there was a way to use some VB code or Name Manager?

Sorry if my explanation is poor. I can attach my spreadsheet if it will help

EDITED TO ADD:

=IF(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<>"",IF(AND(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))>=E$7,INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<=E$8),"OK",(IF(AND(INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))>=(E$6-((E$6-E$7)*1.5)),INDEX('Raw data'!22:22,MATCH(E$10,'Raw data'!$21:$21,0))<=(E$6-((E$6-E$8)*1.5))),"C20","C50"))),"")

that is my current formula, it is there to look to see if a certain measurment on a data set is within spec, which is "OK" "C20" if it is just out of spec, or "C50" if it is 1.5* spec

i would just like this formula to work only if there is a number in row B higher than 0

i can upload a copy of my workbook if needed but will need to hide sensitive data first


问:
Partially hide text in <option>
I have a dataList of options with let's say names (codepen ex, it's in pug)

```<code><datalist id="ice-cream-flavors">
  <option value="Theodor">Smith</option>
  <option value="Maria">Kovalsky</option>
  <option value="Ruyji">Takayama</option>
</datalist>
</code>```

I need also to be able search by nickname, for ex Theodor "Ted" Smith, but I want to hide that nickname - so autocomplete suggests "Theodor Smith" on "Ted" input.

Is there any way to do so?

Thanks in advance!

Title: Partially hide text in <option>

Body:
I have a dataList of options with let's say names (codepen ex, it's in pug)

<datalist id="ice-cream-flavors">
  <option value="Theodor">Smith</option>
  <option value="Maria">Kovalsky</option>
  <option value="Ruyji">Takayama</option>
</datalist>

I need also to be able search by nickname, for ex Theodor "Ted" Smith, but I want to hide that nickname - so autocomplete suggests "Theodor Smith" on "Ted" input.

Is there any way to do so?

Thanks in advance!


问:
Why a name must be set for a calculated field to show up checked in Excel after AddCalculatedField()?
If I add calculated field with AddCalculatedField call, this field appears in Excel file but with "unchecked" state in PivotTable Fields.

How can I make it "checked"?

What helps me, just by insight, is to rename a column after adding it to a DataFields. Like so:

```<code>tab.Fields.AddCalculatedField("Foo", @"'Vp' / 'V1'");
var f = tab.DataFields.Add(tab.Fields["Foo"]);
f.Name = "New name"; // This line changes everything.
</code>```

I need some explanation from devs. Please.

Body:
If I add calculated field with AddCalculatedField call, this field appears in Excel file but with "unchecked" state in PivotTable Fields.

How can I make it "checked"?

What helps me, just by insight, is to rename a column after adding it to a DataFields. Like so:

tab.Fields.AddCalculatedField("Foo", @"'Vp' / 'V1'");
var f = tab.DataFields.Add(tab.Fields["Foo"]);
f.Name = "New name"; // This line changes everything.

I need some explanation from devs. Please.


问:
Devise JWT Test Rspec, help-me
I am trying to get devise and devise-jwt gems to work so I can implement Authorization into my API only Rails app.

I have installed both devise and devise-jwt gems.

I followed the instructions on this blog post:
https://medium.com/@mazik.wyry/rails-5-api-jwt-setup-in-minutes-using-devise-71670fd4ed03

I have implemented the request specs that the author has included in his post and I can't get it approved on "Deleted",
I have to pass the authorizate token on delete, but I'm not getting it.
Any suggestion?

```<code>require 'rails_helper'
require "json"

RSpec.describe "POST /users", type: :request do

  let(:user) { create(:user) }
    let(:url) { '/users/sign_in' }
    let(:params) do
      {
        user: {
          email: user.email,
          password: user.password
        }
      }
    end

    context 'when params are correct' do
      before do
        post url, params: params.to_json, headers: { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' }
      end

      it 'returns 200' do
        expect(response).to have_http_status(200)
      end

      it 'returns JTW token in authorization header' do
        expect(response.headers['authorization']).to be_present
      end

    end

    context 'when login params are incorrect' do
      before { post url }

      it 'returns unathorized status' do
        expect(response.status).to eq 401
      end
    end

  end

  RSpec.describe 'DELETE /logout', type: :request do
    let(:url) { '/users/sign_out' }

    it 'returns 204, no content' do
      delete url
      expect(response).to have_http_status(201)
    end
  end
</code>```

I need to pass the user's token on delete, any suggestions on how I can be doing this?

Title: Devise JWT Test Rspec, help-me

Body:
I am trying to get devise and devise-jwt gems to work so I can implement Authorization into my API only Rails app.

I have installed both devise and devise-jwt gems.

I followed the instructions on this blog post:
https://medium.com/@mazik.wyry/rails-5-api-jwt-setup-in-minutes-using-devise-71670fd4ed03

I have implemented the request specs that the author has included in his post and I can't get it approved on "Deleted",
I have to pass the authorizate token on delete, but I'm not getting it.
Any suggestion?

require 'rails_helper'
require "json"

RSpec.describe "POST /users", type: :request do

  let(:user) { create(:user) }
    let(:url) { '/users/sign_in' }
    let(:params) do
      {
        user: {
          email: user.email,
          password: user.password
        }
      }
    end

    context 'when params are correct' do
      before do
        post url, params: params.to_json, headers: { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' }
      end

      it 'returns 200' do
        expect(response).to have_http_status(200)
      end

      it 'returns JTW token in authorization header' do
        expect(response.headers['authorization']).to be_present
      end

    end

    context 'when login params are incorrect' do
      before { post url }

      it 'returns unathorized status' do
        expect(response.status).to eq 401
      end
    end

  end

  RSpec.describe 'DELETE /logout', type: :request do
    let(:url) { '/users/sign_out' }

    it 'returns 204, no content' do
      delete url
      expect(response).to have_http_status(201)
    end
  end

I need to pass the user's token on delete, any suggestions on how I can be doing this?


问:
Visual studio code don't use the npm version set by nvm + node config
I have not seen any solution for this.

I have some different node installations I set using the nvm 'use' command.
A cmd window shows me the right answers for version request for node & npm
However, visual studio code seems to use the current node version but the latest npm, so....

I have problems for use a particular 'old' app that use node 12 and npm 6.14
The npm 9.1.3 version is the node 16 installed version....

Visual studio code sais me the I have node 12 and npm 9 (instead npm 6)

Any idea to fix this ? Thanks in advance


问:
Linq to SQL producing LEFT JOIN instead of OUTER APPLY
I wrote following query which produces an OUTER APPLY when translated to SQL

```<code>Users.Where(u => !u.IsDeleted).Select(u => new
{
    User = u,
    Requests = OfficeRequests.Where(x => x.BuildingId == 1 && x.RequestedDate >= DateTime.UtcNow.Date).ToList()
})
</code>```

But when the condition User.UserId == OfficeRequest.UserId is included the resulting sql turns into LEFT JOIN instead of OUTER APPLY

```<code>Users.Where(u => !u.IsDeleted).Select(u => new
{
    User = u,
    Requests = OfficeRequests.Where(x => x.BuildingId == 1 && x.UserId == u.UserId && x.RequestedDate >= DateTime.UtcNow.Date).ToList()
})
</code>```

Is there a way to force outer apply in translated sql query?

Body:
I wrote following query which produces an OUTER APPLY when translated to SQL

Users.Where(u => !u.IsDeleted).Select(u => new
{
    User = u,
    Requests = OfficeRequests.Where(x => x.BuildingId == 1 && x.RequestedDate >= DateTime.UtcNow.Date).ToList()
})

But when the condition User.UserId == OfficeRequest.UserId is included the resulting sql turns into LEFT JOIN instead of OUTER APPLY

Users.Where(u => !u.IsDeleted).Select(u => new
{
    User = u,
    Requests = OfficeRequests.Where(x => x.BuildingId == 1 && x.UserId == u.UserId && x.RequestedDate >= DateTime.UtcNow.Date).ToList()
})

Is there a way to force outer apply in translated sql query?


问:
JSESSION ID changing after post request
I have an application running in tomcat server and have a domain like www.foo.com which I have exposed a rest endpoint for a third party application running in a different domain like www.acme.com.

So I have enabled cross origin call from www.acme.com to www.foo.com, however something weird is happening. During the first post request everything is normal, however the succeeding request after two mins changes the JSESSION_ID of the user in the browser. I checked on my application and I didn't see any settings that may cause the issue so I'm thinking that there is a setting/configuration in the server level that might cause the issue.

Did I miss any configuration in the application that may cause this to happen?

Title: JSESSION ID changing after post request


问:
Logs from custom logger are not being written to the logfile using config file for logging
I'm using Python's logging module to log an installation script. The logs are being printed to the console, but the log file is being created empty. I'm loading the conf from an external file.

```<code>import logging
import logging.config

LOGGING_CONF = 'logging.conf'
logging.config.fileConfig(LOGGING_CONF, disable_existing_loggers=False,
                          defaults={'log_filename': 'install.log'})
</code>```
```<code>self.logger = logging.getLogger('install')
self.logger.info("install()")
</code>```

The config file logging.conf has the following config

```<code>[loggers]
keys=root,install

[handlers]
keys=consoleHandler,fileHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[logger_install]
level=DEBUG
handlers=fileHandler
qualname=test.install
propagate=0

[handler_fileHandler]
class=FileHandler
level=INFO
formatter=simpleFormatter
args=('%(log_filename)s','w')

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
</code>```

The install.log is always created empty. No matter what handler I select in the logging.conf it only writes to the console.

Body:
I'm using Python's logging module to log an installation script. The logs are being printed to the console, but the log file is being created empty. I'm loading the conf from an external file.

import logging
import logging.config

LOGGING_CONF = 'logging.conf'
logging.config.fileConfig(LOGGING_CONF, disable_existing_loggers=False,
                          defaults={'log_filename': 'install.log'})

self.logger = logging.getLogger('install')
self.logger.info("install()")

The config file logging.conf has the following config

[loggers]
keys=root,install

[handlers]
keys=consoleHandler,fileHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[logger_install]
level=DEBUG
handlers=fileHandler
qualname=test.install
propagate=0

[handler_fileHandler]
class=FileHandler
level=INFO
formatter=simpleFormatter
args=('%(log_filename)s','w')

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=

The install.log is always created empty. No matter what handler I select in the logging.conf it only writes to the console.


问:
unable to load the specified metadata resource or keyword not supported data source
I have am app that connects to a database in EF6 with code first.
It used to work fine, but after several years not using it now I am facing a problem in connecting to the DB.

I tried modifying the connection string but in this case I get unable to load the specified metadata resource

```<code><add name="StrainerContext"
  connectionString="metadata=res://*/NModel.csdl|res://*/NModel.ssdl|res://*/NModel.msl;provider=System.Data.SqlClient;provider connection string="
  Data Source=ESMILCWTL759\localhost;initial catalog=PGMB_NEXT;integrated security=True;
  Pooling=False;
  multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</code>```

while in this case the error will be keyword not supported data source

```<code><add name="StrainerContext" connectionString="data source=localhost\SQLEXPRESS;initial catalog=PGMB_NEXT;persist security info=True;multipleactiveresultsets=True;App=EntityFramework""providerName="System.Data.EntityClient" />
</code>```

The db exist and I can access it
Any ideas of what do I have to change?

Body:
I have am app that connects to a database in EF6 with code first.
It used to work fine, but after several years not using it now I am facing a problem in connecting to the DB.

I tried modifying the connection string but in this case I get unable to load the specified metadata resource

<add name="StrainerContext"
  connectionString="metadata=res://*/NModel.csdl|res://*/NModel.ssdl|res://*/NModel.msl;provider=System.Data.SqlClient;provider connection string="
  Data Source=ESMILCWTL759\localhost;initial catalog=PGMB_NEXT;integrated security=True;
  Pooling=False;
  multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />

while in this case the error will be keyword not supported data source

<add name="StrainerContext" connectionString="data source=localhost\SQLEXPRESS;initial catalog=PGMB_NEXT;persist security info=True;multipleactiveresultsets=True;App=EntityFramework""providerName="System.Data.EntityClient" />

The db exist and I can access it
Any ideas of what do I have to change?


问:
C# Linux get serial port information
I'm connecting with a USB device on a serial port using C# (using Linux Ubuntu). Now, I can connect just fine and communicate with the device. However, whenever i request the serialport.portname or GetPortNames(), I get a name like /dev/ttyUSB0 or whatever.

It works, but I need to specifically identify a device whenever multiple different devices are connected. How can you get a device specific name like "prolific xxx"?

I read a couple of other posts but these were all very Windows specific. Quering the Win32 system manager and such. Is there a Linux specific or more generic way of doing this? Can´t seem to find an answer somehwere online.

Using a bin like lsusb does give me back specific names. So there must be way right?

Title: C# Linux get serial port information


问:
aiohttp broken pipe error when sending multiple requests (~900+)
so when using aiohttp to send multiple requests to a single url (the ratelimit is 50 per sec)
I'm getting ClientOSErros ('broken pipe')
is there a way to avoid this?</p>
```<code>async def send_req(data):
   async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=50), headers=...) as s:
      async with s.put('...') as r:
         if r. status == 200:
            print('sent data successfully')
         elif r. status == 429:
            print('rate limited')

async def main():
   async with tasksio.TaskPool(5_000) as pool:
      for data in data_lists:
         await pool.put(send_req(data))
</code>```
```<code>aiohttp.client_expceptions.ClientOSError
('broken pipe')```
</code>```

Body:
so when using aiohttp to send multiple requests to a single url (the ratelimit is 50 per sec)
I'm getting ClientOSErros ('broken pipe')
is there a way to avoid this?

async def send_req(data):
   async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=50), headers=...) as s:
      async with s.put('...') as r:
         if r. status == 200:
            print('sent data successfully')
         elif r. status == 429:
            print('rate limited')

async def main():
   async with tasksio.TaskPool(5_000) as pool:
      for data in data_lists:
         await pool.put(send_req(data))

aiohttp.client_expceptions.ClientOSError
('broken pipe')```


问:
Checking the rowsums is equal to 1. How is this output possible?
I am building a decision analytic model (markov model). I am trying to check that the sum of all the rows in my transition probability array is equal to 1.
The array is 85 rows, 85 columns and 35 slices,

I use this code

```<code># Set a flag to keep track of whether or not all slices have rowsums equal to 1
all_slices_have_rowsums_equal_to_1 <- FALSE

# Loop through all of the slices in a_P_tunnels
for (i in 1:35) {
  # Find the row sums of the current slice
  row_sums <- rowSums(a_P_tunnels [ , , i])

  # Check if any of the row sums are not equal to 1
  if (any(row_sums != 1)) {
    # Print the slice number and the row sums that are not equal to 1
    cat("Slice", i, "has row sums", row_sums[row_sums != 1], "\n")
  }
}
</code>```

i get this output:

```<code>> # Set a flag to keep track of whether or not all slices have rowsums equal to 1
> all_slices_have_rowsums_equal_to_1 <- FALSE
>
> # Loop through all of the slices in a_P_tunnels
> for (i in 1:35) {
+   # Find the row sums of the current slice
+   row_sums <- rowSums(a_P_tunnels [ , , i])
+
+   # Check if any of the row sums are not equal to 1
+   if (any(row_sums != 1)) {
+     # Print the slice number and the row sums that are not equal to 1
+     cat("Slice", i, "has row sums", row_sums[row_sums != 1], "\n")
+   }
+ }
Slice 1 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 2 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 3 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 4 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 5 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 6 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 7 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 8 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 9 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 10 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 11 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 12 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 13 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 14 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 15 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 16 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 17 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 18 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 19 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 20 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 21 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 22 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 23 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 24 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 25 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 26 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 27 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 28 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 29 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 30 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 31 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 32 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 33 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 34 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 35 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>
</code>```

Why does it print the row if the sum is equal to 1?

Thanks for any help

THis code works:

```<code>

# Loop through all of the slices in a_P_tunnels
for (i in 1:35) {
  # Find the row sums of the current slice
  row_sums <- rowSums(a_P_tunnels [ , , i])

  # Check if any of the row sums are not equal to 1
  # with a tolerance of 5 decimal places
  if (!isTRUE(all.equal(row_sums, 1, tolerance = 1e-5))) {
    # Instead of comparing the row sums directly to 1,
    # compute the absolute difference between each row sum and 1
    # and check if any of the differences are greater than the tolerance
    differences <- abs(row_sums - 1)
    if (any(differences > 1e-5)) {
      # Print the slice number and the row sums that are not equal to 1
      # with 4 decimal places
      cat("Slice", i, "has row sums", format(round(row_sums[differences > 1e-5], 4), nsmall = 20), "\n")
    }
  }
}

</code>```

Body:
I am building a decision analytic model (markov model). I am trying to check that the sum of all the rows in my transition probability array is equal to 1.
The array is 85 rows, 85 columns and 35 slices,

I use this code

# Set a flag to keep track of whether or not all slices have rowsums equal to 1
all_slices_have_rowsums_equal_to_1 <- FALSE

# Loop through all of the slices in a_P_tunnels
for (i in 1:35) {
  # Find the row sums of the current slice
  row_sums <- rowSums(a_P_tunnels [ , , i])

  # Check if any of the row sums are not equal to 1
  if (any(row_sums != 1)) {
    # Print the slice number and the row sums that are not equal to 1
    cat("Slice", i, "has row sums", row_sums[row_sums != 1], "\n")
  }
}

i get this output:

> # Set a flag to keep track of whether or not all slices have rowsums equal to 1
> all_slices_have_rowsums_equal_to_1 <- FALSE
>
> # Loop through all of the slices in a_P_tunnels
> for (i in 1:35) {
+   # Find the row sums of the current slice
+   row_sums <- rowSums(a_P_tunnels [ , , i])
+
+   # Check if any of the row sums are not equal to 1
+   if (any(row_sums != 1)) {
+     # Print the slice number and the row sums that are not equal to 1
+     cat("Slice", i, "has row sums", row_sums[row_sums != 1], "\n")
+   }
+ }
Slice 1 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 2 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 3 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 4 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 5 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 6 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 7 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 8 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 9 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 10 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 11 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 12 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 13 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 14 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 15 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 16 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 17 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 18 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 19 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 20 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 21 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 22 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 23 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 24 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 25 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 26 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 27 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 28 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 29 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 30 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 31 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 32 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 33 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 34 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Slice 35 has row sums 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
>

Why does it print the row if the sum is equal to 1?

Thanks for any help

THis code works:

# Loop through all of the slices in a_P_tunnels
for (i in 1:35) {
  # Find the row sums of the current slice
  row_sums <- rowSums(a_P_tunnels [ , , i])

  # Check if any of the row sums are not equal to 1
  # with a tolerance of 5 decimal places
  if (!isTRUE(all.equal(row_sums, 1, tolerance = 1e-5))) {
    # Instead of comparing the row sums directly to 1,
    # compute the absolute difference between each row sum and 1
    # and check if any of the differences are greater than the tolerance
    differences <- abs(row_sums - 1)
    if (any(differences > 1e-5)) {
      # Print the slice number and the row sums that are not equal to 1
      # with 4 decimal places
      cat("Slice", i, "has row sums", format(round(row_sums[differences > 1e-5], 4), nsmall = 20), "\n")
    }
  }
}


问:
Dictionary key is no found when starting python module from another script
I'm not sure, if this is related to Can't find module when running python script from another python script.

However, if I run my python script directly I have no issues, but when I start it from another script, I get an error:
'Non-existent config key: model.kwargs.backbone_config.kwargs.input_height'

Even though the key can be found if I run the file directly.
However, if I try to execute the following code:

```<code>    try:
         config.merge_from_file('{base}/HoHoNet/config/s2d3d_sem/HOHO_depth_dct_efficienthc_TransEn1_h1024_fold1_resnet101rgb.yaml'.format(base = os.getcwd()))
    except Exception as e:
        print(e)
        return 1
</code>```

where my config is taken from yacs.config.

Body:
I'm not sure, if this is related to Can't find module when running python script from another python script.

However, if I run my python script directly I have no issues, but when I start it from another script, I get an error:
'Non-existent config key: model.kwargs.backbone_config.kwargs.input_height'

Even though the key can be found if I run the file directly.
However, if I try to execute the following code:

    try:
         config.merge_from_file('{base}/HoHoNet/config/s2d3d_sem/HOHO_depth_dct_efficienthc_TransEn1_h1024_fold1_resnet101rgb.yaml'.format(base = os.getcwd()))
    except Exception as e:
        print(e)
        return 1

where my config is taken from yacs.config.