问:
How to deploy Apache Nifi Statefulset in cluster mode with external zookeeper?
I tried to deploy Apache Nifi (statefulset) in Kubernetes, in cluster mode. Firstyly I am trying only one node but I don't know where I am wrong in the yaml and how to access the Nifi UI when I deploy Nifi statefulset. I use external zookeeper.

Not sure if I have to create service for each node of the cluster.

On K8S dashboard nifi pod is working well.

I know that Stateful sets allow the creation of stable network identities of pods by creating what is known as a headless service. But how can I access the UI next ?

Nifi StatefulSet yaml file:

```<code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nifi
  labels:
    name: nifi
    app: nifi
  annotations:
    app.kubernetes.io/name: nifi
    app.kubernetes.io/part-of: nifi
spec:
  serviceName: nifi
  # replicas: 2
  revisionHistoryLimit: 1
  # strategy:
  #   type: Recreate
  selector:
    matchLabels:
      app: nifi
  template:
    metadata:
      labels:
        app: nifi
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      restartPolicy: Always
      securityContext:
        runAsGroup: 1000
        runAsUser: 1000
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: nifi
        image: XXX
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          name: nifi
        - containerPort: 8082
          name: cluster
        env:
        - name: "NIFI_SENSITIVE_PROPS_KEY"
          value: "nificlusterbulot"
        - name: NIFI_WEB_HTTP_HOST
          value: "nifi-0.NAMESPACE_NAME.svc.cluster.local"
        - name: NIFI_WEB_HTTP_PORT
          value: "8080"
        - name: NIFI_ANALYTICS_PREDICT_ENABLED
          value: "true"
        - name: NIFI_ELECTION_MAX_CANDIDATES
          value: "2"
        - name: NIFI_ELECTION_MAX_WAIT
          value: "1 min"
        - name: NIFI_CLUSTER_IS_NODE
          value: "true"
        - name: NIFI_JVM_HEAP_INIT
          value: "3g"
        - name: NIFI_JVM_HEAP_MAX
          value: "4g"
        - name: NIFI_CLUSTER_NODE_CONNECTION_TIMEOUT
          value: "2 min"
        - name: NIFI_CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT
          value: "2 min"
        - name: NIFI_CLUSTER_NODE_PROTOCOL_MAX_THREADS
          value: "15"
        - name: NIFI_CLUSTER_NODE_PROTOCOL_PORT
          value: "8082"
        - name: NIFI_CLUSTER_NODE_READ_TIMEOUT
          value: "15"
        - name: NIFI_ZK_CONNECT_STRING
          value: "zookeeper:2181"
        - name: NIFI_CLUSTER_NODE_ADDRESS
          value: "nifi-0.nifi.NAMESPACE_NAME.cluster.local"
          # valueFrom:
          #   fieldRef:
          #     fieldPath: status.podIP
        # - name: HOSTNAME
        #   valueFrom:
        #     fieldRef:
        #       fieldPath: status.podIP
        livenessProbe:
          exec:
            command:
              - pgrep
              - java
          initialDelaySeconds: 60
          periodSeconds: 30
          timeoutSeconds: 10
          failureThreshold: 3
          successThreshold: 1
        readinessProbe:
          exec:
            command:
              - pgrep
              - java
          initialDelaySeconds: 180
          periodSeconds: 30
          timeoutSeconds: 10
          failureThreshold: 3
          successThreshold: 1
        resources:
          requests:
            cpu: 400m
            memory: 1Gi
          limits:
            cpu: 500m
            memory: 2Gi
      volumes:
        - name: pv-01
          persistentVolumeClaim:
            claimName: pv-claim
</code>```

Zookeeper yaml file:

```<code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper
  namespace: namespace_name
  labels:
    name : zookeeper
    app : zookeeper
  # annotations:
  #   app.kubernetes.io/name: zookeeper
  #   app.kubernetes.io/part-of: nifi
spec:
  revisionHistoryLimit: 1
  serviceName: zookeeper
  selector:
    matchLabels:
      app: zookeeper
  template:
    metadata:
      labels:
        app: zookeeper
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      restartPolicy: Always
      securityContext:
        runAsGroup: 1000
        runAsUser: 1000
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: zookeeper
        image: XXX
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 2181
          name: zk
        - containerPort: 2182
          name: zc
        # - containerPort: 8083
        #   name: web
        - containerPort: 5111
          name: cmd
        env:
          - name: ALLOW_ANONYMOUS_LOGIN
            value: "yes"
          - name: ZOO_ADMINSERVER_ENABLED
            value: "true"
          - name: ZOO_AUTOPURGE_PURGEINTERVAL
            value: "2"
          - name: ZOO_AUTOPURGE_SNAPRETAINCOUNT
            value: "10"
          - name: ZOO_INIT_LIMIT
            value: "10"
          - name: ZOO_STANDALONE_ENABLED
            value: "true"
          - name: ZOO_SYNC_LIMIT
            value: "6"
          - name: ZOO_TICK_TIME
            value: "4000"
        livenessProbe:
             exec:
                command:
                  - which
                  - java
             initialDelaySeconds: 30
             periodSeconds: 30
             timeoutSeconds: 10
             failureThreshold: 3
             successThreshold: 1
        readinessProbe:
             tcpSocket:
              port: 2181
             initialDelaySeconds: 120
             periodSeconds: 30
             timeoutSeconds: 10
             failureThreshold: 3
             successThreshold: 1
        resources:
          requests:
            cpu: 200m
            memory: 1Gi
          limits:
            cpu: 300m
            memory: 2Gi
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          runAsGroup: 1000
          runAsUser: 1000
      - name: pv-01
        persistentVolumeClaim:
          claimName: pv-claim
</code>```

Body:
I tried to deploy Apache Nifi (statefulset) in Kubernetes, in cluster mode. Firstyly I am trying only one node but I don't know where I am wrong in the yaml and how to access the Nifi UI when I deploy Nifi statefulset. I use external zookeeper.

Not sure if I have to create service for each node of the cluster.

On K8S dashboard nifi pod is working well.

I know that Stateful sets allow the creation of stable network identities of pods by creating what is known as a headless service. But how can I access the UI next ?

Nifi StatefulSet yaml file:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nifi
  labels:
    name: nifi
    app: nifi
  annotations:
    app.kubernetes.io/name: nifi
    app.kubernetes.io/part-of: nifi
spec:
  serviceName: nifi
  # replicas: 2
  revisionHistoryLimit: 1
  # strategy:
  #   type: Recreate
  selector:
    matchLabels:
      app: nifi
  template:
    metadata:
      labels:
        app: nifi
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      restartPolicy: Always
      securityContext:
        runAsGroup: 1000
        runAsUser: 1000
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: nifi
        image: XXX
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          name: nifi
        - containerPort: 8082
          name: cluster
        env:
        - name: "NIFI_SENSITIVE_PROPS_KEY"
          value: "nificlusterbulot"
        - name: NIFI_WEB_HTTP_HOST
          value: "nifi-0.NAMESPACE_NAME.svc.cluster.local"
        - name: NIFI_WEB_HTTP_PORT
          value: "8080"
        - name: NIFI_ANALYTICS_PREDICT_ENABLED
          value: "true"
        - name: NIFI_ELECTION_MAX_CANDIDATES
          value: "2"
        - name: NIFI_ELECTION_MAX_WAIT
          value: "1 min"
        - name: NIFI_CLUSTER_IS_NODE
          value: "true"
        - name: NIFI_JVM_HEAP_INIT
          value: "3g"
        - name: NIFI_JVM_HEAP_MAX
          value: "4g"
        - name: NIFI_CLUSTER_NODE_CONNECTION_TIMEOUT
          value: "2 min"
        - name: NIFI_CLUSTER_PROTOCOL_CONNECTION_HANDSHAKE_TIMEOUT
          value: "2 min"
        - name: NIFI_CLUSTER_NODE_PROTOCOL_MAX_THREADS
          value: "15"
        - name: NIFI_CLUSTER_NODE_PROTOCOL_PORT
          value: "8082"
        - name: NIFI_CLUSTER_NODE_READ_TIMEOUT
          value: "15"
        - name: NIFI_ZK_CONNECT_STRING
          value: "zookeeper:2181"
        - name: NIFI_CLUSTER_NODE_ADDRESS
          value: "nifi-0.nifi.NAMESPACE_NAME.cluster.local"
          # valueFrom:
          #   fieldRef:
          #     fieldPath: status.podIP
        # - name: HOSTNAME
        #   valueFrom:
        #     fieldRef:
        #       fieldPath: status.podIP
        livenessProbe:
          exec:
            command:
              - pgrep
              - java
          initialDelaySeconds: 60
          periodSeconds: 30
          timeoutSeconds: 10
          failureThreshold: 3
          successThreshold: 1
        readinessProbe:
          exec:
            command:
              - pgrep
              - java
          initialDelaySeconds: 180
          periodSeconds: 30
          timeoutSeconds: 10
          failureThreshold: 3
          successThreshold: 1
        resources:
          requests:
            cpu: 400m
            memory: 1Gi
          limits:
            cpu: 500m
            memory: 2Gi
      volumes:
        - name: pv-01
          persistentVolumeClaim:
            claimName: pv-claim

Zookeeper yaml file:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper
  namespace: namespace_name
  labels:
    name : zookeeper
    app : zookeeper
  # annotations:
  #   app.kubernetes.io/name: zookeeper
  #   app.kubernetes.io/part-of: nifi
spec:
  revisionHistoryLimit: 1
  serviceName: zookeeper
  selector:
    matchLabels:
      app: zookeeper
  template:
    metadata:
      labels:
        app: zookeeper
    spec:
      automountServiceAccountToken: false
      enableServiceLinks: false
      restartPolicy: Always
      securityContext:
        runAsGroup: 1000
        runAsUser: 1000
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: zookeeper
        image: XXX
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 2181
          name: zk
        - containerPort: 2182
          name: zc
        # - containerPort: 8083
        #   name: web
        - containerPort: 5111
          name: cmd
        env:
          - name: ALLOW_ANONYMOUS_LOGIN
            value: "yes"
          - name: ZOO_ADMINSERVER_ENABLED
            value: "true"
          - name: ZOO_AUTOPURGE_PURGEINTERVAL
            value: "2"
          - name: ZOO_AUTOPURGE_SNAPRETAINCOUNT
            value: "10"
          - name: ZOO_INIT_LIMIT
            value: "10"
          - name: ZOO_STANDALONE_ENABLED
            value: "true"
          - name: ZOO_SYNC_LIMIT
            value: "6"
          - name: ZOO_TICK_TIME
            value: "4000"
        livenessProbe:
             exec:
                command:
                  - which
                  - java
             initialDelaySeconds: 30
             periodSeconds: 30
             timeoutSeconds: 10
             failureThreshold: 3
             successThreshold: 1
        readinessProbe:
             tcpSocket:
              port: 2181
             initialDelaySeconds: 120
             periodSeconds: 30
             timeoutSeconds: 10
             failureThreshold: 3
             successThreshold: 1
        resources:
          requests:
            cpu: 200m
            memory: 1Gi
          limits:
            cpu: 300m
            memory: 2Gi
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          runAsGroup: 1000
          runAsUser: 1000
      - name: pv-01
        persistentVolumeClaim:
          claimName: pv-claim


来源: stackexchange

问:
How to open an Android app when clicking on verify email link using dynamic links?
For my users, I send a verification email in Firebase. The link that I receive in my email is:

```<code>https://my-project-id.firebaseapp.com/__/auth/action?mode=verifyEmail...
</code>```

When a user clicks on the above link, I want to open my Android app and navigate to a specific screen. Is this possible with dynamic links? If yes, can you help me with the necessary steps?

Any help would be greatly appreciated.

ContentLicense: CC BY-SA 4.0

Body:
For my users, I send a verification email in Firebase. The link that I receive in my email is:

https://my-project-id.firebaseapp.com/__/auth/action?mode=verifyEmail...

When a user clicks on the above link, I want to open my Android app and navigate to a specific screen. Is this possible with dynamic links? If yes, can you help me with the necessary steps?

Any help would be greatly appreciated.


问:
Chrome window opening locally rather than triggering inside the remote server while during selenium testing in python
We have a python script which does application validation(chrome) by navigating through different screens using selenium and tesseract. We are trying trigger this python script using a batch file/ PowerShell command from a remote server. When I try to trigger the batch file, the chrome windows opens in the local server rather opening in the remote server (place where the python script is present). This is the sample python script, there are many validations after this but I have included the code till the application url trigger.

```<code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from PIL import Image
import os
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(
    chrome_options=chrome_options,
    executable_path=r".\chromedriver_win32\chromedriver.exe",
)
driver.get("application url")
</code>```

We want the chrome to open in the remote server. Thanks for the help!

We want the chrome to open in the remote server.

Body:
We have a python script which does application validation(chrome) by navigating through different screens using selenium and tesseract. We are trying trigger this python script using a batch file/ PowerShell command from a remote server. When I try to trigger the batch file, the chrome windows opens in the local server rather opening in the remote server (place where the python script is present). This is the sample python script, there are many validations after this but I have included the code till the application url trigger.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from PIL import Image
import os
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(
    chrome_options=chrome_options,
    executable_path=r".\chromedriver_win32\chromedriver.exe",
)
driver.get("application url")

We want the chrome to open in the remote server. Thanks for the help!

We want the chrome to open in the remote server.


问:
3D barplot with scaled gradient colormap corresponding to a 4th dimension (range of values)
I am trying to create a 3D barplot using matplotlib in python, and apply a colormap which is tied some data (4th dimension) which is not explicitly plotted. I think what makes this even more complicated is that I want this 4th dimension to be a range of values as opposed to a single value.

So far I have managed to create the 3D bar plot with a colormap tied to the z-dimension thanks primarily to this post how to plot gradient fill on the 3d bars in matplotlib. The code can be found below.

```<code>import numpy as np
import glob,os
from matplotlib import pyplot as plt
import matplotlib.colors as cl
import matplotlib.cm as cm
from mpl_toolkits.mplot3d import Axes3D

os.chdir('./')

# axis details for the bar plot
x = ['1', '2', '3', '4', '5'] # labels
x_tick_locks = np.arange(0.1, len(x) + 0.1, 1)
x_axis = np.arange(len(x))

y = ['A', 'B']
y_tick_locks = np.arange(-0.1, len(y) - 0.1, 1)
y_axis = np.arange(len(y))

x_axis, y_axis = np.meshgrid(x_axis, y_axis)
x_axis = x_axis.flatten()
y_axis = y_axis.flatten()
x_data_final = np.ones(len(x) * len(y)) * 0.5
y_data_final = np.ones(len(x) * len(y)) * 0.5

z_axis = np.zeros(len(x)*len(y))
z_data_final = [[30, 10, 15, 20, 25], [10, 15, 15, 28, 40]]

values_min = [[5, 1, 6, 8, 3], [2, 1, 3, 9, 4]]
values_max = [[20, 45, 11, 60, 30], [11, 28, 6, 30, 40]]

cmap_max = max(values_max)
cmap_min = min(values_min)

############################### FOR 3D SCALED GRADIENT BARS ###############################

def make_bar(ax, x0=0, y0=0, width = 0.5, height=1 , cmap="plasma",
              norm=cl.Normalize(vmin=0, vmax=1), **kwargs ):
    # Make data
    u = np.linspace(0, 2*np.pi, 4+1)+np.pi/4.
    v_ = np.linspace(np.pi/4., 3./4*np.pi, 100)
    v = np.linspace(0, np.pi, len(v_)+2 )
    v[0] = 0 ;  v[-1] = np.pi; v[1:-1] = v_
    #print(u)
    x = np.outer(np.cos(u), np.sin(v))
    y = np.outer(np.sin(u), np.sin(v))
    z = np.outer(np.ones(np.size(u)), np.cos(v))

    xthr = np.sin(np.pi/4.)**2 ;  zthr = np.sin(np.pi/4.)
    x[x > xthr] = xthr; x[x < -xthr] = -xthr
    y[y > xthr] = xthr; y[y < -xthr] = -xthr
    z[z > zthr] = zthr  ; z[z < -zthr] = -zthr

    x *= 1./xthr*width; y *= 1./xthr*width
    z += zthr
    z *= height/(2.*zthr)
    #translate
    x += x0; y += y0
    #plot
    ax.plot_surface(x, y, z, cmap=cmap, norm=norm, **kwargs)

def make_bars(ax, x, y, height, width=1):
    widths = np.array(width)*np.ones_like(x)
    x = np.array(x).flatten()
    y = np.array(y).flatten()

    h = np.array(height).flatten()
    w = np.array(widths).flatten()
    norm = cl.Normalize(vmin=0, vmax=h.max())
    for i in range(len(x.flatten())):
        make_bar(ax, x0=x[i], y0=y[i], width = w[i] , height=h[i], norm=norm)

############################### FOR 3D SCALED GRADIENT BARS ###############################

# Creating graph surface
fig = plt.figure(figsize=(9,6))
ax = fig.add_subplot(111, projection= Axes3D.name)
ax.azim = 50
ax.dist = 10
ax.elev = 30
ax.invert_xaxis()
ax.set_box_aspect((1, 0.5, 1))
ax.zaxis.labelpad=7
ax.text(0.9, 2.2, 0, 'Group', 'x')
ax.text(-2, 0.7, 0, 'Class', 'y')
ax.set_xticks(x_tick_locks)
ax.set_xticklabels(x, ha='left')
ax.tick_params(axis='x', which='major', pad=-2)

ax.set_yticks(y_tick_locks)
ax.set_yticklabels(y, ha='right', rotation=30)
ax.tick_params(axis='y', which='major', pad=-5)
ax.set_zlabel('Number')

make_bars(ax, x_axis, y_axis, z_data_final, width=0.2, )
fig.colorbar(plt.cm.ScalarMappable(cmap = 'plasma'), ax = ax, shrink=0.8)

#plt.tight_layout() # doesn't seem to work properly for 3d plots?
plt.show()
</code>```

As I mentioned, I don't want the colormap to be tied to the z-axis but rather a 4th dimension, which is a range. In other words, I want the colours of the colormap to range from cmap_min to cmap_max (so min is 1 and max is 60), then for the bar plot with a z_data_final entry of 30 for example, its colours should correspond with the range of 5 to 20.

Some other posts seem to provide a solution for a single 4th dimensional value, i.e. (python) plot 3d surface with colormap as 4th dimension, function of x,y,z or How to make a 4d plot using Python with matplotlib however I wasn't able to find anything specific to bar plots with a range of values as your 4th dimensional data.

I would appreciate any guidance in this matter, thanks in advance.

This is the 3D bar plot with colormap tied to the z-dimension

Body:
I am trying to create a 3D barplot using matplotlib in python, and apply a colormap which is tied some data (4th dimension) which is not explicitly plotted. I think what makes this even more complicated is that I want this 4th dimension to be a range of values as opposed to a single value.

So far I have managed to create the 3D bar plot with a colormap tied to the z-dimension thanks primarily to this post how to plot gradient fill on the 3d bars in matplotlib. The code can be found below.

import numpy as np
import glob,os
from matplotlib import pyplot as plt
import matplotlib.colors as cl
import matplotlib.cm as cm
from mpl_toolkits.mplot3d import Axes3D

os.chdir('./')

# axis details for the bar plot
x = ['1', '2', '3', '4', '5'] # labels
x_tick_locks = np.arange(0.1, len(x) + 0.1, 1)
x_axis = np.arange(len(x))

y = ['A', 'B']
y_tick_locks = np.arange(-0.1, len(y) - 0.1, 1)
y_axis = np.arange(len(y))

x_axis, y_axis = np.meshgrid(x_axis, y_axis)
x_axis = x_axis.flatten()
y_axis = y_axis.flatten()
x_data_final = np.ones(len(x) * len(y)) * 0.5
y_data_final = np.ones(len(x) * len(y)) * 0.5

z_axis = np.zeros(len(x)*len(y))
z_data_final = [[30, 10, 15, 20, 25], [10, 15, 15, 28, 40]]

values_min = [[5, 1, 6, 8, 3], [2, 1, 3, 9, 4]]
values_max = [[20, 45, 11, 60, 30], [11, 28, 6, 30, 40]]

cmap_max = max(values_max)
cmap_min = min(values_min)

############################### FOR 3D SCALED GRADIENT BARS ###############################

def make_bar(ax, x0=0, y0=0, width = 0.5, height=1 , cmap="plasma",
              norm=cl.Normalize(vmin=0, vmax=1), **kwargs ):
    # Make data
    u = np.linspace(0, 2*np.pi, 4+1)+np.pi/4.
    v_ = np.linspace(np.pi/4., 3./4*np.pi, 100)
    v = np.linspace(0, np.pi, len(v_)+2 )
    v[0] = 0 ;  v[-1] = np.pi; v[1:-1] = v_
    #print(u)
    x = np.outer(np.cos(u), np.sin(v))
    y = np.outer(np.sin(u), np.sin(v))
    z = np.outer(np.ones(np.size(u)), np.cos(v))

    xthr = np.sin(np.pi/4.)**2 ;  zthr = np.sin(np.pi/4.)
    x[x > xthr] = xthr; x[x < -xthr] = -xthr
    y[y > xthr] = xthr; y[y < -xthr] = -xthr
    z[z > zthr] = zthr  ; z[z < -zthr] = -zthr

    x *= 1./xthr*width; y *= 1./xthr*width
    z += zthr
    z *= height/(2.*zthr)
    #translate
    x += x0; y += y0
    #plot
    ax.plot_surface(x, y, z, cmap=cmap, norm=norm, **kwargs)

def make_bars(ax, x, y, height, width=1):
    widths = np.array(width)*np.ones_like(x)
    x = np.array(x).flatten()
    y = np.array(y).flatten()

    h = np.array(height).flatten()
    w = np.array(widths).flatten()
    norm = cl.Normalize(vmin=0, vmax=h.max())
    for i in range(len(x.flatten())):
        make_bar(ax, x0=x[i], y0=y[i], width = w[i] , height=h[i], norm=norm)

############################### FOR 3D SCALED GRADIENT BARS ###############################

# Creating graph surface
fig = plt.figure(figsize=(9,6))
ax = fig.add_subplot(111, projection= Axes3D.name)
ax.azim = 50
ax.dist = 10
ax.elev = 30
ax.invert_xaxis()
ax.set_box_aspect((1, 0.5, 1))
ax.zaxis.labelpad=7
ax.text(0.9, 2.2, 0, 'Group', 'x')
ax.text(-2, 0.7, 0, 'Class', 'y')
ax.set_xticks(x_tick_locks)
ax.set_xticklabels(x, ha='left')
ax.tick_params(axis='x', which='major', pad=-2)

ax.set_yticks(y_tick_locks)
ax.set_yticklabels(y, ha='right', rotation=30)
ax.tick_params(axis='y', which='major', pad=-5)
ax.set_zlabel('Number')

make_bars(ax, x_axis, y_axis, z_data_final, width=0.2, )
fig.colorbar(plt.cm.ScalarMappable(cmap = 'plasma'), ax = ax, shrink=0.8)

#plt.tight_layout() # doesn't seem to work properly for 3d plots?
plt.show()

As I mentioned, I don't want the colormap to be tied to the z-axis but rather a 4th dimension, which is a range. In other words, I want the colours of the colormap to range from cmap_min to cmap_max (so min is 1 and max is 60), then for the bar plot with a z_data_final entry of 30 for example, its colours should correspond with the range of 5 to 20.

Some other posts seem to provide a solution for a single 4th dimensional value, i.e. (python) plot 3d surface with colormap as 4th dimension, function of x,y,z or How to make a 4d plot using Python with matplotlib however I wasn't able to find anything specific to bar plots with a range of values as your 4th dimensional data.

I would appreciate any guidance in this matter, thanks in advance.

This is the 3D bar plot with colormap tied to the z-dimension


问:
TkinterVideo audio issue
Please tell me why there's no audio when I'm trying to play video using TkinterVideo?</p>
```<code>def open_file(self):
    filepath = filedialog.askopenfilename(filetypes=[('Video Files', ["*.mp4"])])
    if filepath != "":
        videoplayer = TkinterVideo(self, scaled=True)
        videoplayer.pack(expand=True, fill="both")
        videoplayer.load(filepath)
        videoplayer.pack(expand=True, fill="both")
        videoplayer.play()
        self.get_button()
</code>```

Title: TkinterVideo audio issue

Body:
Please tell me why there's no audio when I'm trying to play video using TkinterVideo?

def open_file(self):
    filepath = filedialog.askopenfilename(filetypes=[('Video Files', ["*.mp4"])])
    if filepath != "":
        videoplayer = TkinterVideo(self, scaled=True)
        videoplayer.pack(expand=True, fill="both")
        videoplayer.load(filepath)
        videoplayer.pack(expand=True, fill="both")
        videoplayer.play()
        self.get_button()


问:
Logstash output to ES gives me error code '400'
i am creating an ELK stack to fetch tweet and analyse them. When, i start my elk stack i got this error message from Logstash

```<code>Failed to install template {:message=>"Got response code '400' contacting Elasticsearch at URL 'http://elasticsearch:9200/_index_template/twitter'", :exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb:84:in `perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:324:in `perform_request_to_url'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:311:in `block in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:398:in `with_connection'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:310:in `perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:318:in `block in Pool'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client.rb:412:in `template_put'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client.rb:85:in `template_install'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/template_manager.rb:29:in `install'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/template_manager.rb:17:in `install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:578:in `install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:344:in `finish_register'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:300:in `block in register'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/plugin_mixins/elasticsearch/common.rb:154:in `block in after_successful_connection'"]}
</code>```

I think i got an error inside my index template but even on internet i didn't found what is wrong with it.

I am using:
logstash:8.5.3
elastictsearch:8.5.3
kibana:8.5.3

this is my template:

{
  "template": "twitter-*",
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0,
    "index.mapping.total_fields.limit": 2000
  },
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": true
      },
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z YYYY"
        },
        "text": {
          "type": "text"
        },
        "user": {
          "type": "object",
          "properties": {
            "description": {
              "type": "text"
            }
          }
        },
        "coordinates": {
          "type": "object",
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        },
        "entities": {
          "type": "object",
          "properties": {
            "hashtags": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "text",
                  "fielddata": true
                }
              }
            }
          }
        },
        "retweeted_status": {
          "type": "object",
          "properties": {
            "text": {
              "type": "text"
            }
          }
        }
      },
      "dynamic_templates": [
        {
          "string_template": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "keyword"
            }
          }
        }
      ]
    }
  }
}
```
<p>and this is my logstash config, i send my tweet via tcp because i have a python bot who fetch them for me.</p>
```input {
        tcp {
                port => 50000
        }
}

filter {

}

output {
        elasticsearch {
                hosts => "elasticsearch:9200"
                user => "elastic"
                password => "${LOGSTASH_INTERNAL_PASSWORD}"
                index => "twitter-%{+yyyy.MM.dd}"
                document_type => "tweets"
                template      => "./templates/twitter.json"
                template_name => "twitter"
                template_overwrite => true
        }
}
```

Thanks for any help <3

What did you try ?
I tried to modify some attributes of my template, but i still got this message.

What were you expecting?
I was expecting that logstash create my index_template, for incoming tweets.

Body:
i am creating an ELK stack to fetch tweet and analyse them. When, i start my elk stack i got this error message from Logstash

Failed to install template {:message=>"Got response code '400' contacting Elasticsearch at URL 'http://elasticsearch:9200/_index_template/twitter'", :exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb:84:in `perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:324:in `perform_request_to_url'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:311:in `block in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:398:in `with_connection'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:310:in `perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:318:in `block in Pool'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client.rb:412:in `template_put'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/http_client.rb:85:in `template_install'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/template_manager.rb:29:in `install'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch/template_manager.rb:17:in `install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:578:in `install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:344:in `finish_register'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/outputs/elasticsearch.rb:300:in `block in register'", "/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-output-elasticsearch-11.9.3-java/lib/logstash/plugin_mixins/elasticsearch/common.rb:154:in `block in after_successful_connection'"]}

I think i got an error inside my index template but even on internet i didn't found what is wrong with it.

I am using:
logstash:8.5.3
elastictsearch:8.5.3
kibana:8.5.3

this is my template:

{
  "template": "twitter-*",
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0,
    "index.mapping.total_fields.limit": 2000
  },
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": true
      },
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z YYYY"
        },
        "text": {
          "type": "text"
        },
        "user": {
          "type": "object",
          "properties": {
            "description": {
              "type": "text"
            }
          }
        },
        "coordinates": {
          "type": "object",
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        },
        "entities": {
          "type": "object",
          "properties": {
            "hashtags": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "text",
                  "fielddata": true
                }
              }
            }
          }
        },
        "retweeted_status": {
          "type": "object",
          "properties": {
            "text": {
              "type": "text"
            }
          }
        }
      },
      "dynamic_templates": [
        {
          "string_template": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "keyword"
            }
          }
        }
      ]
    }
  }
}

and this is my logstash config, i send my tweet via tcp because i have a python bot who fetch them for me.

input {
        tcp {
                port => 50000
        }
}

filter {

}

output {
        elasticsearch {
                hosts => "elasticsearch:9200"
                user => "elastic"
                password => "${LOGSTASH_INTERNAL_PASSWORD}"
                index => "twitter-%{+yyyy.MM.dd}"
                document_type => "tweets"
                template      => "./templates/twitter.json"
                template_name => "twitter"
                template_overwrite => true
        }
}

Thanks for any help <3

What did you try ?
I tried to modify some attributes of my template, but i still got this message.

What were you expecting?
I was expecting that logstash create my index_template, for incoming tweets.


问:
Bitbucket cloud API - V 2.0, I need to find the the records which are newly created above the datetime given
I'm integrating the bitbucket APIs and I'm calling many APIs from the backend I want data that are created newly and greater than given DateTime so is there any parameter in the APIs to find data according (between two dates)?

List of APIs

https://api.bitbucket.org/2.0/repositories/{workspace}

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commits

Looking forward to your reply.

Thanking you in advance.

I want data according between two DateTime.


问:
Mpesa STK push API update for Android Studio
There has been an update to the STK push library for Mpesa service integration onto Android Studio applications. The old version went something like    implementation 'com.androidstudy:daraja:1.0.2'  The news version is    implementation 'com.androidstudy.daraja:daraja:2.0.1'

It seems like it makes it easier to use because now, you don't need to create the LNMExpress and manage the callbacks from its request. It is all taken care of by the library. All you have to do is provide the following details: token(no idea what this is), phoneNumber, amount, accountRef, description and lastly a callback of type DarajaResult (no idea how to get this).

So, I'm still trying to understand how the update works. Anyone who knows how to use it please post your code or a link to the documentation of the new version here.


问:
Pagination does not change the items on different pages
I added pagination in my application. The same results are displayed on each page and according to the URL, the pages are definitely changing. I've tried a ton of solutions but none worked. Please help me find what I did wrong

My Controller:

```<code>public function index(Request $request)
    {

        $competitions = Competition::latest()->paginate(1);

        return view('competition.index', compact('competitions'));
    }
</code>```

Inside app/Providers/AppServiceProvider I added use Illuminate\Pagination\Paginator; and my function looks like this:

```<code> public function boot()
    {
        Paginator::useBootstrap();
    }
</code>```

That's how I loop in view:

```<code>@foreach ($competitions as $competition)
    <tbody >
       @switch($competition->status)
            @case('active')
                <tr>
            @break

            @case('to_push')
                <tr class="bg-secondary">
            @break

            @case('inactive')
                <tr class="bg-warning">
            @break

            @default
                <tr>
            @endswitch
            <td>{{ $competition->id }}</td>
            <td>{{ $competition->name }}</td>
            <td>{{ $competition->status }}</td>
            <td>{{ $competition->mode }}</td>
            <td>{{ $competition->type }}</td>
            <td>{{ $competition->frequency }}</td>
            <td>{{ $competition->last_push }}</td>
            <td>{{ $competition->next_push }}</td>
            <td class="text-center"><a class="btn btn-info btn-sm" href="{{ route('events.list_by_competition',['competition' => $competition->id]) }}">Events</a></td>
            <td class="text-center"><a class="btn btn-info btn-sm" href="{{ route('competitions.exports',$competition->id) }}">Exports</a></td>
            <td class="text-center">
                <form action="{{ route('competitions.destroy',$competition->id) }}" method="POST">

                    <a class="btn btn-primary btn-sm" href="{{ route('competitions.edit',$competition->id) }}">Edit</a>

                    @csrf
                    @method('DELETE')

                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>
            </td>

        </tr>
 </tbody>
        @endforeach
    </table>
    {{  $competitions->links() }}
</code>```

Body:
I added pagination in my application. The same results are displayed on each page and according to the URL, the pages are definitely changing. I've tried a ton of solutions but none worked. Please help me find what I did wrong

My Controller:

public function index(Request $request)
    {

        $competitions = Competition::latest()->paginate(1);

        return view('competition.index', compact('competitions'));
    }

Inside app/Providers/AppServiceProvider I added use Illuminate\Pagination\Paginator; and my function looks like this:

 public function boot()
    {
        Paginator::useBootstrap();
    }

That's how I loop in view:

@foreach ($competitions as $competition)

       @switch($competition->status)
            @case('active')

            @break

            @case('to_push')

            @break

            @case('inactive')

            @break

            @default

            @endswitch
            {{ $competition->id }}
            {{ $competition->name }}
            {{ $competition->status }}
            {{ $competition->mode }}
            {{ $competition->type }}
            {{ $competition->frequency }}
            {{ $competition->last_push }}
            {{ $competition->next_push }}
             $competition->id]) }}">Events
            id) }}">Exports

                <form action="{{ route('competitions.destroy',$competition->id) }}" method="POST">

                    id) }}">Edit

                    @csrf
                    @method('DELETE')

                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>

        @endforeach

    {{  $competitions->links() }}


问:
How to switch to another project in docker?
I had local drupal website setup with docksal and then accidentally I ran "fin init" command which restarted the project stack.

Now when I am launching my drupal website, it is totally new with no existing modules installed. Is there any way i can get back my existing website with all my earlier modules and contents.

Below is the output of fin dioagnose:

```<code>COMPOSE_PROJECT_NAME_SAFE: drupal_website
COMPOSE_FILE:
/home/minsharm/.docksal/stacks/volumes-bind.yml
/home/minsharm/.docksal/stacks/stack-default.yml
/home/minsharm/Downloads/drupal_website/.docksal/docksal.yml
ENV_FILE:
/home/minsharm/Downloads/drupal_website/.docksal/docksal.env
/home/minsharm/Downloads/drupal_website/.docksal/docksal-local.env

PROJECT_ROOT: /home/minsharm/Downloads/drupal_website
DOCROOT: web
VIRTUAL_HOST: drupal-website.docksal
VIRTUAL_HOST_ALIASES: *.drupal-website.docksal
IP: 192.168.64.100

MySQL endpoint: 192.168.64.100:32769
Public URL:

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      BLACKFIRE_CLIENT_ID: null
      BLACKFIRE_CLIENT_TOKEN: null
      BROWSERTEST_OUTPUT_BASE_URL: http://drupal-website.docksal/
      BROWSERTEST_OUTPUT_DIRECTORY: /var/www/web/sites/simpletest/browser_output
      CLI_IMAGE: '"docksal/cli:php8.1-3.2"'
      COMPOSER_ALLOW_XDEBUG: "0"
      COMPOSER_DEFAULT_VERSION: null
      COMPOSER_DISABLE_XDEBUG_WARN: "0"
      DOCKSAL_STACK: default
      DOCROOT: web
      DRUSH_ALLOW_XDEBUG: "0"
      DRUSH_OPTIONS_URI: drupal-website.docksal
      GIT_USER_EMAIL: minsharm@redhat.com
      GIT_USER_NAME: minsharm
      HOST_GID: "4210635"
      HOST_UID: "4210635"
      MINK_DRIVER_ARGS_WEBDRIVER: '''["chrome", {"chromeOptions":{"w3c":false } },"http://browser:4444/wd/hub"]'''
      MYSQL_DATABASE: default
      MYSQL_HOST: db
      MYSQL_PASSWORD: user
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
      PHP_IDE_CONFIG: null
      SECRET_ACQUIA_CLI_KEY: null
      SECRET_ACQUIA_CLI_SECRET: null
      SECRET_PLATFORMSH_CLI_TOKEN: null
      SECRET_SSH_PRIVATE_KEY: null
      SECRET_TERMINUS_TOKEN: null
      SIMPLETEST_BASE_URL: http://web
      SIMPLETEST_DB: mysql://user:user@db/default
      SSH_AUTH_SOCK: /.ssh-agent/proxy-socket
      VIRTUAL_HOST: drupal-website.docksal
      XDEBUG_CONFIG: client_host=192.168.64.1 remote_host=192.168.64.1
      XDEBUG_ENABLED: "0"
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: cli
    hostname: cli
    healthcheck:
      interval: 10s
    image: docksal/cli:php8.1-3.2
    labels:
      io.docksal.shell: bash
      io.docksal.user: docker
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    volumes:
    - type: volume
      source: docksal_ssh_agent
      target: /.ssh-agent
      read_only: true
      volume: {}
    - type: volume
      source: cli_home
      target: /home/docker
      volume: {}
    - type: bind
      source: /tmp/.docksal/drupal_website
      target: /tmp/.docksal/drupal_website
      read_only: true
      bind:
        create_host_path: true
    - type: volume
      source: project_root
      target: /var/www
      volume:
        nocopy: true
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: null
      MYSQL_DATABASE: default
      MYSQL_INITDB_SKIP_TZINFO: null
      MYSQL_ONETIME_PASSWORD: null
      MYSQL_PASSWORD: user
      MYSQL_RANDOM_ROOT_PASSWORD: null
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: mariadb
    hostname: db
    healthcheck:
      interval: 10s
    image: docksal/mariadb:10.6-1.3
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    ports:
    - mode: ingress
      target: 3306
      protocol: tcp
    volumes:
    - type: volume
      source: db_data
      target: /var/lib/mysql
      volume: {}
    - type: volume
      source: project_root
      target: /var/www
      read_only: true
      volume:
        nocopy: true
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/web
      APACHE_FCGI_HOST_PORT: cli:9000
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: apache
    hostname: web
    healthcheck:
      interval: 10s
    image: docksal/apache:2.4-2.5
    labels:
      io.docksal.cert-name: none
      io.docksal.permanent: "false"
      io.docksal.project-root: /home/minsharm/Downloads/drupal_website
      io.docksal.virtual-host: drupal-website.docksal,*.drupal-website.docksal,drupal-website.docksal.*
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    volumes:
    - type: volume
      source: project_root
      target: /var/www
      read_only: true
      volume:
        nocopy: true
networks:
  default:
    name: drupal_website_default
volumes:
  cli_home:
    name: drupal_website_cli_home
  db_data:
    name: drupal_website_db_data
  docksal_ssh_agent:
    name: docksal_ssh_agent
    external: true
  project_root:
    name: drupal_website_project_root
    driver: local
    driver_opts:
      device: /home/minsharm/Downloads/drupal_website
      o: bind
      type: none
---------------------

███  DOCKSAL
Docksal version: v1.17.0
fin version:     1.110.1

███  OS
Linux Red Hat Enterprise Linux 8.7
Linux minsharm.remote.csb 4.18.0-425.3.1.el8.x86_64 #1 SMP Fri Sep 30 11:45:06 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux

███  ENVIRONMENT
MODE : Linux Kernel
DOCKER_HOST :

███  DOCKER
Expected client version: 20.10.12
Expected server version: 20.10.12

Installed versions:

Client: Docker Engine - Community
 Cloud integration: v1.0.29
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.18.9
 Git commit:        3a2c30b
 Built:             Thu Dec 15 22:28:05 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.9
  Git commit:       42c8b31
  Built:            Thu Dec 15 22:26:16 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.14
  GitCommit:        9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

███  DOCKER COMPOSE
Expected version:  2.1.0
Installed version: v2.1.0

███  DOCKSAL: PROJECTS
project           STATUS                    virtual host                                                                  project root
drupal_website    Up 6 hours (healthy)      drupal-website.docksal,*.drupal-website.docksal,drupal-website.docksal.*      /home/minsharm/Downloads/drupal_website
drupal_website1   Exited (0) 20 hours ago   drupal-website1.docksal,*.drupal-website1.docksal,drupal-website1.docksal.*   /home/minsharm/Documents/drupal_website1
downloads         Exited (0) 2 months ago   downloads.docksal,*.downloads.docksal,downloads.docksal.*                     /home/minsharm/Downloads

███  DOCKSAL: VIRTUAL HOSTS
*.drupal-website.docksal
drupal-website.docksal.*
drupal-website.docksal

███  DOCKSAL: NETWORKING

DOCKSAL_IP: 192.168.64.100
DOCKSAL_HOST_IP: 192.168.64.1
DOCKSAL_VHOST_PROXY_IP:
DOCKSAL_DNS_IP:
DOCKSAL_DNS_DISABLED: 0
DOCKSAL_NO_DNS_RESOLVER: 0
DOCKSAL_DNS_UPSTREAM:
DOCKSAL_DNS_DOMAIN: docksal

███  DOCKSAL: CONNECTIVITY

Host to 192.168.64.100:     PASS
Container to 192.168.64.100:    PASS
Container to 192.168.64.1:  PASS

Checking connectivity to http://dns-test.docksal...
Host: PASS
Containers: FAIL

███  DOCKER: RUNNING CONTAINERS
CONTAINER ID   IMAGE                      COMMAND                  CREATED       STATUS                  PORTS                                                    NAMES
0537085a4a49   docksal/apache:2.4-2.5     "httpd-foreground"       6 hours ago   Up 6 hours (healthy)    80/tcp, 443/tcp                                          drupal_website_web_1
c9bc05669e6d   docksal/cli:php8.1-3.2     "/opt/startup.sh sup…"   6 hours ago   Up 6 hours (healthy)    22/tcp, 3000/tcp, 9000/tcp                               drupal_website_cli_1
b41aa71709ca   docksal/mariadb:10.6-1.3   "docker-entrypoint.s…"   6 hours ago   Up 6 hours (healthy)    0.0.0.0:32769->3306/tcp                                  drupal_website_db_1
9de58b3013cd   docksal/ssh-agent:1.4      "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)                                                            docksal-ssh-agent
c7ce9926f107   docksal/dns:1.2            "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)   192.168.64.100:53->53/udp                                docksal-dns
89eb7926a675   docksal/vhost-proxy:1.8    "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)   192.168.64.100:80->80/tcp, 192.168.64.100:443->443/tcp   docksal-vhost-proxy

███  DOCKER: NETWORKS
NETWORK ID     NAME                      DRIVER    SCOPE
91f4a14850e3   _default                  bridge    local
74fce51de42d   bridge                    bridge    local
14aee58d5925   ddev-drush_default        bridge    local
65b5cbce275d   ddev_default              bridge    local
c6a990a6e748   downloads_default         bridge    local
ebcacefdd5a2   drupal_website1_default   bridge    local
4f79bf6091bd   drupal_website_default    bridge    local
5868b632ab1c   host                      host      local
5a3b3863626b   none                      null      local

███  HDD Usage
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                   16G     0   16G   0% /dev
tmpfs                      16G  294M   16G   2% /dev/shm
tmpfs                      16G  2.5M   16G   1% /run
tmpfs                      16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/RHELCSB-Root   49G   24G   26G  49% /
/dev/mapper/RHELCSB-Home  100G   16G   85G  16% /home
/dev/nvme0n1p2            3.0G  461M  2.6G  16% /boot
/dev/nvme0n1p1            200M   19M  182M  10% /boot/efi
tmpfs                     3.1G   68K  3.1G   1% /run/user/4210635

</code>```

Body:
I had local drupal website setup with docksal and then accidentally I ran "fin init" command which restarted the project stack.

Now when I am launching my drupal website, it is totally new with no existing modules installed. Is there any way i can get back my existing website with all my earlier modules and contents.

Below is the output of fin dioagnose:

COMPOSE_PROJECT_NAME_SAFE: drupal_website
COMPOSE_FILE:
/home/minsharm/.docksal/stacks/volumes-bind.yml
/home/minsharm/.docksal/stacks/stack-default.yml
/home/minsharm/Downloads/drupal_website/.docksal/docksal.yml
ENV_FILE:
/home/minsharm/Downloads/drupal_website/.docksal/docksal.env
/home/minsharm/Downloads/drupal_website/.docksal/docksal-local.env

PROJECT_ROOT: /home/minsharm/Downloads/drupal_website
DOCROOT: web
VIRTUAL_HOST: drupal-website.docksal
VIRTUAL_HOST_ALIASES: *.drupal-website.docksal
IP: 192.168.64.100

MySQL endpoint: 192.168.64.100:32769
Public URL:

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      BLACKFIRE_CLIENT_ID: null
      BLACKFIRE_CLIENT_TOKEN: null
      BROWSERTEST_OUTPUT_BASE_URL: http://drupal-website.docksal/
      BROWSERTEST_OUTPUT_DIRECTORY: /var/www/web/sites/simpletest/browser_output
      CLI_IMAGE: '"docksal/cli:php8.1-3.2"'
      COMPOSER_ALLOW_XDEBUG: "0"
      COMPOSER_DEFAULT_VERSION: null
      COMPOSER_DISABLE_XDEBUG_WARN: "0"
      DOCKSAL_STACK: default
      DOCROOT: web
      DRUSH_ALLOW_XDEBUG: "0"
      DRUSH_OPTIONS_URI: drupal-website.docksal
      GIT_USER_EMAIL: minsharm@redhat.com
      GIT_USER_NAME: minsharm
      HOST_GID: "4210635"
      HOST_UID: "4210635"
      MINK_DRIVER_ARGS_WEBDRIVER: '''["chrome", {"chromeOptions":{"w3c":false } },"http://browser:4444/wd/hub"]'''
      MYSQL_DATABASE: default
      MYSQL_HOST: db
      MYSQL_PASSWORD: user
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
      PHP_IDE_CONFIG: null
      SECRET_ACQUIA_CLI_KEY: null
      SECRET_ACQUIA_CLI_SECRET: null
      SECRET_PLATFORMSH_CLI_TOKEN: null
      SECRET_SSH_PRIVATE_KEY: null
      SECRET_TERMINUS_TOKEN: null
      SIMPLETEST_BASE_URL: http://web
      SIMPLETEST_DB: mysql://user:user@db/default
      SSH_AUTH_SOCK: /.ssh-agent/proxy-socket
      VIRTUAL_HOST: drupal-website.docksal
      XDEBUG_CONFIG: client_host=192.168.64.1 remote_host=192.168.64.1
      XDEBUG_ENABLED: "0"
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: cli
    hostname: cli
    healthcheck:
      interval: 10s
    image: docksal/cli:php8.1-3.2
    labels:
      io.docksal.shell: bash
      io.docksal.user: docker
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    volumes:
    - type: volume
      source: docksal_ssh_agent
      target: /.ssh-agent
      read_only: true
      volume: {}
    - type: volume
      source: cli_home
      target: /home/docker
      volume: {}
    - type: bind
      source: /tmp/.docksal/drupal_website
      target: /tmp/.docksal/drupal_website
      read_only: true
      bind:
        create_host_path: true
    - type: volume
      source: project_root
      target: /var/www
      volume:
        nocopy: true
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: null
      MYSQL_DATABASE: default
      MYSQL_INITDB_SKIP_TZINFO: null
      MYSQL_ONETIME_PASSWORD: null
      MYSQL_PASSWORD: user
      MYSQL_RANDOM_ROOT_PASSWORD: null
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: mariadb
    hostname: db
    healthcheck:
      interval: 10s
    image: docksal/mariadb:10.6-1.3
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    ports:
    - mode: ingress
      target: 3306
      protocol: tcp
    volumes:
    - type: volume
      source: db_data
      target: /var/lib/mysql
      volume: {}
    - type: volume
      source: project_root
      target: /var/www
      read_only: true
      volume:
        nocopy: true
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/web
      APACHE_FCGI_HOST_PORT: cli:9000
    extends:
      file: /home/minsharm/.docksal/stacks/services.yml
      service: apache
    hostname: web
    healthcheck:
      interval: 10s
    image: docksal/apache:2.4-2.5
    labels:
      io.docksal.cert-name: none
      io.docksal.permanent: "false"
      io.docksal.project-root: /home/minsharm/Downloads/drupal_website
      io.docksal.virtual-host: drupal-website.docksal,*.drupal-website.docksal,drupal-website.docksal.*
    logging:
      options:
        max-file: "10"
        max-size: 1m
    networks:
      default: null
    volumes:
    - type: volume
      source: project_root
      target: /var/www
      read_only: true
      volume:
        nocopy: true
networks:
  default:
    name: drupal_website_default
volumes:
  cli_home:
    name: drupal_website_cli_home
  db_data:
    name: drupal_website_db_data
  docksal_ssh_agent:
    name: docksal_ssh_agent
    external: true
  project_root:
    name: drupal_website_project_root
    driver: local
    driver_opts:
      device: /home/minsharm/Downloads/drupal_website
      o: bind
      type: none
---------------------

███  DOCKSAL
Docksal version: v1.17.0
fin version:     1.110.1

███  OS
Linux Red Hat Enterprise Linux 8.7
Linux minsharm.remote.csb 4.18.0-425.3.1.el8.x86_64 #1 SMP Fri Sep 30 11:45:06 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux

███  ENVIRONMENT
MODE : Linux Kernel
DOCKER_HOST :

███  DOCKER
Expected client version: 20.10.12
Expected server version: 20.10.12

Installed versions:

Client: Docker Engine - Community
 Cloud integration: v1.0.29
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.18.9
 Git commit:        3a2c30b
 Built:             Thu Dec 15 22:28:05 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.9
  Git commit:       42c8b31
  Built:            Thu Dec 15 22:26:16 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.14
  GitCommit:        9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

███  DOCKER COMPOSE
Expected version:  2.1.0
Installed version: v2.1.0

███  DOCKSAL: PROJECTS
project           STATUS                    virtual host                                                                  project root
drupal_website    Up 6 hours (healthy)      drupal-website.docksal,*.drupal-website.docksal,drupal-website.docksal.*      /home/minsharm/Downloads/drupal_website
drupal_website1   Exited (0) 20 hours ago   drupal-website1.docksal,*.drupal-website1.docksal,drupal-website1.docksal.*   /home/minsharm/Documents/drupal_website1
downloads         Exited (0) 2 months ago   downloads.docksal,*.downloads.docksal,downloads.docksal.*                     /home/minsharm/Downloads

███  DOCKSAL: VIRTUAL HOSTS
*.drupal-website.docksal
drupal-website.docksal.*
drupal-website.docksal

███  DOCKSAL: NETWORKING

DOCKSAL_IP: 192.168.64.100
DOCKSAL_HOST_IP: 192.168.64.1
DOCKSAL_VHOST_PROXY_IP:
DOCKSAL_DNS_IP:
DOCKSAL_DNS_DISABLED: 0
DOCKSAL_NO_DNS_RESOLVER: 0
DOCKSAL_DNS_UPSTREAM:
DOCKSAL_DNS_DOMAIN: docksal

███  DOCKSAL: CONNECTIVITY

Host to 192.168.64.100:     PASS
Container to 192.168.64.100:    PASS
Container to 192.168.64.1:  PASS

Checking connectivity to http://dns-test.docksal...
Host: PASS
Containers: FAIL

███  DOCKER: RUNNING CONTAINERS
CONTAINER ID   IMAGE                      COMMAND                  CREATED       STATUS                  PORTS                                                    NAMES
0537085a4a49   docksal/apache:2.4-2.5     "httpd-foreground"       6 hours ago   Up 6 hours (healthy)    80/tcp, 443/tcp                                          drupal_website_web_1
c9bc05669e6d   docksal/cli:php8.1-3.2     "/opt/startup.sh sup…"   6 hours ago   Up 6 hours (healthy)    22/tcp, 3000/tcp, 9000/tcp                               drupal_website_cli_1
b41aa71709ca   docksal/mariadb:10.6-1.3   "docker-entrypoint.s…"   6 hours ago   Up 6 hours (healthy)    0.0.0.0:32769->3306/tcp                                  drupal_website_db_1
9de58b3013cd   docksal/ssh-agent:1.4      "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)                                                            docksal-ssh-agent
c7ce9926f107   docksal/dns:1.2            "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)   192.168.64.100:53->53/udp                                docksal-dns
89eb7926a675   docksal/vhost-proxy:1.8    "docker-entrypoint.s…"   2 weeks ago   Up 20 hours (healthy)   192.168.64.100:80->80/tcp, 192.168.64.100:443->443/tcp   docksal-vhost-proxy

███  DOCKER: NETWORKS
NETWORK ID     NAME                      DRIVER    SCOPE
91f4a14850e3   _default                  bridge    local
74fce51de42d   bridge                    bridge    local
14aee58d5925   ddev-drush_default        bridge    local
65b5cbce275d   ddev_default              bridge    local
c6a990a6e748   downloads_default         bridge    local
ebcacefdd5a2   drupal_website1_default   bridge    local
4f79bf6091bd   drupal_website_default    bridge    local
5868b632ab1c   host                      host      local
5a3b3863626b   none                      null      local

███  HDD Usage
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                   16G     0   16G   0% /dev
tmpfs                      16G  294M   16G   2% /dev/shm
tmpfs                      16G  2.5M   16G   1% /run
tmpfs                      16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/RHELCSB-Root   49G   24G   26G  49% /
/dev/mapper/RHELCSB-Home  100G   16G   85G  16% /home
/dev/nvme0n1p2            3.0G  461M  2.6G  16% /boot
/dev/nvme0n1p1            200M   19M  182M  10% /boot/efi
tmpfs                     3.1G   68K  3.1G   1% /run/user/4210635


问:
react useState fetch
In this component i have a cart. Cart contains cartItems(each line from the cart), i have the functionalities as follows: i can add a product to my cart from product page, i can delete cartItem(doesn't matter the quantity) and the next features that i work on are - + buttons which increases/decreases the quantity of the cartItem, my problem is that opening the cart first time when i press for an example the plus button to increment the value i got this error "{timestamp: '2022-12-21T13:13:49.212+00:00', status: 500, error: 'Internal Server Error', path: '/cart/update-cart-item-quantity'}" and on the frontend it increments the value, but the second time i press the button works just fine but the previous increment will not count just the second,third and so on Example( quantity:1, i press on plus quantity:2 error, press on plus again quantity:2 and its works both on backend and frontend)

***my backend is in java spring boot and everything works fine, tested with postman

if u have any suggestions let me know

import React,{ useEffect, useState } from "react";
import classes from "./Modal.module.css";

export default function Modal({ setModal }) {
    const [cart,setCart] = useState([]);
    const [cartItems,setCartItems] = useState();
    const [itemQty, setItemQty] = useState({id:'', quantity:'' })
    const [qty,setQty] = useState();
    // console.log(cart)
    // console.log("Cart iteeeeeem",cartItems);

    function addItemQty(e){
        console.log(e.target.innerText)
        let newList = [];
        let obj = {id: '', quantity: ''}
        let total = 0;
        for (let index = 0; index < cartItems.length; index++) {
            const element = cartItems[index];
            const p = element.product.id
            setItemQty({id:p,quantity:element.quantity})

            console.log(p, e.currentTarget.id)

        if(p == e.currentTarget.id){
            const sellingPer = element.product.sellingPrice;
            if(e.target.innerText=="+"){
                element.quantity += 1;
            }else{
                element.quantity -= 1;
            }

            element.totalPrice = element.quantity * sellingPer;
        }

        newList.push(element);
        total += element.totalPrice;
        cart.totalPrices = total;
        obj.id = p;
        obj.quantity = element.quantity;
        setItemQty({id:p,quantity:element.quantity})

    }

        setCart(cart);
        setCartItems(newList);
        fetchUpdateCartItemQuantity();

    }

    function closeModal() {
        setModal(false);
    }

    const fetchUpdateCartItemQuantity = async ()=>{
        fetch("http://localhost:8080/cart/update-cart-item-quantity",{ method: 'POST',
        body: JSON.stringify({
          id: itemQty.id,quantity: itemQty.quantity+1
        }),
        headers: {
          'Content-type': 'application/json; charset=UTF-8',
        },
      })
         .then((response) => response.json())
         .then((data) => {
            console.log(data);
            // Handle data
         })
         .catch((err) => {
            console.log(err.message);})
        // const response = await req.json();
        // // console.log("Responseeee"+response);
        // setCart(response);
        // setCartItems(response.cartItems)

    }

    useEffect(() =>{

    }, [cartItems])

    useEffect(()=>{
        const fetchCart = async ()=>{
            const request = await fetch("http://localhost:8080/cart/get-cart")
            const response = await request.json();
            setCart(response);
            setCartItems(response.cartItems)
        }
        fetchCart();
    },[])

        const fetchDeleteItemFromCart = async (e)=>{
            const request = await fetch(`http://localhost:8080/cart/delete-cart-item/${e.target.id}`,{method:'DELETE'})
            const response = await request.json();
            setCart(response);
            setCartItems(response.cartItems);
        }
    return (
        <>

                <>

Shopping Cart

                            {cartItems && cartItems.map(item=>(

{item.product.productName}

{item.product.sellingPrice * item.quantity} $

Quantity:
                                         <button onClick={addItemQty}id={item.product.id} data-sign={"-"}>-</button>
                                         <input
                                         onChange={(e)=> setQty(item.quantity)}
                                         value={item.quantity}/>
                                         <button onClick={addItemQty} id={item.product.id} data-sign={"+"}>+</button>

                                            Remove

                                  ))}

Subtotal {cart.totalPrices}

Tax {cart.totalPrices}

Shipping {cart.totalPrices}

Total {cart.totalPrices}

                            Checkout

                </>

      </>
    );
}

```

Title: react useState fetch


问:
Webkit scrolling too much?
I have some content which can have only specific height (no more), and I added some scroll on that content.

This is my CSS:

```<code>.value {
  max-height: 60px;
  overflow-y: auto;
  color: black;
  font-size: 16px;
}

/* width */
.value::-webkit-scrollbar {
  width: 3px;
}
/* Track */
.value::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px rgb(163, 163, 163);
  border-radius: 5px;
}
/* Handle */
.value::-webkit-scrollbar-thumb {
  background: linear-gradient(60deg, #b95aca, #8c15ad);
  border-radius: 5px;
}
</code>```

And This is my Subtitle content:

```<code><div
   class="value"
  *ngIf="courseData.sub_title"
> {{courseData.sub_title}}
</div>
</code>```

This is the image:

So, when I want to scroll down or up using mouse wheel it's scrolling too much and user can not be able read full text (part of text was going up or down with scrolling).

How can I change scroll step?

Title: Webkit scrolling too much?

Body:
I have some content which can have only specific height (no more), and I added some scroll on that content.

This is my CSS:

.value {
  max-height: 60px;
  overflow-y: auto;
  color: black;
  font-size: 16px;
}

/* width */
.value::-webkit-scrollbar {
  width: 3px;
}
/* Track */
.value::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px rgb(163, 163, 163);
  border-radius: 5px;
}
/* Handle */
.value::-webkit-scrollbar-thumb {
  background: linear-gradient(60deg, #b95aca, #8c15ad);
  border-radius: 5px;
}

And This is my Subtitle content:

 {{courseData.sub_title}}

This is the image:

So, when I want to scroll down or up using mouse wheel it's scrolling too much and user can not be able read full text (part of text was going up or down with scrolling).

How can I change scroll step?


问:
Django admin upload multiple images in 1 form
I dont want to use inlines so I figured I want to upload a bunch of images at the same time.
Now I've been struggling for an entire day to get it working but it doesn't for some reason.

My first code:

Model

```<code>class LaptopInfoImages(models.Model):
  laptop_info = models.ForeignKey(LaptopInfo, on_delete=models.CASCADE)
  image = models.ImageField(upload_to=images_directory)
</code>```

admin

```<code>class LaptopInfoImagesForm(forms.ModelForm):
    image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True}))

    class Meta:
        model = LaptopInfoImages
        fields = '__all__'

    def save(self, commit=True):
        instance = super().save(commit=False)
        for image in self.cleaned_data['image']:
            image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=image)
            image_obj.save()
        if commit:
            instance.save()
        return instance
</code>```

This gives me the error:

```<code>AttributeError: 'bytes' object has no attribute '_committed'
</code>```

So I changed the code to:

admin

```<code>class LaptopInfoImagesForm(forms.ModelForm):
image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True}))

class Meta:
    model = LaptopInfoImages
    fields = '__all__'

def save(self, commit=True):
    instance = super().save(commit=False)
    for image in self.cleaned_data['image']:
        # Convert the image to a BytesIO object
        bytes_io = BytesIO(image)

        # Create an InMemoryUploadedFile from the BytesIO object
        in_memory_file = InMemoryUploadedFile(
            bytes_io, None, 'image.jpg', 'image/jpeg', len(image), None
        )

        # Save the image to the LaptopInfoImages model
        image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=in_memory_file)
        image_obj.save()
    if commit:
        instance.save()
    return instance
</code>```

It doesnt give me any errors but it is uploading 9332 laptop info imagess and the images don't work.

Body:
I dont want to use inlines so I figured I want to upload a bunch of images at the same time.
Now I've been struggling for an entire day to get it working but it doesn't for some reason.

My first code:

Model

class LaptopInfoImages(models.Model):
  laptop_info = models.ForeignKey(LaptopInfo, on_delete=models.CASCADE)
  image = models.ImageField(upload_to=images_directory)

admin

class LaptopInfoImagesForm(forms.ModelForm):
    image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True}))

    class Meta:
        model = LaptopInfoImages
        fields = '__all__'

    def save(self, commit=True):
        instance = super().save(commit=False)
        for image in self.cleaned_data['image']:
            image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=image)
            image_obj.save()
        if commit:
            instance.save()
        return instance

This gives me the error:

AttributeError: 'bytes' object has no attribute '_committed'

So I changed the code to:

admin

class LaptopInfoImagesForm(forms.ModelForm):
image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True}))

class Meta:
    model = LaptopInfoImages
    fields = '__all__'

def save(self, commit=True):
    instance = super().save(commit=False)
    for image in self.cleaned_data['image']:
        # Convert the image to a BytesIO object
        bytes_io = BytesIO(image)

        # Create an InMemoryUploadedFile from the BytesIO object
        in_memory_file = InMemoryUploadedFile(
            bytes_io, None, 'image.jpg', 'image/jpeg', len(image), None
        )

        # Save the image to the LaptopInfoImages model
        image_obj = LaptopInfoImages(laptop_info=instance.laptop_info, image=in_memory_file)
        image_obj.save()
    if commit:
        instance.save()
    return instance

It doesnt give me any errors but it is uploading 9332 laptop info imagess and the images don't work.


问:
Nuxt Proxy Issue when deploying using Docker (Github Action)
I am trying to deploy my nuxt app using github actions. I tried to run my app built in docker container at my local environment, but it doesn't work. When I open application using browser,I could check nothing but the background image I set using css.
I believe it might be issue related to proxy or serverMiddleware that I set in nuxt.config.js.

Servermiddleware is for managing session, and proxy server is used to avoid CORS issues when getting data from external api server.

nuxt.config.js

proxy: {
  '/api/v1/': {
     target: 'http://192.168.219.101:8082',
     pathRewrite: {'^/api/v1/cryptolive/': '/'},
     changeOrigin: true,
  },
}

serverMiddleware: [
    // bodyParser.json(),
    session({
        secret: 'super-secret-key',
        resave: false,
        saveUninitialized: false,
        cookie: {
            maxAge: 60000,
        },
    }),
    '~/apis',
],
```


问:
How to change how float numbers are displayed in the input in c programs?
Let us suppose a very simple program in C that asks some number for the user and do something, like in the following piece of code.

```<code>#include <stdio.h>
int main()
{
    float var;
    printf("Provide a number:");
    scanf("%f",&var);
    (do something)
    return 0;
}
</code>```

When the user informs, let's say, 12.45, in the scanf, the value 12.45 is displayed. But when the user informs the value 7, I would like that when the user pressed ENTER, this value would be completed with decimal zeros, like 7.00.

Is there any way to do that using the standard libraries of C?

Body:
Let us suppose a very simple program in C that asks some number for the user and do something, like in the following piece of code.

#include <stdio.h>
int main()
{
    float var;
    printf("Provide a number:");
    scanf("%f",&var);
    (do something)
    return 0;
}

When the user informs, let's say, 12.45, in the scanf, the value 12.45 is displayed. But when the user informs the value 7, I would like that when the user pressed ENTER, this value would be completed with decimal zeros, like 7.00.

Is there any way to do that using the standard libraries of C?


问:
use existing key exchange for curl
Is there a way to have curl rely on an existing ssl exchange when doing a REST API call via the command line?
If I understood it correctly, each curl command will start the ssl exchange from scratch for any API call using HTTPS.
So if I have multiple curl commands to the same API, I'd be redoing the key exchange needlessly. Is there some way to have it reuse an existing connection from a previous curl command or other command ?
The "keep alive" option is clearly not intended for this.

Alternately, is there some command line curl alternative that can do this?

Note that I am only looking for command line options.

Title: use existing key exchange for curl


问:
Multiple entrypoints on same port with different address
I'm currently trying to set up an internal entrypoint in traefik and am hitting a major brick wall. The basic architecture I'm trying to achieve is:

Services via HTTPS, exposed via PUBLICIP:443

Services via HTTPS, exposed via PRIVATEIP:443

I attempted to set up another traefik ingress controller in K3s, but that cause all sorts of problems with node port allocation. Essentially creating additional loadbalancers all contending for the same port. Makes sense that it wouldn't work, I guess.

Where I am a little stuck is understanding how I would best achieve this using traefik, with the helmchart in use in K3S.

I'm wondering if maybe multiple entrypoints bound to specific IP addresses could be an option? https://doc.traefik.io/traefik/routing/entrypoints/ I would like it to be a bit more dynamic than that.

I feel like there is some fundamental concept I'm missing in either how I'm configuring K3S itself, or how services work in kuberentes/traefik.

Any help is appreciated!


问:
ITSAppUsesNonExemptEncryption doesn't work in React Native App via Fastlane

Problem

Since a few weeks ago, I get asked for every uploaded build in iOS again for the Encryption information. I have specified in my info.plist via ITSAppUsesNonExemptEncryption that the app does not use encryption. Here is my Fastfile:

```<code>  desc 'Push a new beta build to TestFlight'
  lane :release do
    increment

    sync_code_signing(
      type: 'appstore',
      app_identifier: 'com.some.workplace'
    )
    build_app(scheme: 'app')
    upload_to_testflight(
      apple_id: apple_id,
      itc_provider: team_id
    )
  end
</code>```

Did Crapple change something? Do I have to specify something else in the Fastfile?

Body:
Problem

Since a few weeks ago, I get asked for every uploaded build in iOS again for the Encryption information. I have specified in my info.plist via ITSAppUsesNonExemptEncryption that the app does not use encryption. Here is my Fastfile:

  desc 'Push a new beta build to TestFlight'
  lane :release do
    increment

    sync_code_signing(
      type: 'appstore',
      app_identifier: 'com.some.workplace'
    )
    build_app(scheme: 'app')
    upload_to_testflight(
      apple_id: apple_id,
      itc_provider: team_id
    )
  end

Did Crapple change something? Do I have to specify something else in the Fastfile?


问:
SMTP problems using IIS and PHPMailer
I have php code  for SMTP. It shows all information when I submit in the website, but the description shows me undefined

Here is the code of php mailing:

```<code>   <div class='view_group' style='padding: 20px 10px;box-sizing: border-box;'>
   <h4 style='font-family: Arial, Helvetica, sans-serif;margin: 0; margin-bottom: 7px; font-size:14px;'>
     PROJECT BRIEF DESCRIPTION
   </h4>
   <p style='font-family: monospace;margin: 0;'>$description</p>
</code>```

Title: SMTP problems using IIS and PHPMailer

Body:
I have php code  for SMTP. It shows all information when I submit in the website, but the description shows me undefined

Here is the code of php mailing:

     PROJECT BRIEF DESCRIPTION

$description


问:
Error: Must be called at startup before the electron app is ready. (in electron Problem with electron in puppeteer)
i have problem with puppeteer in electron
**summery: my puppeteer Function dont work in IPCMain with below Error:
**

```<code>Error: Must be called at startup before the electron app is ready.
    at Object.initialize (E:\Programming\DesktopApp\node_modules\puppeteer-in-electron\index.ts:46:11)
    at Mori (E:\Programming\DesktopApp\src\main\main.ts:28:15)
    at IpcMainImpl.<anonymous> (E:\Programming\DesktopApp\src\main\main.ts:59:3)
    at IpcMainImpl.emit (node:events:527:28)
    at IpcMainImpl.emit (node:domain:475:12)
    at EventEmitter.<anonymous> (node:electron/js2c/browser_init:161:11120)
    at EventEmitter.emit (node:events:527:28)
    at EventEmitter.emit (node:domain:475:12)
</code>```

Steps i did:
1- use of IPCRenderer and IPCMain (This Work and tested by console.log)
2- made a function for doing my puppeteer Work that i put it below
3- when i call the Last Step Function (2) in IPCMain occur some Error

note: if run the function out of the IPCMain work properly

Main.js Codes For puppeteer:

```<code>import path from "path";
import { app, BrowserWindow, shell, Tray, Menu } from "electron";
import { autoUpdater } from "electron-updater";
import log from "electron-log";
import MenuBuilder from "./menu";
import { resolveHtmlPath } from "./util";

const { ipcMain } = require("electron");

import pie from "puppeteer-in-electron";
import puppeteer from "puppeteer-core";

async function Mori(arg: any) {
   console.log(arg); //Work...
  console.log("Moriii Ready Working..."); //Work
  try {
    await pie.initialize(app);
    const browser = await puppeteer.launch({
      executablePath: path.join(
        __dirname,
        "../../Node_Software/chrome-win/chrome.exe"
      ),
      headless: false,
    });
    const page = await browser.newPage();
    await page.goto("https://mortezamehrabi.com", { timeout: 0 });
  } catch (error) {
    console.log(error);
  }
}

ipcMain.on("IPCVirgoolCommentRun", async (event, arg) => {
  event.reply("IPCVirgoolCommentRun", arg);
  console.log("arg IPC ...."); //Work

  Mori("hii")  // This Function puppeteer not Working

});
</code>```

if i Put Mori("hii") Function out of IPCMain Work properly! but in IPCMain we have Error

changing Function Location for wrking...

Body:
i have problem with puppeteer in electron
**summery: my puppeteer Function dont work in IPCMain with below Error:
**

Error: Must be called at startup before the electron app is ready.
    at Object.initialize (E:\Programming\DesktopApp\node_modules\puppeteer-in-electron\index.ts:46:11)
    at Mori (E:\Programming\DesktopApp\src\main\main.ts:28:15)
    at IpcMainImpl.<anonymous> (E:\Programming\DesktopApp\src\main\main.ts:59:3)
    at IpcMainImpl.emit (node:events:527:28)
    at IpcMainImpl.emit (node:domain:475:12)
    at EventEmitter.<anonymous> (node:electron/js2c/browser_init:161:11120)
    at EventEmitter.emit (node:events:527:28)
    at EventEmitter.emit (node:domain:475:12)

Steps i did:
1- use of IPCRenderer and IPCMain (This Work and tested by console.log)
2- made a function for doing my puppeteer Work that i put it below
3- when i call the Last Step Function (2) in IPCMain occur some Error

note: if run the function out of the IPCMain work properly

Main.js Codes For puppeteer:

import path from "path";
import { app, BrowserWindow, shell, Tray, Menu } from "electron";
import { autoUpdater } from "electron-updater";
import log from "electron-log";
import MenuBuilder from "./menu";
import { resolveHtmlPath } from "./util";

const { ipcMain } = require("electron");

import pie from "puppeteer-in-electron";
import puppeteer from "puppeteer-core";

async function Mori(arg: any) {
   console.log(arg); //Work...
  console.log("Moriii Ready Working..."); //Work
  try {
    await pie.initialize(app);
    const browser = await puppeteer.launch({
      executablePath: path.join(
        __dirname,
        "../../Node_Software/chrome-win/chrome.exe"
      ),
      headless: false,
    });
    const page = await browser.newPage();
    await page.goto("https://mortezamehrabi.com", { timeout: 0 });
  } catch (error) {
    console.log(error);
  }
}

ipcMain.on("IPCVirgoolCommentRun", async (event, arg) => {
  event.reply("IPCVirgoolCommentRun", arg);
  console.log("arg IPC ...."); //Work

  Mori("hii")  // This Function puppeteer not Working

});

if i Put Mori("hii") Function out of IPCMain Work properly! but in IPCMain we have Error

changing Function Location for wrking...


问:
golang closure in closure
a closure problem
example looks like this:

uids := []int{1, 2, 3}
wg := sync.WaitGroup{}
for _, uid := range uids {
   wg.Add(1)
   go func() {
      func(id int) {
         defer wg.Done()
         fmt.Println(id)
      }(uid)
   }()
}
wg.Wait()
```
<p>why this result is</p>
```3 3 3
```
<p>what's the difference between</p>
<pre class="lang-golang prettyprint-override"><code>uids := []int{1, 2, 3}
wg := sync.WaitGroup{}
for _, uid := range uids {
   wg.Add(1)
   go func(id int) {
         defer wg.Done()
         fmt.Println(id)
   }(uid)
}
wg.Wait()
</code>```

which result is

```<code>3 1 2
</code>```

Title: golang closure in closure

Body:
a closure problem
example looks like this:

uids := []int{1, 2, 3}
wg := sync.WaitGroup{}
for _, uid := range uids {
   wg.Add(1)
   go func() {
      func(id int) {
         defer wg.Done()
         fmt.Println(id)
      }(uid)
   }()
}
wg.Wait()

why this result is

3 3 3

what's the difference between

uids := []int{1, 2, 3}
wg := sync.WaitGroup{}
for _, uid := range uids {
   wg.Add(1)
   go func(id int) {
         defer wg.Done()
         fmt.Println(id)
   }(uid)
}
wg.Wait()

which result is

3 1 2


问:
Multiple Pending Orders Strategy
I am looking for a simple script on tradingvdiew that I can run to simply place multiple pending entry limit orders, stop orders, etc on my chart when i need them. I can adjust them as needed, but i place 3 to 4 orders at time and it takes to long to manual enter in each order. I would rather add them to my chart and then quickly move them around.

Something like this I think:

Thanks

I tried to use multiple scripts but nothing seems to work.

Title: Multiple Pending Orders Strategy


问:
A-star algorithm freezing seemlingly random after some time in Snake
I'm making an AI for the game Snake, here's my Code:

```<code>import math

class Node():
    def __init__(self, parent=None, position=None):
        self.parent = parent
        self.position = position

        self.g = 0
        self.h = 0
        self.f = 0

    def __eq__(self, other):
        return self.position == other.position

def astar(maze, start, end):
    # Initialize the open list
    open_list = []
    start_node = Node(None, start)
    start_node.g = start_node.h = start_node.f = 0
    open_list.append(start_node)

    # Initialize the closed list
    closed_list = []
    end_node = Node(None, end)

    # While the open list is not empty
    while len(open_list) > 0:
        current_node = open_list[0]
        current_index = 0
        # Find the node with the least f on the open list
        for index, item in enumerate(open_list):
            if item.f < current_node.f:
                current_node = item
                current_index = index

        # Pop current node off the open list
        open_list.pop(current_index)
        # Push current node on the closed list
        closed_list.append(current_node)

        # If current node is goal, then stop search
        if current_node == end_node:
            path = []
            current = current_node
            while current is not None:
                path.append(current.position)
                current = current.parent

            return path[::-1]

        # Find the 4 neighboring squares
        children = []
        for new_position in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            node_position = (current_node.position[0] + new_position[0], current_node.position[1] + new_position[1])

            # Make sure it's within the maze
            if node_position[0] > (len(maze) - 1) or node_position[0] < 0 or node_position[1] > (len(maze[len(maze)-1]) -1) or node_position[1] < 0:
                continue

            # Make sure it's not a wall
            if maze[node_position[0]][node_position[1]] != 0:
                continue

            new_node = Node(current_node, node_position)
            children.append(new_node)

        # For each child
        flag = 0
        for child in children:
            if child in closed_list:
                continue

            child.g = current_node.g + 1
            child.h = hueristic_estimate(child, end_node)
            child.f = child.g + child.h

            for open_node in open_list:
                if child.position == open_node.position and child.f > open_node.f:
                    flag = 1
                    break
            if flag == 1:
                continue

            open_list.append(child)

    return None

def hueristic_estimate(start_node, end_node):
    return ((start_node.position[0] - end_node.position[0]) ** 2 + (start_node.position[1] - end_node.position[1]) ** 2) * 4

</code>```

I have no idea why, but after a bit, around when the snake get's about 15 in length, it will freeze. I don't know whether it's running very, very, very slow or if it's in an infinite loop. I'm pretty sure this should be all correct, yet the problem persists.

Body:
I'm making an AI for the game Snake, here's my Code:

import math

class Node():
    def __init__(self, parent=None, position=None):
        self.parent = parent
        self.position = position

        self.g = 0
        self.h = 0
        self.f = 0

    def __eq__(self, other):
        return self.position == other.position

def astar(maze, start, end):
    # Initialize the open list
    open_list = []
    start_node = Node(None, start)
    start_node.g = start_node.h = start_node.f = 0
    open_list.append(start_node)

    # Initialize the closed list
    closed_list = []
    end_node = Node(None, end)

    # While the open list is not empty
    while len(open_list) > 0:
        current_node = open_list[0]
        current_index = 0
        # Find the node with the least f on the open list
        for index, item in enumerate(open_list):
            if item.f < current_node.f:
                current_node = item
                current_index = index

        # Pop current node off the open list
        open_list.pop(current_index)
        # Push current node on the closed list
        closed_list.append(current_node)

        # If current node is goal, then stop search
        if current_node == end_node:
            path = []
            current = current_node
            while current is not None:
                path.append(current.position)
                current = current.parent

            return path[::-1]

        # Find the 4 neighboring squares
        children = []
        for new_position in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            node_position = (current_node.position[0] + new_position[0], current_node.position[1] + new_position[1])

            # Make sure it's within the maze
            if node_position[0] > (len(maze) - 1) or node_position[0] < 0 or node_position[1] > (len(maze[len(maze)-1]) -1) or node_position[1] < 0:
                continue

            # Make sure it's not a wall
            if maze[node_position[0]][node_position[1]] != 0:
                continue

            new_node = Node(current_node, node_position)
            children.append(new_node)

        # For each child
        flag = 0
        for child in children:
            if child in closed_list:
                continue

            child.g = current_node.g + 1
            child.h = hueristic_estimate(child, end_node)
            child.f = child.g + child.h

            for open_node in open_list:
                if child.position == open_node.position and child.f > open_node.f:
                    flag = 1
                    break
            if flag == 1:
                continue

            open_list.append(child)

    return None

def hueristic_estimate(start_node, end_node):
    return ((start_node.position[0] - end_node.position[0]) ** 2 + (start_node.position[1] - end_node.position[1]) ** 2) * 4

I have no idea why, but after a bit, around when the snake get's about 15 in length, it will freeze. I don't know whether it's running very, very, very slow or if it's in an infinite loop. I'm pretty sure this should be all correct, yet the problem persists.