问:
ArtifactDescriptorException when running a clojure hello world in a docker container
I'm getting ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:clojure:jar when running a literal hello world program using the command clojure -M file.clj in a docker container. No issue doing it locally. Some googling suggests it might be a maven issue but there're no dependencies so I don't see why it's trying to get anything from a maven repo.

Full error output:

```<code>org.clojure:clojure:jar:1.10.2
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:clojure:jar:1.10.2
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:255)
at clojure.tools.deps.alpha.extensions.maven$eval1068$fn__1070.invoke(maven.clj:107)
at clojure.lang.MultiFn.invoke(MultiFn.java:244)
at clojure.tools.deps.alpha$expand_deps$children_task__785$fn__787$fn__788.invoke(alpha.clj:403)
at clojure.tools.deps.alpha.util.concurrent$submit_task$task__502.invoke(concurrent.clj:34)
at clojure.lang.AFn.call(AFn.java:18)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.clojure:clojure:pom:1.10.2 from/to central (https://repo1.maven.org/maven2/): repo1.maven.org: Temporary failure in name resolution
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.clojure:clojure:pom:1.10.2 from/to central (https://repo1.maven.org/maven2/): repo1.maven.org: Temporary failure in name resolution
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:628)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:499)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
... 14 more
Caused by: java.net.UnknownHostException: repo1.maven.org: Temporary failure in name resolution
at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1529)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1519)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1378)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1306)
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:164)
at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:290)
at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:246)
at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:457)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364)
... 19 more
</code>```

Body:
I'm getting ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:clojure:jar when running a literal hello world program using the command clojure -M file.clj in a docker container. No issue doing it locally. Some googling suggests it might be a maven issue but there're no dependencies so I don't see why it's trying to get anything from a maven repo.

Full error output:

org.clojure:clojure:jar:1.10.2
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:clojure:jar:1.10.2
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:255)
at clojure.tools.deps.alpha.extensions.maven$eval1068$fn__1070.invoke(maven.clj:107)
at clojure.lang.MultiFn.invoke(MultiFn.java:244)
at clojure.tools.deps.alpha$expand_deps$children_task__785$fn__787$fn__788.invoke(alpha.clj:403)
at clojure.tools.deps.alpha.util.concurrent$submit_task$task__502.invoke(concurrent.clj:34)
at clojure.lang.AFn.call(AFn.java:18)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.clojure:clojure:pom:1.10.2 from/to central (https://repo1.maven.org/maven2/): repo1.maven.org: Temporary failure in name resolution
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.clojure:clojure:pom:1.10.2 from/to central (https://repo1.maven.org/maven2/): repo1.maven.org: Temporary failure in name resolution
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:628)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:499)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
... 14 more
Caused by: java.net.UnknownHostException: repo1.maven.org: Temporary failure in name resolution
at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1529)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1519)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1378)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1306)
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:263)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:164)
at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:290)
at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:246)
at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:457)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364)
... 19 more


来源: stackexchange

问:
How do I concatenate these strings in vim?
I have two string variables:

```<code>let url = "https://URL/path/to/repo"
let branch = "GIT-HASH"
</code>```

I want to concatentate them and echo it on the shell:

```<code>let result = url . branch
exec '!echo '.result
</code>```

I only ever see url in the output, and never branch. I can echo branch by itself and that works, I can put branch before url and that works, but url . branch does not work. url .. branch produces the same result. Why isn't this working?

Vim version is compiled from v8.2.4236

ContentLicense: CC BY-SA 4.0

Body:
I have two string variables:

let url = "https://URL/path/to/repo"
let branch = "GIT-HASH"

I want to concatentate them and echo it on the shell:

let result = url . branch
exec '!echo '.result

I only ever see url in the output, and never branch. I can echo branch by itself and that works, I can put branch before url and that works, but url . branch does not work. url .. branch produces the same result. Why isn't this working?

Vim version is compiled from v8.2.4236


问:
Multiple python scripts edit txt file
I am developing an app, in which two scripts have access to single txt file. The first script should be writing some data (each in new line) every minute or so, and the second one would read this data, work with it and after that delete it or edit the line. What would happened if first script writes new data and at the same time second script edits some other data in the file. I think there would be some kind of collision, which I can’t afford to have.

How to overcome this problem

Title: Multiple python scripts edit txt file


问:
Where do I find Firestore index error details?
I'm getting this error in the console when running my application in production:

{"code":"failed-precondition","name":"FirebaseError"}

I'm assuming this is a firestore index or rules error, but there are no details around which query is causing the problem. Firebase used to put a URL in the console to build missing indexes, but that feature seems to be gone.

Everything works as expected with no errors when running on an emulator.


问:
Spring cloud config server setting for logging are never picked up
I have a spring cloud config client and server. I have added some logging-logback settings in the application.yaml of client and I have a different setting under config server. I see that the settings from server are never picked. Can somebody please help. I tried with different versions of spring boot and cloud but observe the same behaviour everywhere.

Please note, I only have issues with the logback.rollingpolicy.max-file-size
All other properties are picked from config-server

My application.yaml in the client

```<code>logging:
  level:
    root: info
  file:
    path: /Users/abc/demo/src/main/resources/logs
    name: application
  logback:
    rollingpolicy:
      max-file-size: 1MB
</code>```

My bootstrap.yaml

```<code>spring:
  cloud:
    config:
      enabled: true
      uri: http://localhost:8402
  application:
    name: demo
</code>```

My demo.yaml in cloud config server

```<code>logging:
  level:
    root: info
  file:
    path: /Users/abc/demo/src/main/resources/logs
  name: demo
  logback:
    rollingpolicy:
      max-file-size: 500KB
</code>```

Body:
I have a spring cloud config client and server. I have added some logging-logback settings in the application.yaml of client and I have a different setting under config server. I see that the settings from server are never picked. Can somebody please help. I tried with different versions of spring boot and cloud but observe the same behaviour everywhere.

Please note, I only have issues with the logback.rollingpolicy.max-file-size
All other properties are picked from config-server

My application.yaml in the client

logging:
  level:
    root: info
  file:
    path: /Users/abc/demo/src/main/resources/logs
    name: application
  logback:
    rollingpolicy:
      max-file-size: 1MB

My bootstrap.yaml

spring:
  cloud:
    config:
      enabled: true
      uri: http://localhost:8402
  application:
    name: demo

My demo.yaml in cloud config server

logging:
  level:
    root: info
  file:
    path: /Users/abc/demo/src/main/resources/logs
  name: demo
  logback:
    rollingpolicy:
      max-file-size: 500KB


问:
Using aws emr add-steps for spark-submit
We have a complicated spark-submit command that we would like to submit to AWS EMR using the aws emr add-steps CLI command.  We are having trouble figuring out the correct syntax to use.  For example, consider the example command from Apache's Running Spark on YARN page:

```<code>$ ./bin/spark-submit --class my.main.Class \
    --master yarn \
    --deploy-mode cluster \
    --jars my-other-jar.jar,my-other-other-jar.jar \
    my-main-jar.jar \
    app_arg1 app_arg2
</code>```

Following the guidance from this EMR command-runner page, we created something like this:

```<code>$ aws emr add-steps\
--cluster-id j-123456789 \
--steps Type=CUSTOM_JAR,Name='Test_Job',Jar='command-runner.jar',ActionOnFailure=CONTINUE,Args=[\
./bin/spark-submit,\
--class,my.main.Class,\
--master,yarn,\
--deploy-mode cluster,\
--jars,my-other-jar.jar,my-other-other-jar.jar,my-main-jar.jar,app_arg1,app_arg2]
</code>```

However, due to the apparent parsing at commas, the command appears to only associate --jars with "my-other-jar", whereas "my-other-other-jar" is not.  I'm hoping somebody can tell us the proper syntax to use.  For example, should we use --jars for each extra jar, like:

```<code>--jars,my-other-jar.jar,--jars,my-other-other-jar.jar
</code>```

or maybe there is some special list syntax, e.g.,

```<code>--jars,[my-other-jar.jar,my-other-other-jar.jar]
</code>```

or something else.  Can anybody tell us, or point us to, the correct syntax to use for spark-submit arguments that might take a list, i.e., not just --jars, but also --conf, --files, ...?

Body:
We have a complicated spark-submit command that we would like to submit to AWS EMR using the aws emr add-steps CLI command.  We are having trouble figuring out the correct syntax to use.  For example, consider the example command from Apache's Running Spark on YARN page:

$ ./bin/spark-submit --class my.main.Class \
    --master yarn \
    --deploy-mode cluster \
    --jars my-other-jar.jar,my-other-other-jar.jar \
    my-main-jar.jar \
    app_arg1 app_arg2

Following the guidance from this EMR command-runner page, we created something like this:

$ aws emr add-steps\
--cluster-id j-123456789 \
--steps Type=CUSTOM_JAR,Name='Test_Job',Jar='command-runner.jar',ActionOnFailure=CONTINUE,Args=[\
./bin/spark-submit,\
--class,my.main.Class,\
--master,yarn,\
--deploy-mode cluster,\
--jars,my-other-jar.jar,my-other-other-jar.jar,my-main-jar.jar,app_arg1,app_arg2]

However, due to the apparent parsing at commas, the command appears to only associate --jars with "my-other-jar", whereas "my-other-other-jar" is not.  I'm hoping somebody can tell us the proper syntax to use.  For example, should we use --jars for each extra jar, like:

--jars,my-other-jar.jar,--jars,my-other-other-jar.jar

or maybe there is some special list syntax, e.g.,

--jars,[my-other-jar.jar,my-other-other-jar.jar]

or something else.  Can anybody tell us, or point us to, the correct syntax to use for spark-submit arguments that might take a list, i.e., not just --jars, but also --conf, --files, ...?


问:
how to transfer the ownership, usability, etc of a database from postgres user to normal user
I was learning PostgreSQL like a year ago and started to fill information on a database that the Postgres user was the owner. This data is a lot, and now I want to move it to production but as is known this is a very bad practice, so I created another user and ran the command

```<code>ALTER DATABASE modelos_vehiculos OWNER TO new_user;
</code>```

To transfer the ownership to the new user. The response on psql was

```<code>ALTER DATABASE
</code>```

But now when I try to log with the new user, it says that the user have no permission. I saw on pgadmin and the new user is the owner, but this can't do anything on the database neither SELECT, INSERT,...

How can I concede all the permissions to this user?

I also saw that the correct way to do this is with this command instead of the ALTER one

```<code>REASSIGN OWNED BY old_name TO new_name;
</code>```

But this command can't be used when the owner is the Postgres user because It will transfer all the databases to the user, including the databases used by Postgres to operate.

Body:
I was learning PostgreSQL like a year ago and started to fill information on a database that the Postgres user was the owner. This data is a lot, and now I want to move it to production but as is known this is a very bad practice, so I created another user and ran the command

ALTER DATABASE modelos_vehiculos OWNER TO new_user;

To transfer the ownership to the new user. The response on psql was

ALTER DATABASE

But now when I try to log with the new user, it says that the user have no permission. I saw on pgadmin and the new user is the owner, but this can't do anything on the database neither SELECT, INSERT,...

How can I concede all the permissions to this user?

I also saw that the correct way to do this is with this command instead of the ALTER one

REASSIGN OWNED BY old_name TO new_name;

But this command can't be used when the owner is the Postgres user because It will transfer all the databases to the user, including the databases used by Postgres to operate.


问:
Working in PythonAnywhere: CSS files load, but Javascript does not work
My static files are directing to the correct place since my CSS files are loading. However, I have a JS file that works locally and on codepen, but not on the browser. I have tried placing my JS files in a different folder and directing there and I have changed the script src (from /static/button.js to https://www.yoginib.org/static/button.js) - Neither of these have worked. I am not getting any errors when I check developer tools either.

I am not experienced with jQuery or PythonAnywhere so I am not sure what else to try.

I have some animations on the buttons, so I am not sure if that's affecting the functionality.

This is the HTML (where I reference the JS:

This is also the HTML, showing the buttons that I want to affect using JS:

This is the JavaScript:

This is a screenshot of the buttons on the actual webpage and the text underneath, which should change to different text with a button click:

This is the link to the webpage: https://www.yoginib.org/arena.html


问:
how to get the src file to be processed by annotation processor/annotation processing tool?
I have a need to keep original source file unchanged after annotation processing, is it possible to get the original file stored in a/b/c/A.java to before being processed?

for example I have a class:

```<code>@xxx
class A {
}
</code>```

I would like to get the original source code of the file before being processed. i tried to use
processingEnv.getFiler().getResource but it does not seem to work
Thanks.

Body:
I have a need to keep original source file unchanged after annotation processing, is it possible to get the original file stored in a/b/c/A.java to before being processed?

for example I have a class:

@xxx
class A {
}

I would like to get the original source code of the file before being processed. i tried to use
processingEnv.getFiler().getResource but it does not seem to work
Thanks.


问:
How do I parse iso8601-2004 datetimes into datetime following current iso8601 standard
I am currently making request to an API which include the 24:00 as a valid datetime.
Meaning a possible response from a get request might be 2022-11-21T24:00:00.000Z

Which I cannot parse into a System.Datetime, as it follows the Iso8601 standard which currently don't support this timestamp, but did so in version 2004.

The json response is deserialized using system.text.json deserializers
How do I properly handle this case?
in a simple manner

For those stating it is a duplicate, please consider that the day/month/year also have to be changed when going from 2022-11-21T24:00:00.000Z -> 2022-11-22T00:00:00.000Z when adding an hour like this, which the current dupplicate doesn't seem to cover.

In general this has was allowed using the iso8601-2004 version, but removed in the current version.
https://www.iso.org/obp/ui/#iso:std:iso:8601:-1:ed-1:v1:en

So what do i do to handle this in between persiod?


问:
How to reset a ReactJS app to its initial state?
I have built a multistep wizard to allow people to configure a smart device. When the user has completed the wizard, they may need to configure another device so I send them back to the first step in the wizard. The problem is that whatever page I am on will reflect its most recent screen state, and I want to be able to reset the entire app back to its default state, which obviously includes having all of its pages reset back to their initial states. How can I reset the app itself back to its original default state? I am using React 18.2.0.

The shape of the app is like this. Each step is a route to a component which can contain multiple screens:

```<code><IonApp>
    <IonReactRouter>
      <IonSplitPane contentId="main" when="xs">
        <Menu />
        <IonRouterOutlet id="main">
          <Route path="/bluetooth" exact={true}>
            <Bluetooth />
          </Route>
          <Route path="/wifi" exact={true}>
            <WiFi />
          </Route>
          <Route path="/initialize" exact={true}>
            <Initialize />
          </Route>
        </IonRouterOutlet>
      </IonSplitPane>
    </IonReactRouter>
  </IonApp>
</code>```

Body:
I have built a multistep wizard to allow people to configure a smart device. When the user has completed the wizard, they may need to configure another device so I send them back to the first step in the wizard. The problem is that whatever page I am on will reflect its most recent screen state, and I want to be able to reset the entire app back to its default state, which obviously includes having all of its pages reset back to their initial states. How can I reset the app itself back to its original default state? I am using React 18.2.0.

The shape of the app is like this. Each step is a route to a component which can contain multiple screens:

<IonApp>
    <IonReactRouter>
      <IonSplitPane contentId="main" when="xs">
        <Menu />
        <IonRouterOutlet id="main">
          <Route path="/bluetooth" exact={true}>
            <Bluetooth />
          </Route>
          <Route path="/wifi" exact={true}>
            <WiFi />
          </Route>
          <Route path="/initialize" exact={true}>
            <Initialize />
          </Route>
        </IonRouterOutlet>
      </IonSplitPane>
    </IonReactRouter>
  </IonApp>


问:
how to perform event handling in android?
I am trying to develop an application who can identify the user interaction with android device's UI. I have used a concept, something called as broadcast receiver for it, but it didn't work.
   Is there any other way in android to handle events through our application..?

Regards...

ContentLicense: CC BY-SA 3.0


问:
Why am I getting different responses on the same Curl request?
I have two vps, when I do curl --verbose https://es.aliexpress.com/item/1005004830406404.html

different things happen, on a server it returns the response correctly with the following header

https://hastebin.com/onifayedam.yaml

but on the other server, newly configured it returns 404 with the following header

https://hastebin.com/okibilihir.php-template

I have tried to reinstall the certificates, even to reinstall the operating system from 0 without any result.
I would be grateful for any help or recommendation.


问:
Power BI reports transfer from tenant to tenant
How to transfer Power BI reports from one tenant to other tenant?

Looking out for a detailed procedure of migrating Power BI reports from one tenant to tenant.


问:
NextJS Image switch based on condition not working on production
In my nextjs-application I have a Header with a logo, that needs to switch based on a condition. I use the next/image component and the website is hosted by netlify.

```<code>const Header= () => {
   const [fullWidthBackground, setFullWidthBackground] = useState(false)
   const scrollPosition = useScrollPosition()

   useEffect(() => {
      const isFullWidth = document.body.classList.contains('full-width-hero-background')

      if (isFullWidth) {
         setFullWidthBackground(true)
       } else {
         setFullWidthBackground(false)
       }
     }, [fullWidthBackground])

   return (
     <div>
        <Link href={'/'}>
           <div
              className={`${
                 fullWidthBackground && scrollPosition === 0
                 ? 'flex items-center opacity-100'
                 : 'hidden opacity-0'
              }`}
           >
           <Image
               src="/white-logo.png"
               alt=""
               width={168}
               height={26}
          />
         </div>
         <div
            className={`${
               !fullWidthBackground || scrollPosition > 0
               ? 'flex items-center opacity-100'
               : 'hidden opacity-0'
            }`}
         >
          <Image
            src="/dark-logo.png"
            alt=""
            width={168}
            height={26}
          />
        </div>
      </Link>
     </div>
   )
})
</code>```

This works only on localhost but when I run npm run build it doesn't work.

Can someone maybe help me out? Is it because of the <Link>?

Body:
In my nextjs-application I have a Header with a logo, that needs to switch based on a condition. I use the next/image component and the website is hosted by netlify.

const Header= () => {
   const [fullWidthBackground, setFullWidthBackground] = useState(false)
   const scrollPosition = useScrollPosition()

   useEffect(() => {
      const isFullWidth = document.body.classList.contains('full-width-hero-background')

      if (isFullWidth) {
         setFullWidthBackground(true)
       } else {
         setFullWidthBackground(false)
       }
     }, [fullWidthBackground])

   return (

        <Link href={'/'}>

           <Image
               src="/white-logo.png"
               alt=""
               width={168}
               height={26}
          />

 0
               ? 'flex items-center opacity-100'
               : 'hidden opacity-0'
            }`}
         >
          <Image
            src="/dark-logo.png"
            alt=""
            width={168}
            height={26}
          />

      </Link>

   )
})

This works only on localhost but when I run npm run build it doesn't work.

Can someone maybe help me out? Is it because of the <Link>?


问:
Infopath Repeating Table Replacing Looked Up Values in all Rows; Values Based on Two Seperate Fields
Here's the thought process and believe it or not I had it working and then it broke, now I am not sure why or how to fix it.

I have a secondary data source that is housed in a SharePoint list that contains billing rates for various tiers depending on the customer.

When you initially select a Tier and then the subsequent Positions under the daily billing area all is fine and dandy and values look up as they should.

However as is often the case someone will input the wrong Tier for the billing sheet and it would need to be changed to reflect the actual Tier. When this happens InfoPath is grabbing the value from the first row for the lookup and making it the value for all the position rate fields in the repeating table.

You can change them back, by selecting a different position and going back to the original position, however that is another step.

Seriously, this is the last bit for me to sort out before I can put this project behind me. I've included some screenshots of the groups and how they are laid out and the rules I have setup.

```<code>[Rules for Rate Tier field](https://i.stack.imgur.com/DO7e4.png)
[Rules for Position field](https://i.stack.imgur.com/JF8bh.png)
[Groups and Fields layout](https://i.stack.imgur.com/7etEq.png)
[Example of issue I am having](https://i.stack.imgur.com/aKD3t.gif)
</code>```

I've tried everything from filtering the rate returned by the Position in the secondary source matching to the Position in the form which is activated conditionally when the Rate Tier equals a specific Tier. I've tried eval which I am not familiar with so I either got true or false but it never returned field contents.

Body:
Here's the thought process and believe it or not I had it working and then it broke, now I am not sure why or how to fix it.

I have a secondary data source that is housed in a SharePoint list that contains billing rates for various tiers depending on the customer.

When you initially select a Tier and then the subsequent Positions under the daily billing area all is fine and dandy and values look up as they should.

However as is often the case someone will input the wrong Tier for the billing sheet and it would need to be changed to reflect the actual Tier. When this happens InfoPath is grabbing the value from the first row for the lookup and making it the value for all the position rate fields in the repeating table.

You can change them back, by selecting a different position and going back to the original position, however that is another step.

Seriously, this is the last bit for me to sort out before I can put this project behind me. I've included some screenshots of the groups and how they are laid out and the rules I have setup.

[Rules for Rate Tier field](https://i.stack.imgur.com/DO7e4.png)
[Rules for Position field](https://i.stack.imgur.com/JF8bh.png)
[Groups and Fields layout](https://i.stack.imgur.com/7etEq.png)
[Example of issue I am having](https://i.stack.imgur.com/aKD3t.gif)

I've tried everything from filtering the rate returned by the Position in the secondary source matching to the Position in the form which is activated conditionally when the Rate Tier equals a specific Tier. I've tried eval which I am not familiar with so I either got true or false but it never returned field contents.


问:
How run Varnish on Port 80 on Plesk + CentOS while Nginx on port 8080?
Following the answer posted on SOF to change the Nginx default port on Plesk from 80 to 8080 while running Varnish on Port 80

I've worked on both options then stopped nginx to start varnish on port 80 however nginx refuses to run keep asking to run on port 80

```<code>-- Unit nginx.service has begun starting up.
Dec 14 22:58:17 server.example.com nginx[53793]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 14 22:58:17 server.example.com nginx[53793]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Dec 14 22:58:17 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)
Dec 14 22:58:18 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)
Dec 14 22:58:18 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)
</code>```

Please note that Apache is running on port 7080 also.

Is there a better guaranteed solution?

Body:
Following the answer posted on SOF to change the Nginx default port on Plesk from 80 to 8080 while running Varnish on Port 80

I've worked on both options then stopped nginx to start varnish on port 80 however nginx refuses to run keep asking to run on port 80

-- Unit nginx.service has begun starting up.
Dec 14 22:58:17 server.example.com nginx[53793]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 14 22:58:17 server.example.com nginx[53793]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Dec 14 22:58:17 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)
Dec 14 22:58:18 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)
Dec 14 22:58:18 server.example.com nginx[53796]: nginx: [emerg] bind() to 127.0.0.1:80 failed (98: Address already in use)

Please note that Apache is running on port 7080 also.

Is there a better guaranteed solution?


问:
Simulate actioncable websocket receive in webdriverIo
Is there a way during webdriverio runtime to simulate an actioncable receive?

I am using a fork of the package action-cable-react called actioncable-js-jwt for Rails actioncable js connections. Both of these packages are no longer maintained, but actioncable-js-jwt was the only actioncable for react package I could find that supported jwt authentication. I am building an app in my company's platform and jwt authentication is required.

The problem I am running into is that I have a react component which dispatches a redux action to call an api. The api returns a 204, and the resulting data is broadcasted out from Rails to be received by the actioncable connection. This triggers a dispatch to update the redux store with new data. The component does actions based on new data compared to the initial value on component load, so I cannot simply just set initial redux state for wdio - I need to mock the actioncable receive happening.

The way the actioncable subscription is created is:

```<code>export const createChannelSubscription = (cable, receivedCallback, dispatch, channelName) => {
  let subscription;

  try {
    subscription = cable.subscriptions.create(
      { channel: channelName },
      {
        connected() {},
        disconnected(res) { disconnectedFromWebsocket(res, dispatch); },
        received(data) { receivedCallback(data, dispatch); },
      },
    );
  } catch (e) {
    throw new Error(e);
  }

  return subscription;
};
</code>```

The receivedCallback function is different for each channel, but for example the function might look like:

```<code>export const handleUpdateRoundLeaderWebsocket = (data, dispatch) => {
  dispatch({ type: UPDATE_ROUNDING_LEADER, round: data });
};
</code>```

And the redux state is used here (code snippets):

```<code>  const [currentLeader, setCurrentLeader] = useState(null);
  const userId = useSelector((state) => state.userId);
  const reduxStateField = useSelector((state) => state.field);

  const onChange = useCallback((id) => {
    if (id !== currentLeader) {
      if (id !== userId && userId === currentLeader) {
        setShow(true);
      } else {
        setCurrentLeader(leaderId);
      }
    }
  }, [currentLeader, userId]);

  useEffect(() => {
    onChange(id);
  }, [reduxStateField.id, onChange]);
</code>```

Finally, my wdio test currently looks like:

```<code>    it('has info dialog', () => {
      browser.url('<base-url>-rounding-list-view');
      $('#my-button').click();
      $('div=Continue').click();
      // need new state after the continue click
      // based on new state, might show an info dialog
    });
</code>```

Alternatively, I could look into manually updating redux state during wdio execution - but I don't know how to do that and can't find anything on google except on how to provide initial redux state.

Body:
Is there a way during webdriverio runtime to simulate an actioncable receive?

I am using a fork of the package action-cable-react called actioncable-js-jwt for Rails actioncable js connections. Both of these packages are no longer maintained, but actioncable-js-jwt was the only actioncable for react package I could find that supported jwt authentication. I am building an app in my company's platform and jwt authentication is required.

The problem I am running into is that I have a react component which dispatches a redux action to call an api. The api returns a 204, and the resulting data is broadcasted out from Rails to be received by the actioncable connection. This triggers a dispatch to update the redux store with new data. The component does actions based on new data compared to the initial value on component load, so I cannot simply just set initial redux state for wdio - I need to mock the actioncable receive happening.

The way the actioncable subscription is created is:

export const createChannelSubscription = (cable, receivedCallback, dispatch, channelName) => {
  let subscription;

  try {
    subscription = cable.subscriptions.create(
      { channel: channelName },
      {
        connected() {},
        disconnected(res) { disconnectedFromWebsocket(res, dispatch); },
        received(data) { receivedCallback(data, dispatch); },
      },
    );
  } catch (e) {
    throw new Error(e);
  }

  return subscription;
};

The receivedCallback function is different for each channel, but for example the function might look like:

export const handleUpdateRoundLeaderWebsocket = (data, dispatch) => {
  dispatch({ type: UPDATE_ROUNDING_LEADER, round: data });
};

And the redux state is used here (code snippets):

  const [currentLeader, setCurrentLeader] = useState(null);
  const userId = useSelector((state) => state.userId);
  const reduxStateField = useSelector((state) => state.field);

  const onChange = useCallback((id) => {
    if (id !== currentLeader) {
      if (id !== userId && userId === currentLeader) {
        setShow(true);
      } else {
        setCurrentLeader(leaderId);
      }
    }
  }, [currentLeader, userId]);

  useEffect(() => {
    onChange(id);
  }, [reduxStateField.id, onChange]);

Finally, my wdio test currently looks like:

    it('has info dialog', () => {
      browser.url('<base-url>-rounding-list-view');
      $('#my-button').click();
      $('div=Continue').click();
      // need new state after the continue click
      // based on new state, might show an info dialog
    });

Alternatively, I could look into manually updating redux state during wdio execution - but I don't know how to do that and can't find anything on google except on how to provide initial redux state.


问:
Problem loading Private Key in SemaphoreCI - "No start line"
I've got tests that work on my machine (of course!) but don't work in the SemaphoreCI pipeline. Specifically, I'm failing when loading a PEM private key file, which is saved as a Secret in the Semaphore workspace.  Locally, this same key is saved in a .pem file.

Semaphore Error:

```<code>ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).',
    [_OpenSSLErrorWithText(code=151584876, lib=9, reason=108, reason_text=b'error:0909006C:
        PEM routines:get_name:no start line')])00:02
        ../.pyenv/3.8/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/backend.py:1129: ValueError
</code>```

The key in use:

```<code>-----BEGIN PRIVATE KEY-----
MIIJQw   ...    Nd8DkR8iY=
-----END PRIVATE KEY-----
</code>```

The test function:

```<code>
@mock_dynamodb
def test_decrypt_files(monkeypatch):

    dynamo = boto3.resource('dynamodb', region_name=get_region())
    table = dynamo.Table(ded.get_data_table())

    try:
        testing_key = os.environ['k_key']
    except:
        with open('unit_tests/K_key.pem', 'r') as k:
            testing_key = k.read()

    db_insert = table.put_item(Item={'pk': TEST_COMPANY,
                                     'sk': 'ORG#DATA',
                                     'private_key': testing_key
                                    })

    results = ded.decryptEventData(event, {})
</code>```

The function I'm testing:

```<code>import json
import base64
import boto3
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.asymmetric.padding import OAEP
from cryptography.hazmat.primitives.asymmetric import padding as asym_padding
from cryptography.hazmat.primitives.hashes import SHA256
import cryptography.hazmat.primitives.serialization as serialization
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography import exceptions

from utils import *  # private utility file with functions

# AWS Lambda function
def decryptEventData(event, context):

    event_data = event['Event Data']
    file_key = event['file_key']
    RESULTS_BUCKET = event['results_bucket']

    # Get private key
    dbClient = boto3.resource('dynamodb', region_name=get_aws_region())
    table = dbClient.Table(get_data_table())
    org_info = table.get_item(Key={'pk':org, 'sk':'ORG#DATA'})
    K_org = org_info['Item']['private_key'].encode('ascii')

    privkey = load_pem_private_key(K_org, password=None)
    print(privkey)
    # Error here

    # ... more things below
</code>```

In production, the private key is fetched from a DynamoDB entry. In local testing, it's pulled from a K_key.pem file on my machine, directly copy-pasted from Dynamo.  In SemaphoreCI, I made a secret named 'k_key' with the value again a direct copy-paste from Dynamo.

Things I've tried:

I saw a previous SO that mentioned needing \n carriage returns, so I added those.

Key has been saved with and without ''' quotes.

Re-copy-pasted, just in case.

Based on a different SO, In my terminal: $ openssl rsa -text -inform DER -in K_key.pem
Response:

```<code>unable to load Private Key
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:572:
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=RSAPrivateKey
28560:error:04093004:rsa routines:old_rsa_priv_decode:RSA lib:../openssl-1.1.1q/crypto/rsa/rsa_ameth.c:142:
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
</code>```

Just in case I tried it as a RSA key, with $ openssl rsa -text -inform DER -in K_key.pem

Response:

```<code>unable to load Private Key
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:572:
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=RSAPrivateKey
22556:error:04093004:rsa routines:old_rsa_priv_decode:RSA lib:../openssl-1.1.1q/crypto/rsa/rsa_ameth.c:142:
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
</code>```

I opened the file in Notebook and it says its UTF-8

Keys are generated elsewhere, with this, again using Cryptography:

```<code>    # Create keys for file encryption
    private_rsa_key = rsa.generate_private_key(
        public_exponent=65537,
        key_size=4096,
    )
    private_pem_key = private_rsa_key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption()
        ).decode('ascii')
</code>```

Body:
I've got tests that work on my machine (of course!) but don't work in the SemaphoreCI pipeline. Specifically, I'm failing when loading a PEM private key file, which is saved as a Secret in the Semaphore workspace.  Locally, this same key is saved in a .pem file.

Semaphore Error:

ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).',
    [_OpenSSLErrorWithText(code=151584876, lib=9, reason=108, reason_text=b'error:0909006C:
        PEM routines:get_name:no start line')])00:02
        ../.pyenv/3.8/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/backend.py:1129: ValueError

The key in use:

-----BEGIN PRIVATE KEY-----
MIIJQw   ...    Nd8DkR8iY=
-----END PRIVATE KEY-----

The test function:

@mock_dynamodb
def test_decrypt_files(monkeypatch):

    dynamo = boto3.resource('dynamodb', region_name=get_region())
    table = dynamo.Table(ded.get_data_table())

    try:
        testing_key = os.environ['k_key']
    except:
        with open('unit_tests/K_key.pem', 'r') as k:
            testing_key = k.read()

    db_insert = table.put_item(Item={'pk': TEST_COMPANY,
                                     'sk': 'ORG#DATA',
                                     'private_key': testing_key
                                    })

    results = ded.decryptEventData(event, {})

The function I'm testing:

import json
import base64
import boto3
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.asymmetric.padding import OAEP
from cryptography.hazmat.primitives.asymmetric import padding as asym_padding
from cryptography.hazmat.primitives.hashes import SHA256
import cryptography.hazmat.primitives.serialization as serialization
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography import exceptions

from utils import *  # private utility file with functions

# AWS Lambda function
def decryptEventData(event, context):

    event_data = event['Event Data']
    file_key = event['file_key']
    RESULTS_BUCKET = event['results_bucket']

    # Get private key
    dbClient = boto3.resource('dynamodb', region_name=get_aws_region())
    table = dbClient.Table(get_data_table())
    org_info = table.get_item(Key={'pk':org, 'sk':'ORG#DATA'})
    K_org = org_info['Item']['private_key'].encode('ascii')

    privkey = load_pem_private_key(K_org, password=None)
    print(privkey)
    # Error here

    # ... more things below

In production, the private key is fetched from a DynamoDB entry. In local testing, it's pulled from a K_key.pem file on my machine, directly copy-pasted from Dynamo.  In SemaphoreCI, I made a secret named 'k_key' with the value again a direct copy-paste from Dynamo.

Things I've tried:

I saw a previous SO that mentioned needing \n carriage returns, so I added those.

Key has been saved with and without ''' quotes.

Re-copy-pasted, just in case.

Based on a different SO, In my terminal: $ openssl rsa -text -inform DER -in K_key.pem
Response:

unable to load Private Key
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:572:
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=RSAPrivateKey
28560:error:04093004:rsa routines:old_rsa_priv_decode:RSA lib:../openssl-1.1.1q/crypto/rsa/rsa_ameth.c:142:
28560:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
28560:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO

Just in case I tried it as a RSA key, with $ openssl rsa -text -inform DER -in K_key.pem

Response:

unable to load Private Key
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:572:
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=RSAPrivateKey
22556:error:04093004:rsa routines:old_rsa_priv_decode:RSA lib:../openssl-1.1.1q/crypto/rsa/rsa_ameth.c:142:
22556:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
22556:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:309:Type=PKCS8_PRIV_KEY_INFO

I opened the file in Notebook and it says its UTF-8

Keys are generated elsewhere, with this, again using Cryptography:

    # Create keys for file encryption
    private_rsa_key = rsa.generate_private_key(
        public_exponent=65537,
        key_size=4096,
    )
    private_pem_key = private_rsa_key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption()
        ).decode('ascii')


问:
Live Server ENOENT: no such file or directory, open Error
My Live Server extension stopped working after reinstalling node js. In the runtime status tab of the extension, it says ENOENT: no such file or directory, open. It does not open browser, go live button doesn't work as well. I tried adding Windows/system32 to Path in environment viarables, it used to work before, but not this time. What could be the issue? My npm commands work fine, typescript also works.

Tried reinstalling live server - didn't work. Tried updating it- didn't work. Tried reinstalling node, no result. Tried clearing the npm cache - no result. Tried setting env variable path to windows/system32, also no result.


问:
Is there any way to enable "re-run previous" in vscode?
I am trying to accomplish this using the vscode-r extensions. However this maybe has a more general answer. In the RStudio IDE, there is the ability to "re-run previous" such that the block of code you most recently ran will be run again including some small changes in that code?

So the workflow would be:

```<code>my_fun(arg1 = "foo")
</code>```

make some changes to the code:

```<code>my_fun(arg1 = "bar")
</code>```

Then run a shortcut to simply rerun the line (or lines) of code recently run.

Any idea how to set this up in vscode?

Body:
I am trying to accomplish this using the vscode-r extensions. However this maybe has a more general answer. In the RStudio IDE, there is the ability to "re-run previous" such that the block of code you most recently ran will be run again including some small changes in that code?

So the workflow would be:

my_fun(arg1 = "foo")

make some changes to the code:

my_fun(arg1 = "bar")

Then run a shortcut to simply rerun the line (or lines) of code recently run.

Any idea how to set this up in vscode?


问:
Server side rendering of different web apps using Spring MVC portlet
I have two different applications A and B running on two different Azure Kubernetes clusters. I have to display app B within an iframe in App A. I tried using MVC portlet and it works when App A is accessed from within the private network. Is there any way I can use portlets to stream the APP B when not in private network? This is the code that loads App B within an iframe in App A .</p>
```<code>public class BridgeViewPortlet extends GenericPortlet  implements   Serializable{

    public void doView(final RenderRequest request, final RenderResponse response) throws IOException {

       response.setContentType("text/html");

       String url = request.getParameter("url");

        // Set the content type of the response
        response.setContentType("text/html");

        // Get the output stream for the response
        PrintWriter out = response.getWriter();

        // Write the HTML for the website to the output stream
        out.println("<iframe  width=\"1200\" height=\"600\" src=" + url + "></iframe>");

    }

</code>```

Body:
I have two different applications A and B running on two different Azure Kubernetes clusters. I have to display app B within an iframe in App A. I tried using MVC portlet and it works when App A is accessed from within the private network. Is there any way I can use portlets to stream the APP B when not in private network? This is the code that loads App B within an iframe in App A .

public class BridgeViewPortlet extends GenericPortlet  implements   Serializable{

    public void doView(final RenderRequest request, final RenderResponse response) throws IOException {

       response.setContentType("text/html");

       String url = request.getParameter("url");

        // Set the content type of the response
        response.setContentType("text/html");

        // Get the output stream for the response
        PrintWriter out = response.getWriter();

        // Write the HTML for the website to the output stream
        out.println("");

    }


问:
Passing a JSON from Python to JS and declaring it
For a website, I'm calling a helper function (the python code) which returns 2 values, a Python dict and a JSON. When I pass the JSON to JS I get: referenceError: js_dictionary is not defined.

```<code>    test_dictionary = dict()
    for key in words:
        test_dictionary.update({key: dictionary[key]})
    js_test_dictionary = json.dumps(test_dictionary)
    return test_dictionary, js_test_dictionary
</code>```
```<code>return render_template("study.html", language=selected, dictionary=dictionary, js_dictionary=js_dictionary)
</code>```
```<code>document.addEventListener('DOMContentLoaded', function() {
    const dictionary = `${js_dictionary}`;
    const translations = JSON.parse(dictionary);
    document.querySelector('#check').onclick = function() {
</code>```

I have tried using jQuery instead of JSON.parse and have tried formatting js_dictionary with/without "$``". Any help would go a long way!

Body:
For a website, I'm calling a helper function (the python code) which returns 2 values, a Python dict and a JSON. When I pass the JSON to JS I get: referenceError: js_dictionary is not defined.

    test_dictionary = dict()
    for key in words:
        test_dictionary.update({key: dictionary[key]})
    js_test_dictionary = json.dumps(test_dictionary)
    return test_dictionary, js_test_dictionary

return render_template("study.html", language=selected, dictionary=dictionary, js_dictionary=js_dictionary)

document.addEventListener('DOMContentLoaded', function() {
    const dictionary = `${js_dictionary}`;
    const translations = JSON.parse(dictionary);
    document.querySelector('#check').onclick = function() {

I have tried using jQuery instead of JSON.parse and have tried formatting js_dictionary with/without "$``". Any help would go a long way!


问:
Unable to get local copy using IPersistFile.Save(path, false) in Excel
I implement a vsto plugin for Excel. I need to get local path of the Excel document from Teams channel but Application.ActiveWorkbook.FullName contains url.

I should be able to use IPersistFile.Save(path, false) and create local copy of the document without changing current working document. Unfortunately, it doesn't work in Excel. It creates a local copy, but current working document is replaced with local copy. If user do some changes to the document then Excel won't synchronize it with Teams/Sharepoint.

Is it a bug in API or I need to do something else to fix it?

Is there a different way to get a copy of the file without changing current working document?

I'm able to reproduce issue if I open Excel document from Teams channel and use vsto add-in with below code. Current working document is replaced with local copy but it shouldn't. I cannot get local copy.

this.Application.WorkbookOpen += ( Excel.Workbook wb ) =>
{
if ( !Uri.TryCreate( Application.ActiveWorkbook.FullName, UriKind.Absolute, out Uri uri ) || uri.Scheme == "file" )
{
Debug.WriteLine( $"It's local file: {Application.ActiveWorkbook.FullName}" );
return;
}
Debug.WriteLine( $"It's online file: {Application.ActiveWorkbook.FullName}" );
var fileName = uri.LocalPath.Split( '/' ).Last();
var extension = fileName.Split( '.' ).Last();
var fileNameWithoutExtension = fileName.Substring( 0, fileName.Length - extension.Length - 1 );
var path = Path.Combine( Path.GetTempPath(), $"{fileNameWithoutExtension}_{Guid.NewGuid()}.{extension}" );
if ( wb is IPersistFile persistFile )
{
persistFile.Save( path, false );
//current working document has been replaces with {path}
Debug.WriteLine( $"Local copy has been created: {path}" );
}
else
{
Debug.WriteLine( $"Unable to create local copy" );
}
};
```


问:
Ruby : Extract an embedded XML inside a PDF
I have a Rails application connected to a Flask microservice.
I have a pdf stored inside AWS S3.
I can access that pdf with the following code :

```<code>    s3 = Aws::S3::Client.new(region: 'eu-west-3')

    image_data = s3.get_object(bucket: "bucket-name", key: "file-name")
    image_data.body
</code>```

Inside that pdf is an embedded XML.
All I'm trying to do at this point is to extract the XML inside the PDF within my Rails application or within my Flask application.
That's it : I just want to extract the XML, nothing else.
Unfortunately i'm unable to find any relevant information, in Ruby or Python3, on how to do this properly.

For full information, here is the actual pdf (this is fake data) from which I'm trying to extract the XML
If you open it with adobe
https://drive.google.com/file/d/10pN8aFDAYY3qDBziODH-L441ZcnfdxQU/view?usp=sharing

Body:
I have a Rails application connected to a Flask microservice.
I have a pdf stored inside AWS S3.
I can access that pdf with the following code :

    s3 = Aws::S3::Client.new(region: 'eu-west-3')

    image_data = s3.get_object(bucket: "bucket-name", key: "file-name")
    image_data.body

Inside that pdf is an embedded XML.
All I'm trying to do at this point is to extract the XML inside the PDF within my Rails application or within my Flask application.
That's it : I just want to extract the XML, nothing else.
Unfortunately i'm unable to find any relevant information, in Ruby or Python3, on how to do this properly.

For full information, here is the actual pdf (this is fake data) from which I'm trying to extract the XML
If you open it with adobe
https://drive.google.com/file/d/10pN8aFDAYY3qDBziODH-L441ZcnfdxQU/view?usp=sharing


问:
Javascript/React How to fetch multipart/form-data
The start of multipart/form-data is

```<code>--------------------------
Content-Type: image/jpeg
Content-Disposition: filename="image.jpg"
Content-Length: 489102
jpeg
...
json
</code>```

The three dots are boundary + header as with the jpeg.
Data fetch happens by defined url string.

I tried using npm package parse-multipart-data, but i was fetching the multipart using xhr but also tried fetch()then(), as blob, arraybuffer, but the npm package says i should fetch it raw...
I want to fetch it and separate the fetched data the jpeg to  Image object for example and the json to {} Object in Javascript for example. Is something like this possible?
Thanks for replies.

Body:
The start of multipart/form-data is

--------------------------
Content-Type: image/jpeg
Content-Disposition: filename="image.jpg"
Content-Length: 489102
jpeg
...
json

The three dots are boundary + header as with the jpeg.
Data fetch happens by defined url string.

I tried using npm package parse-multipart-data, but i was fetching the multipart using xhr but also tried fetch()then(), as blob, arraybuffer, but the npm package says i should fetch it raw...
I want to fetch it and separate the fetched data the jpeg to  Image object for example and the json to {} Object in Javascript for example. Is something like this possible?
Thanks for replies.


问:
How do I delete a character from a Cookie or create whitespace?
I've created a site that displays the weather of every city using an API from openweather.

I managed to solve a problem I had where the previous searches wouldn't show up using cookies. This is for a school project that requires that I use cookies.

My problem now is that I can't create whitespace between the previous searches. I keep getting the error.

```<code>java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
</code>```

The only characters that can be used are colon and hyphen as far as the ones I've tried. I read that colon and whitespace used to be accepted on an earlier tomcat, but not anymore. I'm on 9.0.69.

I've uploaded a picture, so you can see the end result.
How do I create a white space between the cities or better yet a list that goes downwards.

This is my servlet;

```<code>package controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.GettheWeather;
import model.weatherBean;

@WebServlet("/OWservlet")
public class OWservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String cityStr = request.getParameter("city");
        String countryStr = request.getParameter("country");

        weatherBean wBean = new weatherBean(cityStr, countryStr);

        GettheWeather.getWeather(wBean);

        request.setAttribute("wBean", wBean);

        Cookie[] cookies = request.getCookies();
        String temp = "";
        for (int i = 0; i < cookies.length; i++) {
            if (cookies[i].getName().equals("city")) {
                temp = cookies[i].getValue();
            }

        }

        temp = temp + "-" + cityStr;

        Cookie ck = new Cookie("city", temp);
        ck.setMaxAge(100);
        response.addCookie(ck);

        RequestDispatcher rd = request.getRequestDispatcher("views/showWeather.jsp");
        rd.forward(request, response);
    }

}
</code>```

and this is my JSP

```<code><%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="model.weatherBean"%>
<%@page import="controller.OWservlet"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>the weather</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>

    <%

    weatherBean wBean = (weatherBean) request.getAttribute("wBean");

    double number = Double.parseDouble(wBean.getTempStr());
    number = number - 273.15;
    int number2 = (int) number;

    out.print("<h2>The weather in " + wBean.getCityStr() + " is now  " + wBean.getCloudsStr() + ", the temperature is : "
            + number2 + "°C, and the date is: " + wBean.getTimeStr().substring(0, 10) + "</h2>");
    %>

    <div class="loginbox">
        <form action="OWservlet" method="get">
            City:<input type="text" name="city" /><br /> Country:<input
                type="text" name="country" /><br /> <input type="submit"
                value="go" />
        </form>
    </div>

    <h1>Previously searched cities: ${cookie["city"].getValue()}</h1>

</body>
</html>
</code>```

I've tried using

```<code>temp.split("-");
</code>```

and

```<code>temp.replace("-"," ")
</code>```

Body:
I've created a site that displays the weather of every city using an API from openweather.

I managed to solve a problem I had where the previous searches wouldn't show up using cookies. This is for a school project that requires that I use cookies.

My problem now is that I can't create whitespace between the previous searches. I keep getting the error.

java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value

The only characters that can be used are colon and hyphen as far as the ones I've tried. I read that colon and whitespace used to be accepted on an earlier tomcat, but not anymore. I'm on 9.0.69.

I've uploaded a picture, so you can see the end result.
How do I create a white space between the cities or better yet a list that goes downwards.

This is my servlet;

package controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.GettheWeather;
import model.weatherBean;

@WebServlet("/OWservlet")
public class OWservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String cityStr = request.getParameter("city");
        String countryStr = request.getParameter("country");

        weatherBean wBean = new weatherBean(cityStr, countryStr);

        GettheWeather.getWeather(wBean);

        request.setAttribute("wBean", wBean);

        Cookie[] cookies = request.getCookies();
        String temp = "";
        for (int i = 0; i < cookies.length; i++) {
            if (cookies[i].getName().equals("city")) {
                temp = cookies[i].getValue();
            }

        }

        temp = temp + "-" + cityStr;

        Cookie ck = new Cookie("city", temp);
        ck.setMaxAge(100);
        response.addCookie(ck);

        RequestDispatcher rd = request.getRequestDispatcher("views/showWeather.jsp");
        rd.forward(request, response);
    }

}

and this is my JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="model.weatherBean"%>
<%@page import="controller.OWservlet"%>
<!DOCTYPE html>

<meta charset="UTF-8">
<title>the weather</title>
<link rel="stylesheet" href="./style.css">

    <%

    weatherBean wBean = (weatherBean) request.getAttribute("wBean");

    double number = Double.parseDouble(wBean.getTempStr());
    number = number - 273.15;
    int number2 = (int) number;

    out.print("
The weather in " + wBean.getCityStr() + " is now  " + wBean.getCloudsStr() + ", the temperature is : "
            + number2 + "°C, and the date is: " + wBean.getTimeStr().substring(0, 10) + "
");
    %>

        <form action="OWservlet" method="get">
            City:<input type="text" name="city" />
 Country:<input
                type="text" name="country" />
 <input type="submit"
                value="go" />
        </form>

Previously searched cities: ${cookie["city"].getValue()}

I've tried using

temp.split("-");

and

temp.replace("-"," ")


问:
Windows Application without GUI, only a menu that opens when you right click on the icon on bottom right
I'm trying build a Windows Application but i kinda don't know where to start. I'm not really that experienced in windows desktop apps. What i need to do is build an application that is not going to have any graphical user interface but rather work on the background but not like windows services. The user should be able to control what happens in the background via a menu consisting of several options. Something like wampserver. An icon on bottom right, menu pops up when you right click on it. No GUI. I'm looking for experienced developers who can point me in the right direction. Thanks.</p>


问:
Add columns by percentages by city
Similar to this question but, this time there's a slight change in the data as now it also has a CITYNAME column. So, the variable values are for each city. But, the purpose stays the same. However, when I try the code in method 2 of that question, I get this error:

```<code>Error in marginSums(x, margin) : 'x' is not an array
</code>```

Data:

```<code>df =

    structure(list(LONGNAME = c("District 1", "District 1", "District 1",
    "District 1", "District 1", "District 1", "District 1", "District 1",
    "District 2", "District 2", "District 2", "District 2", "District 2",
    "District 2", "District 2", "District 2", "District 2", "District 2",
    "District 2", "District 2", "District 3", "District 3", "District 3",
    "District 3", "District 3", "District 3", "District 3", "District 3",
    "District 3", "District 4", "District 4", "District 4", "District 4",
    "District 4", "District 4", "District 4", "District 4", "District 4",
    "District 4", "District 4", "District 5", "District 5", "District 5",
    "District 5", "District 5", "District 5", "District 5", "District 5",
    "District 5", "District 5", "District 5", "District 5", "District 6",
    "District 6", "District 6", "District 6", "District 6", "District 6",
    "District 6", "District 6", "District 6", "District 7", "District 7",
    "District 7", "District 7", "District 7", "District 7", "District 7",
    "District 8", "District 8", "District 8", "District 8", "District 8",
    "District 8", "District 8", "District 8", "District 8", "District 8",
    "District 8", "District 8", "District 9", "District 9", "District 9",
    "District 9", "District 9", "District 9", "District 9", "District 9"
    ), CITYNAME = c("", "COUNTY REGIONAL FACILITY", "DAVIE", "MIRAMAR",
    "PEMBROKE PINES", "SOUTHWEST RANCHES", "SUNRISE", "WESTON", "BMSD",
    "COCONUT CREEK", "CORAL SPRINGS", "COUNTY REGIONAL FACILITY",
    "DEERFIELD BEACH", "HILLSBORO BEACH", "LIGHTHOUSE POINT", "MARGATE",
    "NORTH LAUDERDALE", "PARKLAND", "POMPANO BEACH", "TRIBAL LAND",
    "", "BMSD", "COCONUT CREEK", "CORAL SPRINGS", "LAUDERHILL", "NORTH LAUDERDALE",
    "PARKLAND", "SUNRISE", "TAMARAC", "", "DEERFIELD BEACH", "FORT LAUDERDALE",
    "HILLSBORO BEACH", "LAUDERDALE BY THE SEA", "LAZY LAKE", "LIGHTHOUSE POINT",
    "OAKLAND PARK", "POMPANO BEACH", "SEA RANCH LAKES", "WILTON MANORS",
    "BMSD", "COOPER CITY", "COUNTY REGIONAL FACILITY", "DAVIE", "FORT LAUDERDALE",
    "HOLLYWOOD", "PEMBROKE PINES", "PLANTATION", "SOUTHWEST RANCHES",
    "SUNRISE", "TRIBAL LAND", "WESTON", "COUNTY REGIONAL FACILITY",
    "DANIA BEACH", "DAVIE", "FORT LAUDERDALE", "HALLANDALE BEACH",
    "HOLLYWOOD", "PEMBROKE PARK", "TRIBAL LAND", "WEST PARK", "COOPER CITY",
    "DAVIE", "HOLLYWOOD", "MIRAMAR", "PEMBROKE PINES", "TRIBAL LAND",
    "WEST PARK", "BMSD", "COCONUT CREEK", "FORT LAUDERDALE", "LAUDERDALE LAKES",
    "LAUDERHILL", "MARGATE", "NORTH LAUDERDALE", "OAKLAND PARK",
    "PLANTATION", "POMPANO BEACH", "TAMARAC", "WILTON MANORS", "BMSD",
    "FORT LAUDERDALE", "LAUDERDALE LAKES", "LAUDERHILL", "NORTH LAUDERDALE",
    "OAKLAND PARK", "PLANTATION", "SUNRISE"), `1` = c(65L, 5L, 159L,
    9018L, 17212L, 1133L, 4L, 14469L, 243L, 11934L, 2804L, 26L, 21470L,
    1L, NA, 10856L, 1L, 182L, 1850L, NA, 1L, 13L, 1L, 15889L, 1L,
    1325L, 5748L, 1866L, 12219L, 11L, 2L, 11736L, 1423L, 2137L, 6L,
    20L, 3133L, 7892L, 33L, 967L, 1482L, 8077L, 2L, 19933L, 1L, 3L,
    6L, 3280L, 587L, 3043L, 7L, 3L, 74L, 4929L, 6L, 2882L, 1634L,
    12654L, 814L, 2L, 3420L, 5L, 24L, 6937L, 7599L, 13399L, 42L,
    4L, 1229L, 4L, 9257L, 41L, 794L, 2679L, 4909L, 4504L, 59L, 6816L,
    4310L, 399L, 1L, 14L, 6458L, 6088L, 1L, 202L, 3079L, 14667L),
        `2` = c(1L, NA, 7L, 150L, 713L, 164L, NA, 632L, 10L, 1271L,
        213L, 1L, 1357L, NA, NA, 710L, NA, 2L, 34L, NA, NA, NA, NA,
        2207L, 1L, 128L, 507L, 105L, 1041L, NA, NA, 3915L, 10L, 285L,
        NA, 41L, 504L, 1668L, 28L, 311L, 26L, 300L, NA, 1007L, NA,
        NA, NA, 706L, 29L, 57L, NA, NA, 7L, 602L, NA, 249L, 354L,
        1258L, 18L, NA, 172L, NA, NA, 570L, 1898L, 1442L, 2L, NA,
        88L, NA, 1658L, 10L, 110L, 222L, 413L, 394L, 1L, 999L, 251L,
        112L, NA, NA, 729L, 994L, NA, 4L, 351L, 2011L), `3` = c(8L,
        NA, 5L, 786L, 3407L, 309L, NA, 1489L, 17L, 2632L, 462L, 6L,
        2700L, NA, NA, 1734L, NA, 9L, 112L, NA, NA, 2L, NA, 5432L,
        1L, 264L, 1061L, 248L, 2237L, NA, NA, 4344L, 96L, 890L, NA,
        121L, 1176L, 2533L, 42L, 916L, 88L, 775L, NA, 3099L, NA,
        4L, 1L, 1392L, 67L, 127L, 1L, NA, 16L, 1122L, 2L, 654L, 1109L,
        2217L, 51L, NA, 349L, 1L, 3L, 1678L, 2947L, 3221L, 3L, NA,
        248L, NA, 2678L, 17L, 241L, 792L, 1637L, 650L, 1L, 1502L,
        745L, 205L, NA, 1L, 1876L, 1912L, NA, 5L, 642L, 3118L), `4` = c(6L,
        NA, 1L, 1593L, 4519L, 71L, NA, 522L, 2L, 936L, 164L, 1L,
        966L, NA, NA, 499L, NA, 7L, 78L, 3L, NA, 1L, NA, 2117L, NA,
        151L, 493L, 59L, 1879L, NA, NA, 2255L, 28L, 964L, NA, 149L,
        537L, 2417L, 27L, 491L, 45L, 370L, NA, 1023L, NA, 5L, 1L,
        1034L, 28L, 54L, NA, NA, 10L, 541L, 1L, 285L, 615L, 1864L,
        18L, NA, 118L, NA, 2L, 726L, 2754L, 1353L, 2L, 1L, 184L,
        1L, 1584L, 9L, 95L, 292L, 545L, 589L, NA, 494L, 633L, 230L,
        NA, 5L, 654L, 1412L, NA, 2L, 319L, 1066L), `5` = c(56L, 1L,
        1L, 2535L, 1460L, 100L, NA, 1473L, 10L, 1157L, 300L, 1L,
        2068L, 1L, 2L, 982L, NA, 13L, 289L, NA, NA, NA, NA, 2634L,
        NA, 95L, 684L, 83L, 1590L, NA, NA, 5443L, 6L, 423L, NA, 305L,
        806L, 3276L, 22L, 571L, 76L, 562L, NA, 1662L, NA, 1L, NA,
        2160L, 50L, 188L, 1L, NA, 7L, 602L, 1L, 356L, 488L, 2399L,
        70L, NA, 316L, 1L, 1L, 1464L, 1638L, 1922L, 5L, 1L, 237L,
        NA, 2952L, 28L, 179L, 380L, 638L, 1266L, 1L, 1669L, 439L,
        75L, NA, 5L, 802L, 2049L, NA, 1L, 727L, 2039L), `6` = c(119L,
        5L, 2L, 2009L, 1507L, 210L, 1L, 1884L, 9L, 2602L, 383L, 7L,
        3439L, NA, 11L, 2064L, NA, 19L, 589L, NA, NA, NA, NA, 5867L,
        NA, 167L, 1576L, 137L, 2295L, NA, NA, 9500L, 12L, 974L, 1L,
        1366L, 2167L, 5695L, 18L, 971L, 89L, 911L, NA, 3510L, NA,
        62L, 2L, 4574L, 118L, 852L, NA, 1L, 19L, 1009L, 6L, 1177L,
        1897L, 7727L, 818L, NA, 590L, NA, NA, 2981L, 4663L, 3492L,
        5L, 3L, 664L, 2L, 5137L, 19L, 320L, 740L, 1260L, 939L, 4L,
        951L, 1868L, 145L, 1L, 13L, 1517L, 6763L, NA, 1L, 2127L,
        3642L), `7` = c(52L, 1L, 1L, 1690L, 1047L, 113L, 1L, 1764L,
        6L, 799L, 205L, 5L, 2156L, NA, 9L, 891L, NA, 7L, 260L, NA,
        NA, NA, NA, 1351L, NA, 32L, 1203L, 42L, 1231L, NA, NA, 5630L,
        404L, 276L, 1L, 1060L, 959L, 4115L, 16L, 69L, 64L, 491L,
        NA, 1550L, NA, 1L, 1L, 2100L, 65L, 178L, 2L, 1L, 8L, 1478L,
        3L, 325L, 1684L, 4398L, 98L, 1L, 104L, NA, 5L, 660L, 988L,
        2003L, 2L, NA, 196L, NA, 1445L, 13L, 109L, 215L, 218L, 237L,
        NA, 1125L, 450L, 41L, 1L, 5L, 152L, 2172L, NA, 1L, 2030L,
        1999L), `8` = c(17L, NA, 2L, 505L, 844L, 103L, NA, 741L,
        3L, 287L, 85L, 4L, 1987L, NA, 21L, 219L, NA, 13L, 361L, NA,
        NA, 1L, NA, 388L, NA, 8L, 916L, 16L, 318L, NA, NA, 5649L,
        32L, 126L, 2L, 1777L, 304L, 3389L, 3L, 16L, 20L, 354L, NA,
        992L, NA, 1L, 1L, 3095L, 44L, 103L, NA, 1L, 21L, 1953L, 4L,
        132L, 5905L, 5542L, 78L, NA, 29L, NA, NA, 207L, 386L, 544L,
        2L, NA, 60L, NA, 776L, 5L, 46L, 243L, 94L, 110L, 2L, 399L,
        391L, 6L, NA, 1L, 20L, 1481L, NA, 2L, 4003L, 1372L), `9` = c(14L,
        1L, 3L, 143L, 50L, 25L, NA, 66L, 3L, 65L, 24L, 3L, 563L,
        NA, 98L, 36L, NA, 2L, 36L, NA, NA, 3L, NA, 190L, NA, 6L,
        441L, 32L, 28L, NA, NA, 4004L, 138L, 9L, NA, 596L, 33L, 1662L,
        NA, 34L, 6L, 76L, NA, 241L, NA, NA, 2L, 326L, 12L, 12L, NA,
        NA, 26L, 1500L, 5L, 36L, 10335L, 8321L, 1L, NA, NA, NA, NA,
        22L, 108L, 227L, NA, NA, 10L, 2L, 348L, 2L, 2L, 16L, 24L,
        51L, 1L, 66L, 59L, 7L, 1L, NA, 14L, 70L, NA, NA, 614L, 208L
        ), `10` = c(12L, NA, NA, NA, NA, 2L, NA, NA, NA, NA, NA,
        NA, 20L, 2L, NA, NA, NA, NA, 3L, NA, NA, NA, NA, 9L, NA,
        NA, 3L, NA, NA, NA, NA, 313L, 167L, 1L, NA, 43L, NA, 563L,
        NA, NA, NA, 1L, NA, NA, NA, NA, NA, 3L, 1L, 1L, NA, NA, 11L,
        78L, NA, 1L, 1956L, 870L, NA, NA, NA, NA, NA, NA, NA, 2L,
        NA, NA, NA, NA, 12L, 1L, NA, NA, 2L, 1L, NA, 7L, NA, NA,
        NA, NA, NA, NA, NA, NA, 5L, NA)), row.names = c(NA, -88L), class = c("tbl_df",
    "tbl", "data.frame"))
</code>```

Code:

```<code>df[paste0("pct", names(df)[-2])] = proportions(as.data.frame(df[-2]), 1) * 100
</code>```

Title: Add columns by percentages by city

Body:
Similar to this question but, this time there's a slight change in the data as now it also has a CITYNAME column. So, the variable values are for each city. But, the purpose stays the same. However, when I try the code in method 2 of that question, I get this error:

Error in marginSums(x, margin) : 'x' is not an array

Data:

df =

    structure(list(LONGNAME = c("District 1", "District 1", "District 1",
    "District 1", "District 1", "District 1", "District 1", "District 1",
    "District 2", "District 2", "District 2", "District 2", "District 2",
    "District 2", "District 2", "District 2", "District 2", "District 2",
    "District 2", "District 2", "District 3", "District 3", "District 3",
    "District 3", "District 3", "District 3", "District 3", "District 3",
    "District 3", "District 4", "District 4", "District 4", "District 4",
    "District 4", "District 4", "District 4", "District 4", "District 4",
    "District 4", "District 4", "District 5", "District 5", "District 5",
    "District 5", "District 5", "District 5", "District 5", "District 5",
    "District 5", "District 5", "District 5", "District 5", "District 6",
    "District 6", "District 6", "District 6", "District 6", "District 6",
    "District 6", "District 6", "District 6", "District 7", "District 7",
    "District 7", "District 7", "District 7", "District 7", "District 7",
    "District 8", "District 8", "District 8", "District 8", "District 8",
    "District 8", "District 8", "District 8", "District 8", "District 8",
    "District 8", "District 8", "District 9", "District 9", "District 9",
    "District 9", "District 9", "District 9", "District 9", "District 9"
    ), CITYNAME = c("", "COUNTY REGIONAL FACILITY", "DAVIE", "MIRAMAR",
    "PEMBROKE PINES", "SOUTHWEST RANCHES", "SUNRISE", "WESTON", "BMSD",
    "COCONUT CREEK", "CORAL SPRINGS", "COUNTY REGIONAL FACILITY",
    "DEERFIELD BEACH", "HILLSBORO BEACH", "LIGHTHOUSE POINT", "MARGATE",
    "NORTH LAUDERDALE", "PARKLAND", "POMPANO BEACH", "TRIBAL LAND",
    "", "BMSD", "COCONUT CREEK", "CORAL SPRINGS", "LAUDERHILL", "NORTH LAUDERDALE",
    "PARKLAND", "SUNRISE", "TAMARAC", "", "DEERFIELD BEACH", "FORT LAUDERDALE",
    "HILLSBORO BEACH", "LAUDERDALE BY THE SEA", "LAZY LAKE", "LIGHTHOUSE POINT",
    "OAKLAND PARK", "POMPANO BEACH", "SEA RANCH LAKES", "WILTON MANORS",
    "BMSD", "COOPER CITY", "COUNTY REGIONAL FACILITY", "DAVIE", "FORT LAUDERDALE",
    "HOLLYWOOD", "PEMBROKE PINES", "PLANTATION", "SOUTHWEST RANCHES",
    "SUNRISE", "TRIBAL LAND", "WESTON", "COUNTY REGIONAL FACILITY",
    "DANIA BEACH", "DAVIE", "FORT LAUDERDALE", "HALLANDALE BEACH",
    "HOLLYWOOD", "PEMBROKE PARK", "TRIBAL LAND", "WEST PARK", "COOPER CITY",
    "DAVIE", "HOLLYWOOD", "MIRAMAR", "PEMBROKE PINES", "TRIBAL LAND",
    "WEST PARK", "BMSD", "COCONUT CREEK", "FORT LAUDERDALE", "LAUDERDALE LAKES",
    "LAUDERHILL", "MARGATE", "NORTH LAUDERDALE", "OAKLAND PARK",
    "PLANTATION", "POMPANO BEACH", "TAMARAC", "WILTON MANORS", "BMSD",
    "FORT LAUDERDALE", "LAUDERDALE LAKES", "LAUDERHILL", "NORTH LAUDERDALE",
    "OAKLAND PARK", "PLANTATION", "SUNRISE"), `1` = c(65L, 5L, 159L,
    9018L, 17212L, 1133L, 4L, 14469L, 243L, 11934L, 2804L, 26L, 21470L,
    1L, NA, 10856L, 1L, 182L, 1850L, NA, 1L, 13L, 1L, 15889L, 1L,
    1325L, 5748L, 1866L, 12219L, 11L, 2L, 11736L, 1423L, 2137L, 6L,
    20L, 3133L, 7892L, 33L, 967L, 1482L, 8077L, 2L, 19933L, 1L, 3L,
    6L, 3280L, 587L, 3043L, 7L, 3L, 74L, 4929L, 6L, 2882L, 1634L,
    12654L, 814L, 2L, 3420L, 5L, 24L, 6937L, 7599L, 13399L, 42L,
    4L, 1229L, 4L, 9257L, 41L, 794L, 2679L, 4909L, 4504L, 59L, 6816L,
    4310L, 399L, 1L, 14L, 6458L, 6088L, 1L, 202L, 3079L, 14667L),
        `2` = c(1L, NA, 7L, 150L, 713L, 164L, NA, 632L, 10L, 1271L,
        213L, 1L, 1357L, NA, NA, 710L, NA, 2L, 34L, NA, NA, NA, NA,
        2207L, 1L, 128L, 507L, 105L, 1041L, NA, NA, 3915L, 10L, 285L,
        NA, 41L, 504L, 1668L, 28L, 311L, 26L, 300L, NA, 1007L, NA,
        NA, NA, 706L, 29L, 57L, NA, NA, 7L, 602L, NA, 249L, 354L,
        1258L, 18L, NA, 172L, NA, NA, 570L, 1898L, 1442L, 2L, NA,
        88L, NA, 1658L, 10L, 110L, 222L, 413L, 394L, 1L, 999L, 251L,
        112L, NA, NA, 729L, 994L, NA, 4L, 351L, 2011L), `3` = c(8L,
        NA, 5L, 786L, 3407L, 309L, NA, 1489L, 17L, 2632L, 462L, 6L,
        2700L, NA, NA, 1734L, NA, 9L, 112L, NA, NA, 2L, NA, 5432L,
        1L, 264L, 1061L, 248L, 2237L, NA, NA, 4344L, 96L, 890L, NA,
        121L, 1176L, 2533L, 42L, 916L, 88L, 775L, NA, 3099L, NA,
        4L, 1L, 1392L, 67L, 127L, 1L, NA, 16L, 1122L, 2L, 654L, 1109L,
        2217L, 51L, NA, 349L, 1L, 3L, 1678L, 2947L, 3221L, 3L, NA,
        248L, NA, 2678L, 17L, 241L, 792L, 1637L, 650L, 1L, 1502L,
        745L, 205L, NA, 1L, 1876L, 1912L, NA, 5L, 642L, 3118L), `4` = c(6L,
        NA, 1L, 1593L, 4519L, 71L, NA, 522L, 2L, 936L, 164L, 1L,
        966L, NA, NA, 499L, NA, 7L, 78L, 3L, NA, 1L, NA, 2117L, NA,
        151L, 493L, 59L, 1879L, NA, NA, 2255L, 28L, 964L, NA, 149L,
        537L, 2417L, 27L, 491L, 45L, 370L, NA, 1023L, NA, 5L, 1L,
        1034L, 28L, 54L, NA, NA, 10L, 541L, 1L, 285L, 615L, 1864L,
        18L, NA, 118L, NA, 2L, 726L, 2754L, 1353L, 2L, 1L, 184L,
        1L, 1584L, 9L, 95L, 292L, 545L, 589L, NA, 494L, 633L, 230L,
        NA, 5L, 654L, 1412L, NA, 2L, 319L, 1066L), `5` = c(56L, 1L,
        1L, 2535L, 1460L, 100L, NA, 1473L, 10L, 1157L, 300L, 1L,
        2068L, 1L, 2L, 982L, NA, 13L, 289L, NA, NA, NA, NA, 2634L,
        NA, 95L, 684L, 83L, 1590L, NA, NA, 5443L, 6L, 423L, NA, 305L,
        806L, 3276L, 22L, 571L, 76L, 562L, NA, 1662L, NA, 1L, NA,
        2160L, 50L, 188L, 1L, NA, 7L, 602L, 1L, 356L, 488L, 2399L,
        70L, NA, 316L, 1L, 1L, 1464L, 1638L, 1922L, 5L, 1L, 237L,
        NA, 2952L, 28L, 179L, 380L, 638L, 1266L, 1L, 1669L, 439L,
        75L, NA, 5L, 802L, 2049L, NA, 1L, 727L, 2039L), `6` = c(119L,
        5L, 2L, 2009L, 1507L, 210L, 1L, 1884L, 9L, 2602L, 383L, 7L,
        3439L, NA, 11L, 2064L, NA, 19L, 589L, NA, NA, NA, NA, 5867L,
        NA, 167L, 1576L, 137L, 2295L, NA, NA, 9500L, 12L, 974L, 1L,
        1366L, 2167L, 5695L, 18L, 971L, 89L, 911L, NA, 3510L, NA,
        62L, 2L, 4574L, 118L, 852L, NA, 1L, 19L, 1009L, 6L, 1177L,
        1897L, 7727L, 818L, NA, 590L, NA, NA, 2981L, 4663L, 3492L,
        5L, 3L, 664L, 2L, 5137L, 19L, 320L, 740L, 1260L, 939L, 4L,
        951L, 1868L, 145L, 1L, 13L, 1517L, 6763L, NA, 1L, 2127L,
        3642L), `7` = c(52L, 1L, 1L, 1690L, 1047L, 113L, 1L, 1764L,
        6L, 799L, 205L, 5L, 2156L, NA, 9L, 891L, NA, 7L, 260L, NA,
        NA, NA, NA, 1351L, NA, 32L, 1203L, 42L, 1231L, NA, NA, 5630L,
        404L, 276L, 1L, 1060L, 959L, 4115L, 16L, 69L, 64L, 491L,
        NA, 1550L, NA, 1L, 1L, 2100L, 65L, 178L, 2L, 1L, 8L, 1478L,
        3L, 325L, 1684L, 4398L, 98L, 1L, 104L, NA, 5L, 660L, 988L,
        2003L, 2L, NA, 196L, NA, 1445L, 13L, 109L, 215L, 218L, 237L,
        NA, 1125L, 450L, 41L, 1L, 5L, 152L, 2172L, NA, 1L, 2030L,
        1999L), `8` = c(17L, NA, 2L, 505L, 844L, 103L, NA, 741L,
        3L, 287L, 85L, 4L, 1987L, NA, 21L, 219L, NA, 13L, 361L, NA,
        NA, 1L, NA, 388L, NA, 8L, 916L, 16L, 318L, NA, NA, 5649L,
        32L, 126L, 2L, 1777L, 304L, 3389L, 3L, 16L, 20L, 354L, NA,
        992L, NA, 1L, 1L, 3095L, 44L, 103L, NA, 1L, 21L, 1953L, 4L,
        132L, 5905L, 5542L, 78L, NA, 29L, NA, NA, 207L, 386L, 544L,
        2L, NA, 60L, NA, 776L, 5L, 46L, 243L, 94L, 110L, 2L, 399L,
        391L, 6L, NA, 1L, 20L, 1481L, NA, 2L, 4003L, 1372L), `9` = c(14L,
        1L, 3L, 143L, 50L, 25L, NA, 66L, 3L, 65L, 24L, 3L, 563L,
        NA, 98L, 36L, NA, 2L, 36L, NA, NA, 3L, NA, 190L, NA, 6L,
        441L, 32L, 28L, NA, NA, 4004L, 138L, 9L, NA, 596L, 33L, 1662L,
        NA, 34L, 6L, 76L, NA, 241L, NA, NA, 2L, 326L, 12L, 12L, NA,
        NA, 26L, 1500L, 5L, 36L, 10335L, 8321L, 1L, NA, NA, NA, NA,
        22L, 108L, 227L, NA, NA, 10L, 2L, 348L, 2L, 2L, 16L, 24L,
        51L, 1L, 66L, 59L, 7L, 1L, NA, 14L, 70L, NA, NA, 614L, 208L
        ), `10` = c(12L, NA, NA, NA, NA, 2L, NA, NA, NA, NA, NA,
        NA, 20L, 2L, NA, NA, NA, NA, 3L, NA, NA, NA, NA, 9L, NA,
        NA, 3L, NA, NA, NA, NA, 313L, 167L, 1L, NA, 43L, NA, 563L,
        NA, NA, NA, 1L, NA, NA, NA, NA, NA, 3L, 1L, 1L, NA, NA, 11L,
        78L, NA, 1L, 1956L, 870L, NA, NA, NA, NA, NA, NA, NA, 2L,
        NA, NA, NA, NA, 12L, 1L, NA, NA, 2L, 1L, NA, 7L, NA, NA,
        NA, NA, NA, NA, NA, NA, 5L, NA)), row.names = c(NA, -88L), class = c("tbl_df",
    "tbl", "data.frame"))

Code:

df[paste0("pct", names(df)[-2])] = proportions(as.data.frame(df[-2]), 1) * 100


问:
Create tar using buffer with Python
I have buffer (bytes) that I want to tar using Python without write to temp file

If I had a file it's simple to archive like :

```<code>import tarfile
with tarfile.open('archive.tar','w:xz' ) as f :
    f.add('sample.txt')
</code>```

Buf I have bytes bytes(b'......') that I want to archive (not file path) , Is that possible ?

Title: Create tar using buffer with Python

Body:
I have buffer (bytes) that I want to tar using Python without write to temp file

If I had a file it's simple to archive like :

import tarfile
with tarfile.open('archive.tar','w:xz' ) as f :
    f.add('sample.txt')

Buf I have bytes bytes(b'......') that I want to archive (not file path) , Is that possible ?