问:
how to solve this issue ? Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in D:\
```<code>PS D:\NextJs\Next-JS-Tutorials\hello-world> yarn dev
yarn run v1.22.19
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\node_modules\postcss\package.json
    at new NodeError (node:internal/errors:393:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:358:9)
    at Module._resolveFilename (node:internal/modules/cjs/loader:981:27)
    at mod._resolveFilename (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\build\webpack\require-hook.js:4:1784)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at 552 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11590)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
    at 270 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:400)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
    at 327 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:260)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

PS D:\NextJs\Next-JS-Tutorials\hello-world> node -v
v18.12.1
</code>```

getting this issue why i try to run a next js app (yarn dev)

and the content of "D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\node_modules\postcss\package.json" is

```<code>{
  "name": "postcss",
  "version": "8.1.7",
  "description": "Tool for transforming styles with JS plugins",
  "engines": {
    "node": "^10 || ^12 || >=14"
  },
  "exports": {
    ".": {
      "require": "./lib/postcss.js",
      "import": "./lib/postcss.mjs",
      "types": "./lib/postcss.d.ts"
    },
    "./": "./"
  },
  "main": "./lib/postcss.js",
  "types": "./lib/postcss.d.ts",
  "keywords": [
    "css",
    "postcss",
    "rework",
    "preprocessor",
    "parser",
    "source map",
    "transform",
    "manipulation",
    "transpiler"
  ],
  "funding": {
    "type": "opencollective",
    "url": "https://opencollective.com/postcss/"
  },
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
  "license": "MIT",
  "homepage": "https://postcss.org/",
  "repository": "postcss/postcss",
  "dependencies": {
    "colorette": "^1.2.1",
    "line-column": "^1.0.2",
    "nanoid": "^3.1.16",
    "source-map": "^0.6.1"
  },
  "browser": {
    "./lib/terminal-highlight": false,
    "colorette": false,
    "fs": false
  }
}

</code>```

Please help me to solve this

i tried removing the NODE-MODULES folder and the yarn-lock file and re running 'yarn' command .
but it is not helping

Body:
PS D:\NextJs\Next-JS-Tutorials\hello-world> yarn dev
yarn run v1.22.19
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\node_modules\postcss\package.json
    at new NodeError (node:internal/errors:393:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:358:9)
    at Module._resolveFilename (node:internal/modules/cjs/loader:981:27)
    at mod._resolveFilename (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\build\webpack\require-hook.js:4:1784)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at 552 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11590)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
    at 270 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:400)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
    at 327 (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:260)
    at __nccwpck_require__ (D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

PS D:\NextJs\Next-JS-Tutorials\hello-world> node -v
v18.12.1

getting this issue why i try to run a next js app (yarn dev)

and the content of "D:\NextJs\Next-JS-Tutorials\hello-world\node_modules\next\node_modules\postcss\package.json" is

{
  "name": "postcss",
  "version": "8.1.7",
  "description": "Tool for transforming styles with JS plugins",
  "engines": {
    "node": "^10 || ^12 || >=14"
  },
  "exports": {
    ".": {
      "require": "./lib/postcss.js",
      "import": "./lib/postcss.mjs",
      "types": "./lib/postcss.d.ts"
    },
    "./": "./"
  },
  "main": "./lib/postcss.js",
  "types": "./lib/postcss.d.ts",
  "keywords": [
    "css",
    "postcss",
    "rework",
    "preprocessor",
    "parser",
    "source map",
    "transform",
    "manipulation",
    "transpiler"
  ],
  "funding": {
    "type": "opencollective",
    "url": "https://opencollective.com/postcss/"
  },
  "author": "Andrey Sitnik <andrey@sitnik.ru>",
  "license": "MIT",
  "homepage": "https://postcss.org/",
  "repository": "postcss/postcss",
  "dependencies": {
    "colorette": "^1.2.1",
    "line-column": "^1.0.2",
    "nanoid": "^3.1.16",
    "source-map": "^0.6.1"
  },
  "browser": {
    "./lib/terminal-highlight": false,
    "colorette": false,
    "fs": false
  }
}

Please help me to solve this

i tried removing the NODE-MODULES folder and the yarn-lock file and re running 'yarn' command .
but it is not helping


来源: stackexchange

问:
Connect to RabbitMQ in docker from a stand-alone java application
I have an application A, which is spring boot, microservices based and is dockerized.
A has an inbuilt messaging framework and supports multiple implementations such as RabbitMQ, Kafka and ActiveMQ.
The default broker for the application is RabbitMQ. RabbitMQ runs in a separate container.

Now B is a java console spring boot application.
B needs to listen to a topic on RabbitMQ to receive messages from application A

I am able to implement this in a stand-alone way. That is, I use RabbitMQ specific interfaces, create connection factory and am able to receive messages in B from A.

My question is:
Will I be able to use A's messaging framework in B to listen to messages? I have tried adding a subscriber. I'm able to connect to RabbitMQ but not able to receive messages. RabbitMQ host that I'm using is "localhost"

ContentLicense: CC BY-SA 4.0


问:
Find all extension methods that conflicts with built-in method of the type
I have just updated my project from .NET Standard 2.0 to 2.1 (Due to a Unity3D Version Update), and with this update, a lot of methods that I previously implemented with extension methods are now built-in to the type itself. (e.g. TryGetValue for KeyedCollection)

Unfortunately, some of my extension methods share the same name as the C# implementation, but have different behaviours. (e.g. my TryGetValue won't throw an exception when a null key is given, but .Net 2.1's will throw). As such, I am having a lot of runtime errors.

I wonder if there's any way to get the compiler to generate a warning for all of the extension methods that conflict with the base class?

Currently, I am finding all extension methods through finding all (this , and then checking if it has any usages (Code metrics display from Rider)

But this is taking a really long time and I want to see if there's a better way.


问:
%in% operator for numeric vector returns weird behavior
I have a simple check in place but i lack consistency in the return value. I can not see the issue.

Code example  is a sequence from 0 to 1 in steps of 0.1 and check to see a number is present in this vector

```<code>    numsequence <- seq(0,1,0.1)
    0.2 %in% numsequence # gives TRUE
    0.3 %in% numsequence # gives FALSE
    0.4 %in% numsequence # gives TRUE
    0.5 %in% numsequence # gives TRUE
    0.6 %in% numsequence # gives FALSE
</code>```

My own construct which does not work as well

```<code>    numsequence <- seq(0,1,0.1)
    vectortosearch <- unique(simResults_SURU$ReusePrevBefore)
    vectortosearch
    # [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
    str(vectortosearch)
    # num [1:11] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 ...
    for(v in vectortosearch){
        print(v)
        if (v %in% numsequence ){
            print(v)
        }
    }
</code>```

gives the following output
0
0
0.1
0.1
0.2
0.2
0.3
0.4
0.4
0.5
0.5
0.6
0.7
0.8
0.8
0.9
0.9
1
1

This construct works for all numbers

```<code>    for(number in numsequence){print(number);print(number %in% numsequence)}
</code>```

Any one has an idea why it does not work? Why 0.3 and 0.6 and 0.7 are left out the loop?

Expecting to see all numbers from the sequence vector to be displayed following the %in% operator

Body:
I have a simple check in place but i lack consistency in the return value. I can not see the issue.

Code example  is a sequence from 0 to 1 in steps of 0.1 and check to see a number is present in this vector

    numsequence <- seq(0,1,0.1)
    0.2 %in% numsequence # gives TRUE
    0.3 %in% numsequence # gives FALSE
    0.4 %in% numsequence # gives TRUE
    0.5 %in% numsequence # gives TRUE
    0.6 %in% numsequence # gives FALSE

My own construct which does not work as well

    numsequence <- seq(0,1,0.1)
    vectortosearch <- unique(simResults_SURU$ReusePrevBefore)
    vectortosearch
    # [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
    str(vectortosearch)
    # num [1:11] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 ...
    for(v in vectortosearch){
        print(v)
        if (v %in% numsequence ){
            print(v)
        }
    }

gives the following output
0
0
0.1
0.1
0.2
0.2
0.3
0.4
0.4
0.5
0.5
0.6
0.7
0.8
0.8
0.9
0.9
1
1

This construct works for all numbers

    for(number in numsequence){print(number);print(number %in% numsequence)}

Any one has an idea why it does not work? Why 0.3 and 0.6 and 0.7 are left out the loop?

Expecting to see all numbers from the sequence vector to be displayed following the %in% operator


问:
Keep state locally in my browser after click
I'm trying to build a simple Bingo site where a button choose a random number, and this number changes the color of a div, so it is visible that this number is picked.

I only want it to remember which numbers are chosen locally.

I think it is maybe something to do with localStorage(), but i can not figure out how.

Little piece of code where it selects a random number looks like this:

```<code>$('.new_number').click(function(){
    random_number = Math.floor((Math.random(1,90) * 90) + 1) ;
    $('.' + random_number).toggleClass('box1');
    localStorage
})
</code>```

Body:
I'm trying to build a simple Bingo site where a button choose a random number, and this number changes the color of a div, so it is visible that this number is picked.

I only want it to remember which numbers are chosen locally.

I think it is maybe something to do with localStorage(), but i can not figure out how.

Little piece of code where it selects a random number looks like this:

$('.new_number').click(function(){
    random_number = Math.floor((Math.random(1,90) * 90) + 1) ;
    $('.' + random_number).toggleClass('box1');
    localStorage
})


问:
How to understand percentages of hue and significance of x value from histplot
To simplify think about I have data of only two columns:

MonthlyIncome: numerical

Attrition: Yes or No

When I draw a histplot, it gave me a picture like this:

histplot
lineplot

I can see that in 2500 MonthlyIncome area, Attrition=Yes counts is high, but also Attrition=No is high.
Same in 10000 Income bin area. Attrition=Yes is high but also Attrition=No is high.

So I can not decide if this 2500 (or 10000) is important, is it enough to make that conclusion ''2500 Income People tend to leave job''. Maybe it is not because in the all bins attrition rate might be %20. Maybe machine learning models can understand but I can not understand

Could you give me some information and code sample to determine if this areas important or not?
How can I convert them to percentage format?


问:
Plotting 2D Schrodinger equation on Python and be able to see a resonance at certain energy
I have a code to make about the 2D schrodinger equation time dependant. I was able to figure how to use the finites differences and I guess I was able to solve the 1D schrodinger equation. But know I have to plot my wave function in spherical coordinate (so in 2D?) and create an animation to observe a wave packet at certain energies (3.48 Hartree). It is suggested that E=k^2/2 So I used this to make my schrodinger equation energy dependant. The potential and deltak are given. I also need to make the wave packet propagatinf from r=15 to r=0, I think that I just need to insert a minus in my exponential in my psi0 which I did in the code below. Any idea or even explanation would be welcome

```<code>import numpy as np
from scipy import sparse
import matplotlib.pyplot as plt
import scipy.integrate as integrate
from matplotlib.animation import FuncAnimation
from matplotlib import animation
from IPython import display

</code>```
```<code>dx    = 0.02                      # spatial separation
a= 15
x     = np.arange(0.1, a, dx)       # spatial grid points

deltak = 0.2                       # center of initial gaussian wave-packet

E=3.48
x0= 2

A=1.0 / (deltak * np.sqrt(np.pi)) # normalization constant

hbar = 1

dt = 0.1  # time interval for snapshots
t0 = 0.0    # initial time
tf = 1.0    # final time

t_eval = np.arange(t0, tf, dt)
k =  np.sqrt(2 * E)

Vx=  7.5 * x**2 * np.exp(-x)

def psi_t2(t,psi):
    return  (-1j * (((-0.5 * D2.dot(psi)) + V * psi)))

# Initial Wavefunction
psi0_ = np.sqrt(A) * np.exp(-(x-x0)**2 / (2.0 * deltak**2)) * np.exp(1j * -k * x)

# Solve the Initial Value Problem
sol_ = integrate.solve_ivp(psi_t2, t_span = [t0, tf], y0 = psi0_, t_eval = t_eval,method="RK23")

for i,t in enumerate (sol_.t):
    plt.plot(x, np.abs(sol_.y[:,i])**2)

fig=plt.figure()
ax=plt.subplot(1,1,1)
#fig,ax = plt.subplots(figsize=(8,4))

ax.set_xlim(-5, 16)
ax.set_ylim(0, 5)
title = ax.set_title('')

line1, = ax.plot([], [], "k--")
line2, = ax.plot([], [])

def init():
    line1.set_data(x, V)
    return line1,

def animate(i):
    line2.set_data(x, np.abs(sol_.y[:,i])**2)
    #line2.set_data(x, np.real(sol.y[:, i]))
    #line2.set_data(x, np.abs(psi))
    title.set_text('Time = {0:1.3f}'.format(sol_.t[i])) #permet d'afficher le temps
    return line1,

anim = animation.FuncAnimation(fig, animate, init_func=init,frames=len(sol_.t), interval=50, blit=True)

video = anim.to_html5_video()
html = display.HTML(video)
display.display(html)
plt.close()
</code>```

Body:
I have a code to make about the 2D schrodinger equation time dependant. I was able to figure how to use the finites differences and I guess I was able to solve the 1D schrodinger equation. But know I have to plot my wave function in spherical coordinate (so in 2D?) and create an animation to observe a wave packet at certain energies (3.48 Hartree). It is suggested that E=k^2/2 So I used this to make my schrodinger equation energy dependant. The potential and deltak are given. I also need to make the wave packet propagatinf from r=15 to r=0, I think that I just need to insert a minus in my exponential in my psi0 which I did in the code below. Any idea or even explanation would be welcome

import numpy as np
from scipy import sparse
import matplotlib.pyplot as plt
import scipy.integrate as integrate
from matplotlib.animation import FuncAnimation
from matplotlib import animation
from IPython import display

dx    = 0.02                      # spatial separation
a= 15
x     = np.arange(0.1, a, dx)       # spatial grid points

deltak = 0.2                       # center of initial gaussian wave-packet

E=3.48
x0= 2

A=1.0 / (deltak * np.sqrt(np.pi)) # normalization constant

hbar = 1

dt = 0.1  # time interval for snapshots
t0 = 0.0    # initial time
tf = 1.0    # final time

t_eval = np.arange(t0, tf, dt)
k =  np.sqrt(2 * E)

Vx=  7.5 * x**2 * np.exp(-x)

def psi_t2(t,psi):
    return  (-1j * (((-0.5 * D2.dot(psi)) + V * psi)))

# Initial Wavefunction
psi0_ = np.sqrt(A) * np.exp(-(x-x0)**2 / (2.0 * deltak**2)) * np.exp(1j * -k * x)

# Solve the Initial Value Problem
sol_ = integrate.solve_ivp(psi_t2, t_span = [t0, tf], y0 = psi0_, t_eval = t_eval,method="RK23")

for i,t in enumerate (sol_.t):
    plt.plot(x, np.abs(sol_.y[:,i])**2)

fig=plt.figure()
ax=plt.subplot(1,1,1)
#fig,ax = plt.subplots(figsize=(8,4))

ax.set_xlim(-5, 16)
ax.set_ylim(0, 5)
title = ax.set_title('')

line1, = ax.plot([], [], "k--")
line2, = ax.plot([], [])

def init():
    line1.set_data(x, V)
    return line1,

def animate(i):
    line2.set_data(x, np.abs(sol_.y[:,i])**2)
    #line2.set_data(x, np.real(sol.y[:, i]))
    #line2.set_data(x, np.abs(psi))
    title.set_text('Time = {0:1.3f}'.format(sol_.t[i])) #permet d'afficher le temps
    return line1,

anim = animation.FuncAnimation(fig, animate, init_func=init,frames=len(sol_.t), interval=50, blit=True)

video = anim.to_html5_video()
html = display.HTML(video)
display.display(html)
plt.close()


问:
new column include centroid
I am working on k-mean clustering.
I have a problem to divided records into centroids by adding new columns like this

Column A
Centroid

coud
1

Hot
3

coud
3

coud
2

Hot
1

I need to create new dataframe include column of Centroid

Title: new column include centroid


问:
Annotation @Type dosent find attribute type to map classes in hibernate
I am trying to map 2 classes in hibernate with @Type annotation.

I read great amount of publication that say to use @Type(type = ""), but when I use it I got next:

I tried to use attribute value, with declaring class but it also didn't work:


问:
How to call method in correct asyncio context from a different thread in Python (Textual framework)
I have an old python multithreaded console app using urwid as its visualization library.
I'd like to switch to Textual which looks amazing.

I've never managed a mix of multithreaded and asyncio code, and I'd like to avoid rewriting the old app to migrate all the thread-based code to async.

I'm not able to figure out how to call Textual widgets methods that update the ui from external threads.

For example, the following test code that simulates a separate thread trying to add lines to a TextLog widget raises a NoActiveAppError exception.

import time
import threading
from textual.app import App, ComposeResult
from textual.widgets import TextLog
from textual.pilot import Pilot

# simple textual app with a single textlog widget
class MyApp(App):

    def compose(self) -> ComposeResult:

        self.logbox = TextLog(id="log", wrap=True, max_lines=1024)
        yield self.logbox

# init textlog content when ready
async def on_ready(pilot: Pilot):
    pilot.app.logbox.write("Welcome to this and that!")

# separate thread
def test_thread():
    i = 0
    while True:
        # do stuff
        time.sleep(3)
        i += 1
        # this throws a NoActiveApp exception
        app.logbox.write(f"Iteration #{i}")

app = MyApp()
threading.Thread(target=test_thread).start()
app.run(auto_pilot=on_ready)

```

It looks like Textual is making use of contextvars, thus storing in the main async loop thread context a copy of the app instance.

For instance I'd like to call the TextLog widget write method from the separate thread, but I cannot figure out how.

Body:
I have an old python multithreaded console app using urwid as its visualization library.
I'd like to switch to Textual which looks amazing.

I've never managed a mix of multithreaded and asyncio code, and I'd like to avoid rewriting the old app to migrate all the thread-based code to async.

I'm not able to figure out how to call Textual widgets methods that update the ui from external threads.

For example, the following test code that simulates a separate thread trying to add lines to a TextLog widget raises a NoActiveAppError exception.

import time
import threading
from textual.app import App, ComposeResult
from textual.widgets import TextLog
from textual.pilot import Pilot

# simple textual app with a single textlog widget
class MyApp(App):

    def compose(self) -> ComposeResult:

        self.logbox = TextLog(id="log", wrap=True, max_lines=1024)
        yield self.logbox

# init textlog content when ready
async def on_ready(pilot: Pilot):
    pilot.app.logbox.write("Welcome to this and that!")

# separate thread
def test_thread():
    i = 0
    while True:
        # do stuff
        time.sleep(3)
        i += 1
        # this throws a NoActiveApp exception
        app.logbox.write(f"Iteration #{i}")

app = MyApp()
threading.Thread(target=test_thread).start()
app.run(auto_pilot=on_ready)

It looks like Textual is making use of contextvars, thus storing in the main async loop thread context a copy of the app instance.

For instance I'd like to call the TextLog widget write method from the separate thread, but I cannot figure out how.


问:
Why doesn't the border also surround the embedded video?
I'm trying to create a border which encompasses a couple of paragraphs and a video in between the paragraphs.  However, when I create a class for the paragraph tag and use CSS to create the border, the border only surrounds the beginning part of the paragraph and not the video and anything afterwards.

Here's the HTML code that I used:

```<code><p class = "mechanics_border">
    <a id = "red_wolf">x45 Boss Split (Red Wolf Spawns)</a><br>
    This is paragraph 1.<br>
    <center>
        <video width = "520" height = "340" autoplay muted controls>
            <source src = "videos/valtan/red-wolf-spawns.mp4" type = "video/mp4">
        </video>
    </center>
    <br>
    This is paragraph 2, it's not supposed to have it's own paragraph as I want it to be within the same border.
</p>
</code>```

Here's the CSS code that I wrote for it.

```<code>.mechanics_border{
    border-style: solid;
}
</code>```

Any help would be appreciated :)

Body:
I'm trying to create a border which encompasses a couple of paragraphs and a video in between the paragraphs.  However, when I create a class for the paragraph tag and use CSS to create the border, the border only surrounds the beginning part of the paragraph and not the video and anything afterwards.

Here's the HTML code that I used:

    x45 Boss Split (Red Wolf Spawns)

    This is paragraph 1.

        <video width = "520" height = "340" autoplay muted controls>
            <source src = "videos/valtan/red-wolf-spawns.mp4" type = "video/mp4">
        </video>

    This is paragraph 2, it's not supposed to have it's own paragraph as I want it to be within the same border.

Here's the CSS code that I wrote for it.

.mechanics_border{
    border-style: solid;
}

Any help would be appreciated :)


问:
Add whatsapp Link with pre defined text messages that include page title and page url
i need to insert whatsapp link just like https://wa.me/[phone number]
but with pre defined text message that are able to insert page title and also page url,
like for example when customer came from

page title: abcd

page url: wesbite.com/abc

the message should include both page title and page url like,

hello customer, may i help you

abc

website.com/abc

and if customer comes from

page title: efgh

page url: wesbite.com/efgh

the message should be like

hello customer, may i help you

efgh

website.com/efgh

i am using bigcommerce, and their support doesn't support for themes customization.
and i am also not an IT expert.

this link suppose to show both on header and footer.
is this possible to just add to a theme?

i found a code online like this

const msg = encodeURIComponent("Hello, thanks for contacting us! -- URL: " + window.location.href);
document.querySelector('.whatsapp-link').href = 'https://wa.me/6281381534824?text=' + msg

but i don't know how to use it.


问:
My Horizontal Scroll View Is not working istead its not showing my objects which are in scroll view
I was expecting that the objects inside my horizontal scroll view will make it horizontly scrollable but my objects are not shown when i use the scroll view:

```<code><ScrollView horizontal={true}
            showsHorizontalScrollIndicator={false}
            pagingEnabled={true} >
</code>```

My codes and Error:

https://i.stack.imgur.com/nPM4T.png

Body:
I was expecting that the objects inside my horizontal scroll view will make it horizontly scrollable but my objects are not shown when i use the scroll view:

<ScrollView horizontal={true}
            showsHorizontalScrollIndicator={false}
            pagingEnabled={true} >

My codes and Error:

https://i.stack.imgur.com/nPM4T.png


问:
NPM package import causes ERROR in ./node_modules ... export X (imported as X) was not found in Y (possible exports: default)
After installing the wix-style-react package from NPM to my react app using npm i wix-style-react, the moment I import anything from this package my app fails to compile with thousands of errors such as:

```<code>ERROR in ./node_modules/wix-style-react/dist/es/src/SkeletonRectangle/SkeletonRectangle.js 43:19-21
export 'st' (imported as 'st') was not found in './SkeletonRectangle.st.css' (possible exports: default)
</code>```

(such errors exist for all routes under ./node_modules/wix-style-react/dist/es/src/)

How can I fix this?
The package obviously should work as it has thousands of weekly downloads, so I'm guessing that fixing this involves some config / import change on my end.

To clarify - this is an external package so I have no control over the exports.

Thanks for your help!

package.json:

```<code>{
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^14.4.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^3.0.4",
    "wix-style-react": "^10.65.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
</code>```

Body:
After installing the wix-style-react package from NPM to my react app using npm i wix-style-react, the moment I import anything from this package my app fails to compile with thousands of errors such as:

ERROR in ./node_modules/wix-style-react/dist/es/src/SkeletonRectangle/SkeletonRectangle.js 43:19-21
export 'st' (imported as 'st') was not found in './SkeletonRectangle.st.css' (possible exports: default)

(such errors exist for all routes under ./node_modules/wix-style-react/dist/es/src/)

How can I fix this?
The package obviously should work as it has thousands of weekly downloads, so I'm guessing that fixing this involves some config / import change on my end.

To clarify - this is an external package so I have no control over the exports.

Thanks for your help!

package.json:

{
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^14.4.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^3.0.4",
    "wix-style-react": "^10.65.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}


问:
User reported that our app kill spotify background music, how to prevent that to happen?
So we got report that our app stop any music playing in the background like spotify, I also just tried it with youtube music and it also got killed

Our app is just a online f&b shop without any sound (but we use mediaPlayer to play logo animation in the beginning) and I dont think I've ever put some code to kill background music

is there any special setting I need to place in manifest to prevent this happening?

it is quite bewildering to me


问:
facing windows script host error whenever i create and start a .js file
This error is showing for me whenever I create a new .js file example: teams.js

this is the error that appears :

Script: C:\**\**\Desktop\foot\teams.js Line: 1 Charact : 1 Error: Syntax error Code: 800A03EA Source: Microsoft JScript compilation error

Everything was normal and working perfectly.

As usual, I turned off my pc and the error appeared the next day.

On the first day, the error was saying that **windows do not have the appropriate authorization for accessing file /path **

I looked for it on the internet, and I found a solution that says to uninstall adobe Flashplayer and reinstall it, I did so but the error remains.


问:
I don't know why Android Paging3 with RoomDatabase and Compose return entire data at once
199 messages are currently stored in the My Rooms database.

so I want paging this data with Paging Library.

I followed Android Developer explaination.

but My PagingData emit all of my Message Data at once..

what is the problem..

Dao

```<code>@Query("SELECT * FROM msgentity WHERE room_id =:roomId ORDER by msg")
fun getPassedMsg(roomId: String) : PagingSource<Int, MsgEntity>
</code>```

In ViewModel

```<code>val lst  = Pager(
    PagingConfig(
        pageSize = 30,
        enablePlaceholders = true,
    )
){
    dao.getPassedMsg(argus.roomId)
}.flow.cachedIn(viewModelScope)
</code>```

my Compose functions

```<code>    val msgL = viewModel.lst.collectAsLazyPagingItems()
    ChatInsideScreen(/*viewModel = viewModel*/msgL)
</code>```

and

```<code>@Composable
fun ChatInsideScreen(
msgL : LazyPagingItems<MsgEntity>
) {
    TestList(lst = msgL)
}

@Composable
fun TestList(lst : LazyPagingItems<MsgEntity>){
    LazyColumn(){
        itemsIndexed(lst) { idx, msg ->
            Text(text = "$idx : ${msg?.msg ?: "nono"}",)
            if (msg == null){
                Text(text = "placeHolder")
            }
        }
    }
}
</code>```

when My Screen init
all of 199 messages are delivered by Pager...

how can I fix it..

Body:
199 messages are currently stored in the My Rooms database.

so I want paging this data with Paging Library.

I followed Android Developer explaination.

but My PagingData emit all of my Message Data at once..

what is the problem..

Dao

@Query("SELECT * FROM msgentity WHERE room_id =:roomId ORDER by msg")
fun getPassedMsg(roomId: String) : PagingSource<Int, MsgEntity>

In ViewModel

val lst  = Pager(
    PagingConfig(
        pageSize = 30,
        enablePlaceholders = true,
    )
){
    dao.getPassedMsg(argus.roomId)
}.flow.cachedIn(viewModelScope)

my Compose functions

    val msgL = viewModel.lst.collectAsLazyPagingItems()
    ChatInsideScreen(/*viewModel = viewModel*/msgL)

and

@Composable
fun ChatInsideScreen(
msgL : LazyPagingItems<MsgEntity>
) {
    TestList(lst = msgL)
}

@Composable
fun TestList(lst : LazyPagingItems<MsgEntity>){
    LazyColumn(){
        itemsIndexed(lst) { idx, msg ->
            Text(text = "$idx : ${msg?.msg ?: "nono"}",)
            if (msg == null){
                Text(text = "placeHolder")
            }
        }
    }
}

when My Screen init
all of 199 messages are delivered by Pager...

how can I fix it..


问:
When i run npm start then give Node module error
```<code>ERROR in ../../node_modules/socks/build/common/helpers.js 9:15-32

Module not found: Error: Can't resolve 'stream' in 'D:\Full stack web developer\node_modules\socks\build\common'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
    - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "stream": false }
</code>```


问:
How to sequence multiple text animations one after one?
using CSS and html how can we sequence multiple text animations one after one?

I am not able to print multiple text animations in a sequence in html and CSS...


问:
PHP vers. 5.6 or 5.5 on Windows 11 - Error "No input file specified."
I'm having trouble installing PHP with the old version 5.6 or below (5.2 is running well) on my Windows 11 machine. I know it is not recommended to run this old version, but in fact, I need to do so at the moment.

I know that this question is already asked several times, but all solutions did not help in my case. I already googled a lot this error message, but all hints did not work for me. Here are some links I had a look at:

PHP error: "No input file specified." in IIS 10.0, PHP 5.6 on local development server

"No input file specified" for some versions of PHP

and many more.

The error is, that I'm getting always the message

No input file specified.

when trying to open a PHP page.
I already tried IIS as webserver as well as Apache, but the error is the same. So I assume it is not an issue of the webserver, but PHP.
In Apache I'm getting more information in the error.log file.

I already tried to set the document_root in PHP and Apache to the exact same location. I already tried to comment out the document_root and open_basedir as described in other posts. The PHP version is a fresh download from https://windows.php.net/downloads/releases/archives/. I used the file php.ini-production template as php.ini. I just changed display_errors to On. The rest of the php.ini has not been changed (except doc_root trying to outcomment).

The configuration of PHP in the Apache webserver looks like this:

```<code><IfModule fcgid_module>
FcgidInitialEnv PHPRC "D:/PHP/v5.5.38-nts-Win32-VC11-x86"
<FilesMatch \.(php|html)$>
    SetHandler fcgid-script
</FilesMatch>
FcgidWrapper "D:/PHP/v5.5.38-nts-Win32-VC11-x86/php-cgi.exe" .php
FcgidWrapper "D:/PHP/v5.5.38-nts-Win32-VC11-x86/php-cgi.exe" .html
</IfModule>
</code>```

I've set the Apaches' webserver LogLevel to trace8 to get more information.
This is being written in the error log file of Apache, when I'm trying to access i.e. the phpinfo.php file.

[Sat Dec 31 11:23:18.338359 2022] [core:trace5] [pid 16684:tid 1184]
protocol.c(711): [client ::1:50400] Request received from client: GET
/phpinfo.php HTTP/1.1

[Sat Dec 31 11:23:18.339347 2022] [http:trace4]
[pid 16684:tid 1184] http_request.c(435): [client ::1:50400] Headers
received from client:

[Sat Dec 31 11:23:18.339347 2022] [http:trace4]
[pid 16684:tid 1184] http_request.c(438): [client ::1:50400]   Host:
localhost

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]   Connection:
keep-alive

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Cache-Control: max-age=0

[Sat Dec 31 11:23:18.339347 2022]
[http:trace4] [pid 16684:tid 1184] http_request.c(438): [client
::1:50400]   sec-ch-ua: \"Not?A_Brand\";v=\"8\",
\"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"

[Sat Dec
31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   sec-ch-ua-mobile: ?0 [Sat
Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   sec-ch-ua-platform:
\"Windows\"

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Upgrade-Insecure-Requests: 1

[Sat Dec 31 11:23:18.339347 2022]
[http:trace4] [pid 16684:tid 1184] http_request.c(438): [client
::1:50400]   User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Site: none [Sat
Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Mode: navigate

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-User: ?1

[Sat Dec
31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Dest: document

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Accept-Encoding: gzip,
deflate, br

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Cookie:
remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6ImpTL0F1Sk1RSmErdTdzQTlRME53bmc9PSIsInZhbHVlIjoidll4SFZ6SHA3WmFZRnVMZ3ZqS0I0cnpURlFKckJJdWExNTFHNmtlUWd2bFA2WFd0YlM4bG9QUWoyb2Q1NkpMU2pvcW9NZGY5M3dVTUUxdUYxbHc3RTBUa2lTZGhkT05takNTRnhNRkRPMzU5NDRCdklJcERidFdreHFMQm1KRnJsQ2twLzhPZEVSa2lZS2hGUTRNUDQwSnY3QUlHcGkvRWx5QU1naUF1UGFTWVRmbGJDU2dOTlp3MVp6aTV2ZDZmTjJpSjJFamJwNG9sak5SR2UxR3BnRDM1aUNnbTVZL2RKblN1YzBsL2l0VT0iLCJtYWMiOiI1MGU3MzMyZmFlZDgxNjQ1NjI3MjNmZWFmYTU4YzhlMWJlZjQzN2RiZTZjMjM5MjQ4NjRiMTliZjY5OTYyM2E0IiwidGFnIjoiIn0%3D;
HttpOnly; __utmc=111872281;
__utmz=111872281.1671477985.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.881906265.1671477985.1671477985.1671559722.2; PHPSESSID=k77fg6s7n5fnf42aq3851bbn04

[Sat Dec 31 11:23:18.339347 2022]
[authz_core:debug] [pid 16684:tid 1184] mod_authz_core.c(815): [client
::1:50400] AH01626: authorization result of Require all granted:
granted

[Sat Dec 31 11:23:18.339347 2022] [authz_core:debug] [pid
16684:tid 1184] mod_authz_core.c(815): [client ::1:50400] AH01626:
authorization result of : granted

[Sat Dec 31 11:23:18.339347 2022] [core:trace3] [pid 16684:tid 1184]
request.c(360): [client ::1:50400] request authorized without
authentication by access_checker_ex hook: /phpinfo.php

[Sat Dec 31 11:23:18.340339 2022] [core:trace4] [pid 16684:tid 1184]
util_script.c(568): [client ::1:50400] Headers from script
'phpinfo.php':

[Sat Dec 31 11:23:18.340339 2022] [core:trace4] [pid
16684:tid 1184] util_script.c(571): [client ::1:50400]   Status: 404
Not Found

[Sat Dec 31 11:23:18.340339 2022] [core:trace1] [pid
16684:tid 1184] util_script.c(650): [client ::1:50400] Status line
from script 'phpinfo.php': 404 Not Found

[Sat Dec 31 11:23:18.340339
2022] [core:trace4] [pid 16684:tid 1184] util_script.c(571): [client
::1:50400]   X-Powered-By: PHP/5.5.38

[Sat Dec 31 11:23:18.340339
2022] [core:trace4] [pid 16684:tid 1184] util_script.c(571): [client
::1:50400]   Content-type: text/html

[Sat Dec 31 11:23:18.340339 2022]
[http:trace3] [pid 16684:tid 1184] http_filters.c(1129): [client
::1:50400] Response sent with status 404, headers:

[Sat Dec 31 11:23:18.340339 2022] [http:trace5] [pid 16684:tid 1184]
http_filters.c(1138): [client ::1:50400]   Date: Sat, 31 Dec 2022
10:23:18 GMT

[Sat Dec 31 11:23:18.340339 2022] [http:trace5] [pid
16684:tid 1184] http_filters.c(1141): [client ::1:50400]   Server:
Apache/2.4.54 (Win64) mod_fcgid/2.3.10-dev

[Sat Dec 31 11:23:18.340339
2022] [http:trace4] [pid 16684:tid 1184] http_filters.c(959): [client
::1:50400]   X-Powered-By: PHP/5.5.38

[Sat Dec 31 11:23:18.340339
2022] [http:trace4] [pid 16684:tid 1184] http_filters.c(959): [client
::1:50400]   Keep-Alive: timeout=5, max=100

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Connection: Keep-Alive

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Transfer-Encoding: chunked

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Content-Type: text/html [Sat
Dec 31 11:23:18.340339 2022] [core:trace6] [pid 16684:tid 1184]
core_filters.c(828): [client ::1:50400] writev_nonblocking: 286/286

How can I solve this issue?

Body:
I'm having trouble installing PHP with the old version 5.6 or below (5.2 is running well) on my Windows 11 machine. I know it is not recommended to run this old version, but in fact, I need to do so at the moment.

I know that this question is already asked several times, but all solutions did not help in my case. I already googled a lot this error message, but all hints did not work for me. Here are some links I had a look at:

PHP error: "No input file specified." in IIS 10.0, PHP 5.6 on local development server

"No input file specified" for some versions of PHP

and many more.

The error is, that I'm getting always the message

No input file specified.

when trying to open a PHP page.
I already tried IIS as webserver as well as Apache, but the error is the same. So I assume it is not an issue of the webserver, but PHP.
In Apache I'm getting more information in the error.log file.

I already tried to set the document_root in PHP and Apache to the exact same location. I already tried to comment out the document_root and open_basedir as described in other posts. The PHP version is a fresh download from https://windows.php.net/downloads/releases/archives/. I used the file php.ini-production template as php.ini. I just changed display_errors to On. The rest of the php.ini has not been changed (except doc_root trying to outcomment).

The configuration of PHP in the Apache webserver looks like this:

<IfModule fcgid_module>
FcgidInitialEnv PHPRC "D:/PHP/v5.5.38-nts-Win32-VC11-x86"
<FilesMatch \.(php|html)$>
    SetHandler fcgid-script
</FilesMatch>
FcgidWrapper "D:/PHP/v5.5.38-nts-Win32-VC11-x86/php-cgi.exe" .php
FcgidWrapper "D:/PHP/v5.5.38-nts-Win32-VC11-x86/php-cgi.exe" .html
</IfModule>

I've set the Apaches' webserver LogLevel to trace8 to get more information.
This is being written in the error log file of Apache, when I'm trying to access i.e. the phpinfo.php file.

[Sat Dec 31 11:23:18.338359 2022] [core:trace5] [pid 16684:tid 1184]
protocol.c(711): [client ::1:50400] Request received from client: GET
/phpinfo.php HTTP/1.1

[Sat Dec 31 11:23:18.339347 2022] [http:trace4]
[pid 16684:tid 1184] http_request.c(435): [client ::1:50400] Headers
received from client:

[Sat Dec 31 11:23:18.339347 2022] [http:trace4]
[pid 16684:tid 1184] http_request.c(438): [client ::1:50400]   Host:
localhost

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]   Connection:
keep-alive

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Cache-Control: max-age=0

[Sat Dec 31 11:23:18.339347 2022]
[http:trace4] [pid 16684:tid 1184] http_request.c(438): [client
::1:50400]   sec-ch-ua: \"Not?A_Brand\";v=\"8\",
\"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"

[Sat Dec
31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   sec-ch-ua-mobile: ?0 [Sat
Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   sec-ch-ua-platform:
\"Windows\"

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Upgrade-Insecure-Requests: 1

[Sat Dec 31 11:23:18.339347 2022]
[http:trace4] [pid 16684:tid 1184] http_request.c(438): [client
::1:50400]   User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Site: none [Sat
Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Mode: navigate

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-User: ?1

[Sat Dec
31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Sec-Fetch-Dest: document

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Accept-Encoding: gzip,
deflate, br

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid
16684:tid 1184] http_request.c(438): [client ::1:50400]

Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7

[Sat Dec 31 11:23:18.339347 2022] [http:trace4] [pid 16684:tid 1184]
http_request.c(438): [client ::1:50400]   Cookie:
remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6ImpTL0F1Sk1RSmErdTdzQTlRME53bmc9PSIsInZhbHVlIjoidll4SFZ6SHA3WmFZRnVMZ3ZqS0I0cnpURlFKckJJdWExNTFHNmtlUWd2bFA2WFd0YlM4bG9QUWoyb2Q1NkpMU2pvcW9NZGY5M3dVTUUxdUYxbHc3RTBUa2lTZGhkT05takNTRnhNRkRPMzU5NDRCdklJcERidFdreHFMQm1KRnJsQ2twLzhPZEVSa2lZS2hGUTRNUDQwSnY3QUlHcGkvRWx5QU1naUF1UGFTWVRmbGJDU2dOTlp3MVp6aTV2ZDZmTjJpSjJFamJwNG9sak5SR2UxR3BnRDM1aUNnbTVZL2RKblN1YzBsL2l0VT0iLCJtYWMiOiI1MGU3MzMyZmFlZDgxNjQ1NjI3MjNmZWFmYTU4YzhlMWJlZjQzN2RiZTZjMjM5MjQ4NjRiMTliZjY5OTYyM2E0IiwidGFnIjoiIn0%3D;
HttpOnly; __utmc=111872281;
__utmz=111872281.1671477985.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=111872281.881906265.1671477985.1671477985.1671559722.2; PHPSESSID=k77fg6s7n5fnf42aq3851bbn04

[Sat Dec 31 11:23:18.339347 2022]
[authz_core:debug] [pid 16684:tid 1184] mod_authz_core.c(815): [client
::1:50400] AH01626: authorization result of Require all granted:
granted

[Sat Dec 31 11:23:18.339347 2022] [authz_core:debug] [pid
16684:tid 1184] mod_authz_core.c(815): [client ::1:50400] AH01626:
authorization result of : granted

[Sat Dec 31 11:23:18.339347 2022] [core:trace3] [pid 16684:tid 1184]
request.c(360): [client ::1:50400] request authorized without
authentication by access_checker_ex hook: /phpinfo.php

[Sat Dec 31 11:23:18.340339 2022] [core:trace4] [pid 16684:tid 1184]
util_script.c(568): [client ::1:50400] Headers from script
'phpinfo.php':

[Sat Dec 31 11:23:18.340339 2022] [core:trace4] [pid
16684:tid 1184] util_script.c(571): [client ::1:50400]   Status: 404
Not Found

[Sat Dec 31 11:23:18.340339 2022] [core:trace1] [pid
16684:tid 1184] util_script.c(650): [client ::1:50400] Status line
from script 'phpinfo.php': 404 Not Found

[Sat Dec 31 11:23:18.340339
2022] [core:trace4] [pid 16684:tid 1184] util_script.c(571): [client
::1:50400]   X-Powered-By: PHP/5.5.38

[Sat Dec 31 11:23:18.340339
2022] [core:trace4] [pid 16684:tid 1184] util_script.c(571): [client
::1:50400]   Content-type: text/html

[Sat Dec 31 11:23:18.340339 2022]
[http:trace3] [pid 16684:tid 1184] http_filters.c(1129): [client
::1:50400] Response sent with status 404, headers:

[Sat Dec 31 11:23:18.340339 2022] [http:trace5] [pid 16684:tid 1184]
http_filters.c(1138): [client ::1:50400]   Date: Sat, 31 Dec 2022
10:23:18 GMT

[Sat Dec 31 11:23:18.340339 2022] [http:trace5] [pid
16684:tid 1184] http_filters.c(1141): [client ::1:50400]   Server:
Apache/2.4.54 (Win64) mod_fcgid/2.3.10-dev

[Sat Dec 31 11:23:18.340339
2022] [http:trace4] [pid 16684:tid 1184] http_filters.c(959): [client
::1:50400]   X-Powered-By: PHP/5.5.38

[Sat Dec 31 11:23:18.340339
2022] [http:trace4] [pid 16684:tid 1184] http_filters.c(959): [client
::1:50400]   Keep-Alive: timeout=5, max=100

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Connection: Keep-Alive

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Transfer-Encoding: chunked

[Sat Dec 31 11:23:18.340339 2022] [http:trace4] [pid 16684:tid 1184]
http_filters.c(959): [client ::1:50400]   Content-Type: text/html [Sat
Dec 31 11:23:18.340339 2022] [core:trace6] [pid 16684:tid 1184]
core_filters.c(828): [client ::1:50400] writev_nonblocking: 286/286

How can I solve this issue?


问:
OkHttp Mtls config with self-signed certificates
Trying to connect an android Java App to an API secured with mTLS that uses self-signed certificates

I tried the following code. The TLS part is working since when disabling the certificate authentication on server side the get request goes through with no problem. However when re-enabling I get the following error:

"error:1000045c:SSL routines:OPENSSL_internal:TLSV1_ALERT_CERTIFICATE_REQUIRED (external/boringssl/src/ssl/tls_record.cc:594 0xb4000074d73e2188:0x00000001)". Any ideas? Thanks!

```<code>OkHttpClient client;

// Load the client private key and public key from the "client.privkey" and "client.pubkey" files
PrivateKey privKey = null;
PublicKey pubKey = null;
Resources res = getReactApplicationContext().getResources();
try {
    // Open the "client.privkey" and "client.pubkey" files as InputStreams
    InputStream privKeyStream = res.openRawResource(R.raw.privkey);
    InputStream pubKeyStream = res.openRawResource(R.raw.client);

    // Read the private key
    String privKeyStr = readInputStream(privKeyStream);
    privKey = getPrivateKeyFromString(privKeyStr);

    // Read the public key
    String pubKeyStr = readInputStream(pubKeyStream);
    pubKey = getPublicKeyFromString(pubKeyStr);
} catch (IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
    // Handle exceptions
}

// Load the self-signed certificate from the R.raw resources
InputStream caInput = getReactApplicationContext().getResources().openRawResource(R.raw.cacert);
Certificate ca;
try {
    // Generate a Certificate object from the certificate file
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    ca = cf.generateCertificate(caInput);
} catch (CertificateException e) {
    throw new RuntimeException("Failed to generate certificate", e);
} finally {
    try {
        caInput.close();
    } catch (IOException e) {
        // Ignore
    }
}

// Create a KeyStore containing the self-signed certificate
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore;
try {
    keyStore = KeyStore.getInstance(keyStoreType);
    keyStore.load(null, null);
    keyStore.setCertificateEntry("ca", ca);
    keyStore.setKeyEntry("client", privKey, null, new Certificate[] { ca });
} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException e) {
    throw new RuntimeException("Failed to create key store", e);
}

// Create a TrustManagerFactory that trusts the self-signed certificate
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf;
try {
    tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
    tmf.init(keyStore);
} catch (NoSuchAlgorithmException | KeyStoreException e) {
    throw new RuntimeException("Failed to create TrustManagerFactory", e);
}

// Create an SSLContext that uses the TrustManagerFactory
SSLContext sslContext;
try {
    sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, tmf.getTrustManagers(), null);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
    throw new RuntimeException("Failed to create SSLContext", e);
}

// Create an OkHttpClient that uses the SSLContext

client = new OkHttpClient.Builder()
        .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) tmf.getTrustManagers()[0])
        .build();

Log.d(TAG, "Requesting from url: " + API_URL);
Request request = new Request.Builder()
        .url(API_URL)
        .build();
//set hostname verifier
client = client.newBuilder().hostnameVerifier(new HostnameVerifier() {
    @Override
    public boolean verify(String hostname, SSLSession session) {
        return true;
    }
}).build();

// Encode the client public key to a base64 string
String pubKeyStr = pubKey.toString();

String finalPubKeyStr = pubKeyStr;
client = client.newBuilder().addInterceptor(new Interceptor() {
    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request original = chain.request();
        Request request = original.newBuilder()
                .header("Client-Public-Key", finalPubKeyStr)
                .method(original.method(), original.body())
                .build();
        return chain.proceed(request);
    }
}).build();
//set client certificate authentication
client = client.newBuilder().sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) tmf.getTrustManagers()[0]).build();

Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
    throw new IOException("Unexpected response code: " + response.code());
}
Log.d(TAG, "Response: " + response.body().string());
</code>```

Body:
Trying to connect an android Java App to an API secured with mTLS that uses self-signed certificates

I tried the following code. The TLS part is working since when disabling the certificate authentication on server side the get request goes through with no problem. However when re-enabling I get the following error:

"error:1000045c:SSL routines:OPENSSL_internal:TLSV1_ALERT_CERTIFICATE_REQUIRED (external/boringssl/src/ssl/tls_record.cc:594 0xb4000074d73e2188:0x00000001)". Any ideas? Thanks!

OkHttpClient client;

// Load the client private key and public key from the "client.privkey" and "client.pubkey" files
PrivateKey privKey = null;
PublicKey pubKey = null;
Resources res = getReactApplicationContext().getResources();
try {
    // Open the "client.privkey" and "client.pubkey" files as InputStreams
    InputStream privKeyStream = res.openRawResource(R.raw.privkey);
    InputStream pubKeyStream = res.openRawResource(R.raw.client);

    // Read the private key
    String privKeyStr = readInputStream(privKeyStream);
    privKey = getPrivateKeyFromString(privKeyStr);

    // Read the public key
    String pubKeyStr = readInputStream(pubKeyStream);
    pubKey = getPublicKeyFromString(pubKeyStr);
} catch (IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
    // Handle exceptions
}

// Load the self-signed certificate from the R.raw resources
InputStream caInput = getReactApplicationContext().getResources().openRawResource(R.raw.cacert);
Certificate ca;
try {
    // Generate a Certificate object from the certificate file
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    ca = cf.generateCertificate(caInput);
} catch (CertificateException e) {
    throw new RuntimeException("Failed to generate certificate", e);
} finally {
    try {
        caInput.close();
    } catch (IOException e) {
        // Ignore
    }
}

// Create a KeyStore containing the self-signed certificate
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore;
try {
    keyStore = KeyStore.getInstance(keyStoreType);
    keyStore.load(null, null);
    keyStore.setCertificateEntry("ca", ca);
    keyStore.setKeyEntry("client", privKey, null, new Certificate[] { ca });
} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException e) {
    throw new RuntimeException("Failed to create key store", e);
}

// Create a TrustManagerFactory that trusts the self-signed certificate
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf;
try {
    tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
    tmf.init(keyStore);
} catch (NoSuchAlgorithmException | KeyStoreException e) {
    throw new RuntimeException("Failed to create TrustManagerFactory", e);
}

// Create an SSLContext that uses the TrustManagerFactory
SSLContext sslContext;
try {
    sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, tmf.getTrustManagers(), null);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
    throw new RuntimeException("Failed to create SSLContext", e);
}

// Create an OkHttpClient that uses the SSLContext

client = new OkHttpClient.Builder()
        .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) tmf.getTrustManagers()[0])
        .build();

Log.d(TAG, "Requesting from url: " + API_URL);
Request request = new Request.Builder()
        .url(API_URL)
        .build();
//set hostname verifier
client = client.newBuilder().hostnameVerifier(new HostnameVerifier() {
    @Override
    public boolean verify(String hostname, SSLSession session) {
        return true;
    }
}).build();

// Encode the client public key to a base64 string
String pubKeyStr = pubKey.toString();

String finalPubKeyStr = pubKeyStr;
client = client.newBuilder().addInterceptor(new Interceptor() {
    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request original = chain.request();
        Request request = original.newBuilder()
                .header("Client-Public-Key", finalPubKeyStr)
                .method(original.method(), original.body())
                .build();
        return chain.proceed(request);
    }
}).build();
//set client certificate authentication
client = client.newBuilder().sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) tmf.getTrustManagers()[0]).build();

Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
    throw new IOException("Unexpected response code: " + response.code());
}
Log.d(TAG, "Response: " + response.body().string());


问:
Deep Java Library (DJL) - logical AND classification
I am trying to build a simple neural network to represent a logical AND.

As I am new to machine learning and the Deep Java Library I was following the beginner tutorial: https://docs.djl.ai/jupyter/tutorial/01_create_your_first_network.html

The result of the tutorial was good and I got the correct results.

Then I have modified the code to:

read data from a CSV file

use the data from the CSV file for training

classify an input vector of two float values

The code is shown below. Unfortunately the result of the classification is not as expected.

When I use:

```<code>float one [] = {1f,1f};
classify(one);
</code>```

I get the result:

```<code>0: 0.5816633701324463
1: 0.4183366000652313
</code>```

When I use:

```<code>float zero [] = {1f,0f};
classify(zero);
</code>```

I get the result:

```<code>0: 0.5276625156402588
1: 0.47233742475509644
</code>```

So there is something obviously wrong, but I do not know where to start:

data / training

model type

network setup

Maybe someone can help me to find the solution and show me the mistake I am making.

Java code:

```<code>import ai.djl.*;
import ai.djl.training.*;
import java.io.IOException;
import java.nio.file.*;
import ai.djl.ndarray.types.*;
import ai.djl.training.loss.*;
import ai.djl.training.listener.*;
import ai.djl.training.evaluator.*;
import ai.djl.basicmodelzoo.basic.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.csv.CSVFormat;
import ai.djl.ndarray.*;
import ai.djl.modality.*;
import ai.djl.translate.*;
import ai.djl.ndarray.NDList;
import ai.djl.translate.TranslateException;
import ai.djl.basicdataset.tabular.CsvDataset;
import ai.djl.basicdataset.tabular.utils.Feature;

public class App
{
    public static void main( String[] args )
    {
        boolean train = false;

        if(train) {
            try {
                training();
            } catch (Exception e) {
                System.out.println("[ERROR] Could not train");
                e.printStackTrace();
            }
        } else {
            try {
                // define some input vectors for the neural network
                float zero [] = {1f,0f};
                float zero2 [] = {0f,0f};
                float one [] = {1f,1f};

                classify(zero);
            } catch (Exception e) {
                System.out.println("[ERROR] Could not classify");
                e.printStackTrace();
            }
        }

    }

    /**
     * Classify with the trained neural network
     * @throws MalformedModelException
     * @throws IOException
     * @throws TranslateException
     */
    static void classify(float [] input) throws MalformedModelException, IOException, TranslateException {

        Path modelDir = Paths.get("build/mlp");
        Model model = Model.newInstance("mlpBlock");
        model.setBlock(new Mlp(2, 2, new int[] {2}));
        model.load(modelDir);

        Translator<float[], Classifications> translator = new Translator<float[], Classifications>() {

            @Override
            public NDList processInput(TranslatorContext ctx, float[] input) {

                NDArray array = ctx.getNDManager().create(input);
                NDList ndList = new NDList();
                ndList.add(array);
                return ndList;
            }

            @Override
            public Classifications processOutput(TranslatorContext ctx, NDList list) {
                NDArray probabilities = list.singletonOrThrow().softmax(0);
                List<String> classNames = IntStream.range(0, 2).mapToObj(String::valueOf).collect(Collectors.toList());
                return new Classifications(classNames, probabilities);
            }

            @Override
            public Batchifier getBatchifier() {
                return Batchifier.STACK;
            }
        };

        var predictor = model.newPredictor(translator);

        var classifications = predictor.predict(input);

        for(int i = 0; i < classifications.getProbabilities().size(); i++) {
            System.out.println(classifications.getClassNames().get(i) + ": " + classifications.getProbabilities().get(i));

        }
    }

    /**
     * Train the neural network
     * @throws IOException
     * @throws TranslateException
     */
    static void training() throws IOException, TranslateException {

        Path csvPath = Paths.get("TrainingDataAND.csv");

        CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader();

        CsvDataset dataset = CsvDataset.builder()
            .optCsvFile(csvPath)
            .addFeature(new Feature("in1", true))
            .addFeature(new Feature("in2", true))
            .addLabel(new Feature("result", true))
            .setSampling(2, true)
            .setCsvFormat(csvFormat)
            .build();

        Model model = Model.newInstance("mlpBlock");
        model.setBlock(new Mlp(2, 2, new int[] {2}));

        DefaultTrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss())
            .addEvaluator(new Accuracy())
            .addTrainingListeners(TrainingListener.Defaults.logging());

        Trainer trainer = model.newTrainer(config);

        trainer.initialize(new Shape(1, 2));

        int epoch = 2;

        EasyTrain.fit(trainer, epoch, dataset, null);

        Path modelDir = Paths.get("build/mlp");
        Files.createDirectories(modelDir);

        model.setProperty("Epoch", String.valueOf(epoch));

        model.save(modelDir, "mlpBlock");

    }
}

</code>```

Training data (TrainingDataAND.csv):

```<code>in1,in2,result
1,1,1
1,0,0
0,1,0
0,0,0
</code>```

Body:
I am trying to build a simple neural network to represent a logical AND.

As I am new to machine learning and the Deep Java Library I was following the beginner tutorial: https://docs.djl.ai/jupyter/tutorial/01_create_your_first_network.html

The result of the tutorial was good and I got the correct results.

Then I have modified the code to:

read data from a CSV file

use the data from the CSV file for training

classify an input vector of two float values

The code is shown below. Unfortunately the result of the classification is not as expected.

When I use:

float one [] = {1f,1f};
classify(one);

I get the result:

0: 0.5816633701324463
1: 0.4183366000652313

When I use:

float zero [] = {1f,0f};
classify(zero);

I get the result:

0: 0.5276625156402588
1: 0.47233742475509644

So there is something obviously wrong, but I do not know where to start:

data / training

model type

network setup

Maybe someone can help me to find the solution and show me the mistake I am making.

Java code:

import ai.djl.*;
import ai.djl.training.*;
import java.io.IOException;
import java.nio.file.*;
import ai.djl.ndarray.types.*;
import ai.djl.training.loss.*;
import ai.djl.training.listener.*;
import ai.djl.training.evaluator.*;
import ai.djl.basicmodelzoo.basic.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.csv.CSVFormat;
import ai.djl.ndarray.*;
import ai.djl.modality.*;
import ai.djl.translate.*;
import ai.djl.ndarray.NDList;
import ai.djl.translate.TranslateException;
import ai.djl.basicdataset.tabular.CsvDataset;
import ai.djl.basicdataset.tabular.utils.Feature;

public class App
{
    public static void main( String[] args )
    {
        boolean train = false;

        if(train) {
            try {
                training();
            } catch (Exception e) {
                System.out.println("[ERROR] Could not train");
                e.printStackTrace();
            }
        } else {
            try {
                // define some input vectors for the neural network
                float zero [] = {1f,0f};
                float zero2 [] = {0f,0f};
                float one [] = {1f,1f};

                classify(zero);
            } catch (Exception e) {
                System.out.println("[ERROR] Could not classify");
                e.printStackTrace();
            }
        }

    }

    /**
     * Classify with the trained neural network
     * @throws MalformedModelException
     * @throws IOException
     * @throws TranslateException
     */
    static void classify(float [] input) throws MalformedModelException, IOException, TranslateException {

        Path modelDir = Paths.get("build/mlp");
        Model model = Model.newInstance("mlpBlock");
        model.setBlock(new Mlp(2, 2, new int[] {2}));
        model.load(modelDir);

        Translator<float[], Classifications> translator = new Translator<float[], Classifications>() {

            @Override
            public NDList processInput(TranslatorContext ctx, float[] input) {

                NDArray array = ctx.getNDManager().create(input);
                NDList ndList = new NDList();
                ndList.add(array);
                return ndList;
            }

            @Override
            public Classifications processOutput(TranslatorContext ctx, NDList list) {
                NDArray probabilities = list.singletonOrThrow().softmax(0);
                List<String> classNames = IntStream.range(0, 2).mapToObj(String::valueOf).collect(Collectors.toList());
                return new Classifications(classNames, probabilities);
            }

            @Override
            public Batchifier getBatchifier() {
                return Batchifier.STACK;
            }
        };

        var predictor = model.newPredictor(translator);

        var classifications = predictor.predict(input);

        for(int i = 0; i < classifications.getProbabilities().size(); i++) {
            System.out.println(classifications.getClassNames().get(i) + ": " + classifications.getProbabilities().get(i));

        }
    }

    /**
     * Train the neural network
     * @throws IOException
     * @throws TranslateException
     */
    static void training() throws IOException, TranslateException {

        Path csvPath = Paths.get("TrainingDataAND.csv");

        CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader();

        CsvDataset dataset = CsvDataset.builder()
            .optCsvFile(csvPath)
            .addFeature(new Feature("in1", true))
            .addFeature(new Feature("in2", true))
            .addLabel(new Feature("result", true))
            .setSampling(2, true)
            .setCsvFormat(csvFormat)
            .build();

        Model model = Model.newInstance("mlpBlock");
        model.setBlock(new Mlp(2, 2, new int[] {2}));

        DefaultTrainingConfig config = new DefaultTrainingConfig(Loss.softmaxCrossEntropyLoss())
            .addEvaluator(new Accuracy())
            .addTrainingListeners(TrainingListener.Defaults.logging());

        Trainer trainer = model.newTrainer(config);

        trainer.initialize(new Shape(1, 2));

        int epoch = 2;

        EasyTrain.fit(trainer, epoch, dataset, null);

        Path modelDir = Paths.get("build/mlp");
        Files.createDirectories(modelDir);

        model.setProperty("Epoch", String.valueOf(epoch));

        model.save(modelDir, "mlpBlock");

    }
}

Training data (TrainingDataAND.csv):

in1,in2,result
1,1,1
1,0,0
0,1,0
0,0,0


问:
How to print the result of a .ps1 in windows form?
I'm creating a system for executing cascaded scripts. There will be a checklist and depending on the option that the user selects, he must execute these lines inside the powershell (.ps1). So that the user can follow the application status of the selected items, I want to print the execution status on the screen. I'm using C# the current command I'm using opens the powershell, and I don't want to make it available to the user.

Code

```<code>Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
scriptInvoker.Invoke("Set-ExecutionPolicy Unrestricted");

Pipeline pipeline = runspace.CreatePipeline();
Command command = new Command(@"E:\Users\goku\Downloads\Baseline1.ps1");
pipeline.Commands.Add(command);

pipeline.Invoke();
runspace.Close();
</code>```

Example

my idea is that this window opens to show the status and when it's done it closes automatically, I don't want to leave an exit button.

thank you if anyone can help.

I didn't find anything that would make it possible to print the result.

Body:
I'm creating a system for executing cascaded scripts. There will be a checklist and depending on the option that the user selects, he must execute these lines inside the powershell (.ps1). So that the user can follow the application status of the selected items, I want to print the execution status on the screen. I'm using C# the current command I'm using opens the powershell, and I don't want to make it available to the user.

Code

Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
scriptInvoker.Invoke("Set-ExecutionPolicy Unrestricted");

Pipeline pipeline = runspace.CreatePipeline();
Command command = new Command(@"E:\Users\goku\Downloads\Baseline1.ps1");
pipeline.Commands.Add(command);

pipeline.Invoke();
runspace.Close();

Example

my idea is that this window opens to show the status and when it's done it closes automatically, I don't want to leave an exit button.

thank you if anyone can help.

I didn't find anything that would make it possible to print the result.


问:
PHP able to receive post request with a raw text but its giving error when post same data raw json
I'm posting data to my API endpoint. it's simple JSON data. But I'm getting error 404 when posting data as raw JSON but if I post the same data at the same endpoint as raw text its works.

working as raw text

getting error 404 as raw JSON

```<code><?php

    var_dump(http_response_code());
    echo "hello";
    var_dump($_POST);
    echo file_get_contents("php://input");

</code>```

I have removed all code from the API end point and just trying to print post data.

Sample JSON :

```<code>{
    "object": "whatsapp_business_account",
    "entry": [
        {
            "id": "456",
            "changes": [
                {
                    "value": {
                        "messaging_product": "whatsapp",
                        "metadata": {
                            "display_phone_number": "123456789",
                            "phone_number_id": 123456789
                        },
                        "contacts": [
                            {
                                "profile": {
                                    "name": "NAME"
                                },
                                "wa_id": 123456789
                            }
                        ],
                        "messages": [
                            {
                                "from": 123456789,
                                "id": "wamid.ID",
                                "timestamp": 123456789,
                                "text": {
                                    "body": "MESSAGE_BODY"
                                },
                                "type": "text"
                            }
                        ]
                    },
                    "field": "messages"
                }
            ]
        }
    ]
}

</code>```

I have checked JSON and it's a valid JSON. no special character but still unable to solve this issue.

One more thing its working on my local machine under XAMPP but not on Linux shared server.

Body:
I'm posting data to my API endpoint. it's simple JSON data. But I'm getting error 404 when posting data as raw JSON but if I post the same data at the same endpoint as raw text its works.

working as raw text

getting error 404 as raw JSON

<?php

    var_dump(http_response_code());
    echo "hello";
    var_dump($_POST);
    echo file_get_contents("php://input");

I have removed all code from the API end point and just trying to print post data.

Sample JSON :

{
    "object": "whatsapp_business_account",
    "entry": [
        {
            "id": "456",
            "changes": [
                {
                    "value": {
                        "messaging_product": "whatsapp",
                        "metadata": {
                            "display_phone_number": "123456789",
                            "phone_number_id": 123456789
                        },
                        "contacts": [
                            {
                                "profile": {
                                    "name": "NAME"
                                },
                                "wa_id": 123456789
                            }
                        ],
                        "messages": [
                            {
                                "from": 123456789,
                                "id": "wamid.ID",
                                "timestamp": 123456789,
                                "text": {
                                    "body": "MESSAGE_BODY"
                                },
                                "type": "text"
                            }
                        ]
                    },
                    "field": "messages"
                }
            ]
        }
    ]
}

I have checked JSON and it's a valid JSON. no special character but still unable to solve this issue.

One more thing its working on my local machine under XAMPP but not on Linux shared server.


问:
"Take profit" and "stop trailing loss" codes for long positions, I want to compile for short positions
I want to compile the "take profit" and "trailing stop" codes that I use for long transactions, for short transactions. Could you help.

Here's what I did but it's not working.

Thanks

Codes

```<code>take_profit_level_short = strategy.position_avg_price * (1 - take_profit_short)
stop_loss_level_Short = close > strategy.position_avg_price * (1 + stop_loss_short)

var previous_high_value = 0.0
var original_ttp_value = 0.0

if asagi_kirilim and window and (allow_shorts == true)
    color.new(color.red, 80)
    strategy.entry("short", strategy.short, comment = alarm_label_short )
    previous_high_value := 0.0
    original_ttp_value := 0

// Short Take Profit!
if take_profit_level_short >= source_function(source_type) and (strategy.position_size < 0 or previous_high_value < 0.0) and (allow_shorts == true)
    if trailing_short > 0.0
        if previous_high_value < 0.0
            if source_function(source_type) <= previous_high_value
                previous_high_value := source_function(source_type)
                previous_high_value
            else
                previous_high_percent = (original_ttp_value - previous_high_value) * 1.0 / original_ttp_value
                current_high_percent = (original_ttp_value - source_function(source_type)) * 1.0 / original_ttp_value
                if ((previous_high_percent - current_high_percent)) <= trailing_short
                    strategy.close_all(comment= alarm_label_TP_short )
                    previous_high_value := 0
                    original_ttp_value := 0
                    original_ttp_value
        else
            previous_high_value := source_function(source_type)
            original_ttp_value := source_function(source_type)
            original_ttp_value
    else
        if buySignalk
            strategy.close_all(comment= alarm_label_TP_short )
            previous_high_value := 0
            original_ttp_value := 0
            original_ttp_value
    ```

```

Body:
I want to compile the "take profit" and "trailing stop" codes that I use for long transactions, for short transactions. Could you help.

Here's what I did but it's not working.

Thanks

Codes

take_profit_level_short = strategy.position_avg_price * (1 - take_profit_short)
stop_loss_level_Short = close > strategy.position_avg_price * (1 + stop_loss_short)

var previous_high_value = 0.0
var original_ttp_value = 0.0

if asagi_kirilim and window and (allow_shorts == true)
    color.new(color.red, 80)
    strategy.entry("short", strategy.short, comment = alarm_label_short )
    previous_high_value := 0.0
    original_ttp_value := 0

// Short Take Profit!
if take_profit_level_short >= source_function(source_type) and (strategy.position_size < 0 or previous_high_value < 0.0) and (allow_shorts == true)
    if trailing_short > 0.0
        if previous_high_value < 0.0
            if source_function(source_type) <= previous_high_value
                previous_high_value := source_function(source_type)
                previous_high_value
            else
                previous_high_percent = (original_ttp_value - previous_high_value) * 1.0 / original_ttp_value
                current_high_percent = (original_ttp_value - source_function(source_type)) * 1.0 / original_ttp_value
                if ((previous_high_percent - current_high_percent)) <= trailing_short
                    strategy.close_all(comment= alarm_label_TP_short )
                    previous_high_value := 0
                    original_ttp_value := 0
                    original_ttp_value
        else
            previous_high_value := source_function(source_type)
            original_ttp_value := source_function(source_type)
            original_ttp_value
    else
        if buySignalk
            strategy.close_all(comment= alarm_label_TP_short )
            previous_high_value := 0
            original_ttp_value := 0
            original_ttp_value
    ```


问:
TypeError: Cannot read properties of undefined (reading '_getIdTokenResponse') when trying to log in to Firebase with Google access token
I am trying to log in to my Firebase project from a Node.js application using a Google access token that I obtained from a Chrome extension. I am using the firebase-admin library and the signInWithCredential method to sign in with a Google OAuth credential, but I keep getting an error with the message "TypeError: Cannot read properties of undefined (reading '_getIdTokenResponse')".

Here is the code that I am using in my Node.js application to sign in with the Google access token:

`

```<code>...

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  XXXXXX
};

admin.initializeApp(firebaseConfig);

const app = express();
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/google/signin', async (req, res) => {
  const accessToken = req.body.accessToken;

  // Create a Google auth provider
  const googleAuthProvider = new admin.auth.GoogleAuthProvider();
  const credential = googleAuthProvider.credential(null, accessToken);

  // Sign in with the Firebase credential
  const auth = await firebaseAuth.signInWithCredential(credential);
  res.send(auth.user.displayName);
});

...

</code>```

`

I precise that I have this issue while doing the Post Request on Postman for now. As I wanted to try it manually first.

I have been trying to solve this issue for several hours, but I am unable to figure out. Any help would be greatly appreciated.

Body:
I am trying to log in to my Firebase project from a Node.js application using a Google access token that I obtained from a Chrome extension. I am using the firebase-admin library and the signInWithCredential method to sign in with a Google OAuth credential, but I keep getting an error with the message "TypeError: Cannot read properties of undefined (reading '_getIdTokenResponse')".

Here is the code that I am using in my Node.js application to sign in with the Google access token:

`

...

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  XXXXXX
};

admin.initializeApp(firebaseConfig);

const app = express();
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/google/signin', async (req, res) => {
  const accessToken = req.body.accessToken;

  // Create a Google auth provider
  const googleAuthProvider = new admin.auth.GoogleAuthProvider();
  const credential = googleAuthProvider.credential(null, accessToken);

  // Sign in with the Firebase credential
  const auth = await firebaseAuth.signInWithCredential(credential);
  res.send(auth.user.displayName);
});

...

`

I precise that I have this issue while doing the Post Request on Postman for now. As I wanted to try it manually first.

I have been trying to solve this issue for several hours, but I am unable to figure out. Any help would be greatly appreciated.


问:
how to filter negative numbers in pine script?
Im trying to filter open interest when it drops , for example if it drops -500k but not lower than -1mil gives a specific size of circle shape , or for second shape if it drops -10mil but not lower than -20m it gives bigger size in shape. i have no problem with positive numbers but somehow negative number mess together

the problem here is , it works but all shapes are showing it wont filter based on condition we give.
is there anyways to solve this please ,

```<code>//tiny size
sd =  VC < E() and close < open  and VC < -500000 and VC > -1000000

plotshape(sd, style=shape.circle, location=location.absolute, color=color.new(color.yellow, 75), size=size.tiny)

// smal size
sd1 =   VC < E() and close < open  and VC < -1000000 and VC > -2000000

plotshape(sd1, style=shape.circle, location=location.absolute, color=color.new(color.yellow, 75), size=size.small)
</code>```

as i mentioned above i have no problem with positive numbers in same method but it wont work on negative numbers,.

Body:
Im trying to filter open interest when it drops , for example if it drops -500k but not lower than -1mil gives a specific size of circle shape , or for second shape if it drops -10mil but not lower than -20m it gives bigger size in shape. i have no problem with positive numbers but somehow negative number mess together

the problem here is , it works but all shapes are showing it wont filter based on condition we give.
is there anyways to solve this please ,

//tiny size
sd =  VC < E() and close < open  and VC < -500000 and VC > -1000000

plotshape(sd, style=shape.circle, location=location.absolute, color=color.new(color.yellow, 75), size=size.tiny)

// smal size
sd1 =   VC < E() and close < open  and VC < -1000000 and VC > -2000000

plotshape(sd1, style=shape.circle, location=location.absolute, color=color.new(color.yellow, 75), size=size.small)

as i mentioned above i have no problem with positive numbers in same method but it wont work on negative numbers,.


问:
Problem with ActionListener to give a buttona value
I'm trying to give a functions to an array of jbuttons with ActionListener
but when I pass 'i' as variable it gives erorr :
App.java:45: error: local variables referenced from an inner class must be final or effectively final
the error is on line 45, 58, and 71.

Here's the code :

```<code>import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class App extends JFrame {
    App(){

        JFrame calcFrame = new JFrame();
        calcFrame.setSize(320, 420);
        calcFrame.setVisible(true);
        calcFrame.setTitle("Calculator");
        calcFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        calcFrame.setResizable(false);
        calcFrame.getContentPane().setBackground(new Color(0x123456));

        //add panel
        JTextField textField = new JTextField();
        textField.setBounds(35, 20, 200, 100);
        textField.setBackground(new Color(0x000000));
        calcFrame.add(textField);

        JButton cbtn = new JButton(String.valueOf('c')); // clear button
        cbtn.setBounds(240, 140, 50, 50);
        calcFrame.add(cbtn);

        JButton pbtn = new JButton(String.valueOf('^')); // power button
        pbtn.setBounds(240, 200, 50, 50);
        calcFrame.add(pbtn);

        /*Add array of buttuns from 0 ... 9 */

        JButton nums[] = new JButton[10];
        calcFrame.getContentPane().setLayout(null);

        // organzie using if statment
        for(int i = 0; i < 4; i++)
        {
            nums[i] = new JButton(String.valueOf(i)); // organzie first line 0 ... 3
            nums[i].setBounds(i * 60,  140, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        for(int i = 4, j = 0; i < 8; i++, j++)//organzie second line 4 ... 7
        {
            nums[i] = new JButton(String.valueOf(i));
            nums[i].setBounds(j * 60, 200, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        for(int i = 8, j = 0; i < 10; i++, j++)//last numbers line 8 ... 9
        {
            nums[i] = new JButton(String.valueOf(i));
            nums[i].setBounds(j * 60, 260, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        //End of numbers 0 ... 9
        JButton dotbtn = new JButton();
        JButton eqlbtn = new JButton();

        dotbtn = new JButton(String.valueOf('.'));// dot button for a value less than 1
        dotbtn.setBounds(120, 260, 50, 50);
        calcFrame.add(dotbtn);

        eqlbtn = new JButton(String.valueOf('=')); //equal button
        eqlbtn.setBounds(180, 260, 50, 50);;
        calcFrame.add(eqlbtn);

        String[] arthmetictools = {"+", "-", "x", "/"};

        JButton[] artbtns = new JButton[4]; // array of arthmetic buttons
        for (int i = 0; i <= 4; i++) {
            artbtns[i] = new JButton(String.valueOf(arthmetictools[i]));
            artbtns[i].setBounds( 60 * i, 320, 50, 50);
            calcFrame.add(artbtns[i]);
        }

    }
    public static void main(String[] args) {
        System.out.println("Hello, World!");

        /* make the frame call it calc frame */
        App calc = new App();

    }

}

</code>```

Thank you.

Tried to set text field to string of i from for loop.

Body:
I'm trying to give a functions to an array of jbuttons with ActionListener
but when I pass 'i' as variable it gives erorr :
App.java:45: error: local variables referenced from an inner class must be final or effectively final
the error is on line 45, 58, and 71.

Here's the code :

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class App extends JFrame {
    App(){

        JFrame calcFrame = new JFrame();
        calcFrame.setSize(320, 420);
        calcFrame.setVisible(true);
        calcFrame.setTitle("Calculator");
        calcFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        calcFrame.setResizable(false);
        calcFrame.getContentPane().setBackground(new Color(0x123456));

        //add panel
        JTextField textField = new JTextField();
        textField.setBounds(35, 20, 200, 100);
        textField.setBackground(new Color(0x000000));
        calcFrame.add(textField);

        JButton cbtn = new JButton(String.valueOf('c')); // clear button
        cbtn.setBounds(240, 140, 50, 50);
        calcFrame.add(cbtn);

        JButton pbtn = new JButton(String.valueOf('^')); // power button
        pbtn.setBounds(240, 200, 50, 50);
        calcFrame.add(pbtn);

        /*Add array of buttuns from 0 ... 9 */

        JButton nums[] = new JButton[10];
        calcFrame.getContentPane().setLayout(null);

        // organzie using if statment
        for(int i = 0; i < 4; i++)
        {
            nums[i] = new JButton(String.valueOf(i)); // organzie first line 0 ... 3
            nums[i].setBounds(i * 60,  140, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        for(int i = 4, j = 0; i < 8; i++, j++)//organzie second line 4 ... 7
        {
            nums[i] = new JButton(String.valueOf(i));
            nums[i].setBounds(j * 60, 200, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        for(int i = 8, j = 0; i < 10; i++, j++)//last numbers line 8 ... 9
        {
            nums[i] = new JButton(String.valueOf(i));
            nums[i].setBounds(j * 60, 260, 50, 50);
            nums[i].addActionListener(new ActionListener(){
                //give buttons a function
                @Override
                public void actionPerformed(ActionEvent e) {
                    textField.setText(textField.getText().concat(String.valueOf(i)));
                }
            });
            calcFrame.add(nums[i]);
        }
        //End of numbers 0 ... 9
        JButton dotbtn = new JButton();
        JButton eqlbtn = new JButton();

        dotbtn = new JButton(String.valueOf('.'));// dot button for a value less than 1
        dotbtn.setBounds(120, 260, 50, 50);
        calcFrame.add(dotbtn);

        eqlbtn = new JButton(String.valueOf('=')); //equal button
        eqlbtn.setBounds(180, 260, 50, 50);;
        calcFrame.add(eqlbtn);

        String[] arthmetictools = {"+", "-", "x", "/"};

        JButton[] artbtns = new JButton[4]; // array of arthmetic buttons
        for (int i = 0; i <= 4; i++) {
            artbtns[i] = new JButton(String.valueOf(arthmetictools[i]));
            artbtns[i].setBounds( 60 * i, 320, 50, 50);
            calcFrame.add(artbtns[i]);
        }

    }
    public static void main(String[] args) {
        System.out.println("Hello, World!");

        /* make the frame call it calc frame */
        App calc = new App();

    }

}

Thank you.

Tried to set text field to string of i from for loop.