问:
How do I fix my Inventory putting items in wrong slots?
I'm working on my Inventory system for my Roblox survival game and I can't figure out a way to fix an issue I've been having that you can see in this GIF I've made: https://imgur.com/BwLYrmG

I believe I've found what's been causing this bug but I can't find a solution to it. I believe the cause is that when the script runs the function updateDisplay() every second, it checks through all the hotbar and inventory slots and if one of them is empty, it puts the item there. However, if there is only one item in the player's Backpack, the script says the same tool is in slot1 and also puts it in slot2. I'm wondering how I can implement the check for this.

code is here

```<code>local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local player = Players.LocalPlayer
local backpack = player.Backpack
local char = player.Character

local GUI = script.Parent.Parent.Inventory
local hotbar = GUI.Hotbar
local inventory = GUI.Inventory
local items = inventory.Items

local slot1 = inventory.Items.InventorySlot1
local slot2 = inventory.Items.InventorySlot2
local slot3 = hotbar.Frame.HotbarSlot1
local slot4 = hotbar.Frame.HotbarSlot2

local invSlotData = {
    [slot1] = nil,
    [slot2] = nil,
    [slot3] = nil,
    [slot4] = nil

}

local function scanItems()

    local items = {}

    --checks backpack and character for items and adds them to the Items table
    for i, tool in pairs(backpack:GetChildren()) do
        if tool.ClassName == "Tool" then
            table.insert(items, tool)
        end
    end

    for i, tool in pairs(char:GetChildren()) do
        if tool.ClassName == "Tool" then
            table.insert(items, tool)
        end
    end

    local invItems = {}

    --[[looks through Items table, and if a tool has the same name as an index in invItems table, add to the index's count and insert
    the tool's name into the index's Items table. else, create a new index with the tool's name and set all it's tables to default  --]]
    for i, tool in pairs(items) do
        if invItems[tool.Name] then
            invItems[tool.Name].Count += 1
            table.insert(invItems[tool.Name].Items, tool)
        else
            invItems[tool.Name] = {
                Count = 1,
                Items = {tool}
            }
        end
    end

    return invItems
end

local function resetItems()
    for i, button in pairs(items:GetChildren()) do
        if button.ClassName == "ImageButton" then
            button.Image = ""
            button.CountDisplay.Text = ""
            button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        end
    end

    for i, button in pairs(hotbar.Frame:GetChildren()) do
        if button.ClassName == "ImageButton" then
            button.Image = ""
            button.CountDisplay.Text = ""
            button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        end
    end
end

local function updateDisplay()
    resetItems()

    local invItems = scanItems()

    for toolName, toolData in pairs(invItems) do
        if invSlotData[slot1] == nil then

            invSlotData[slot1] = toolData

            slot1.CountDisplay.Text = toolData.Count
            slot1.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot2] == nil then

            invSlotData[slot2] = toolData

            slot2.CountDisplay.Text = toolData.Count
            slot2.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot3] == nil then

            invSlotData[slot3] = toolData

            slot3.CountDisplay.Text = toolData.Count
            slot3.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot4] == nil then

            invSlotData[slot4] = toolData

            slot4.CountDisplay.Text = toolData.Count
            slot4.Image = toolData.Items[1].TextureId
        end
    end

    print(invSlotData)
end

task.spawn(function()
    while true do
        task.wait(1)
        updateDisplay()
    end
end)
</code>```

I've attempted to solve this by adding a for, in pairs loop inside the for toolName, toolData loop searching through invSlotData for if the name of the tool was the same as one in another slot.

Body:
I'm working on my Inventory system for my Roblox survival game and I can't figure out a way to fix an issue I've been having that you can see in this GIF I've made: https://imgur.com/BwLYrmG

I believe I've found what's been causing this bug but I can't find a solution to it. I believe the cause is that when the script runs the function updateDisplay() every second, it checks through all the hotbar and inventory slots and if one of them is empty, it puts the item there. However, if there is only one item in the player's Backpack, the script says the same tool is in slot1 and also puts it in slot2. I'm wondering how I can implement the check for this.

code is here

local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local player = Players.LocalPlayer
local backpack = player.Backpack
local char = player.Character

local GUI = script.Parent.Parent.Inventory
local hotbar = GUI.Hotbar
local inventory = GUI.Inventory
local items = inventory.Items

local slot1 = inventory.Items.InventorySlot1
local slot2 = inventory.Items.InventorySlot2
local slot3 = hotbar.Frame.HotbarSlot1
local slot4 = hotbar.Frame.HotbarSlot2

local invSlotData = {
    [slot1] = nil,
    [slot2] = nil,
    [slot3] = nil,
    [slot4] = nil

}

local function scanItems()

    local items = {}

    --checks backpack and character for items and adds them to the Items table
    for i, tool in pairs(backpack:GetChildren()) do
        if tool.ClassName == "Tool" then
            table.insert(items, tool)
        end
    end

    for i, tool in pairs(char:GetChildren()) do
        if tool.ClassName == "Tool" then
            table.insert(items, tool)
        end
    end

    local invItems = {}

    --[[looks through Items table, and if a tool has the same name as an index in invItems table, add to the index's count and insert
    the tool's name into the index's Items table. else, create a new index with the tool's name and set all it's tables to default  --]]
    for i, tool in pairs(items) do
        if invItems[tool.Name] then
            invItems[tool.Name].Count += 1
            table.insert(invItems[tool.Name].Items, tool)
        else
            invItems[tool.Name] = {
                Count = 1,
                Items = {tool}
            }
        end
    end

    return invItems
end

local function resetItems()
    for i, button in pairs(items:GetChildren()) do
        if button.ClassName == "ImageButton" then
            button.Image = ""
            button.CountDisplay.Text = ""
            button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        end
    end

    for i, button in pairs(hotbar.Frame:GetChildren()) do
        if button.ClassName == "ImageButton" then
            button.Image = ""
            button.CountDisplay.Text = ""
            button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        end
    end
end

local function updateDisplay()
    resetItems()

    local invItems = scanItems()

    for toolName, toolData in pairs(invItems) do
        if invSlotData[slot1] == nil then

            invSlotData[slot1] = toolData

            slot1.CountDisplay.Text = toolData.Count
            slot1.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot2] == nil then

            invSlotData[slot2] = toolData

            slot2.CountDisplay.Text = toolData.Count
            slot2.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot3] == nil then

            invSlotData[slot3] = toolData

            slot3.CountDisplay.Text = toolData.Count
            slot3.Image = toolData.Items[1].TextureId

        elseif invSlotData[slot4] == nil then

            invSlotData[slot4] = toolData

            slot4.CountDisplay.Text = toolData.Count
            slot4.Image = toolData.Items[1].TextureId
        end
    end

    print(invSlotData)
end

task.spawn(function()
    while true do
        task.wait(1)
        updateDisplay()
    end
end)

I've attempted to solve this by adding a for, in pairs loop inside the for toolName, toolData loop searching through invSlotData for if the name of the tool was the same as one in another slot.


来源: stackexchange

问:
Need to activate the RDS License through powershell
I'm automating RDS license activation through PowerShell task in Azure release pipeline for multiple vms in deployment groups. Currently activating manual by accessing the rds license manager and right click in the hostname and activate server and choosing connection method as "Web Browser" and providing License key and then it activating and post install wizard to enter client key (CAL: already provisioned from rds license team with requested quantity of users). Once it completed successfully, again right click on the hostname of rds licnese manager to review configuration and Clicking Add to group to join the AD terminal service group to complete the activity.

Currently I'm not able to find the right way to automate this process using powershell.
Note: I'm having license key and client key(CAL) for vm details which required to activate the license manual.

Tried some script to check in the vm but it does not work:

```<code>Import-Module RemoteDesktop

$server = Get-WmiObject -Class Win32_OperatingSystem
Activate-RDLicenseServer -ActivationMethod Web -ProductKey <license key>

Install-RDS CALs  -LicenseKey ""

Get-RDLicenseConfiguration
</code>```

this script does not work can I get the right way to activate the license. Getting error like RDS doesn't exist on the machine.

Note:
Installed all required RDS features and subfeatures of remotedesktop

ContentLicense: CC BY-SA 4.0

Body:
I'm automating RDS license activation through PowerShell task in Azure release pipeline for multiple vms in deployment groups. Currently activating manual by accessing the rds license manager and right click in the hostname and activate server and choosing connection method as "Web Browser" and providing License key and then it activating and post install wizard to enter client key (CAL: already provisioned from rds license team with requested quantity of users). Once it completed successfully, again right click on the hostname of rds licnese manager to review configuration and Clicking Add to group to join the AD terminal service group to complete the activity.

Currently I'm not able to find the right way to automate this process using powershell.
Note: I'm having license key and client key(CAL) for vm details which required to activate the license manual.

Tried some script to check in the vm but it does not work:

Import-Module RemoteDesktop

$server = Get-WmiObject -Class Win32_OperatingSystem
Activate-RDLicenseServer -ActivationMethod Web -ProductKey <license key>

Install-RDS CALs  -LicenseKey ""

Get-RDLicenseConfiguration

this script does not work can I get the right way to activate the license. Getting error like RDS doesn't exist on the machine.

Note:
Installed all required RDS features and subfeatures of remotedesktop


问:
Problems with control of primefaces components by Managed Bean
I hope somebody could help me with the trouble I am having with JSF 2 and Primefaces 3.0M3.

the problem is that the back bean methods do not fired from any component in the layoutunit 'center' they are inside a form and nothing happens, even I tried to update the components with remoteCommand, autoUpdate of the outputpanel, commandButton with action and actionListener and nothing, there is no error message. In the layoutunit west works the components well, renders the outputpanel (pfpInfo) of the center layoutunit but I do not know what is happening.

here is the code

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
    <title>Articulos</title>
</h:head>
<h:body>
    <link rel="stylesheet" type="text/css" href="../css/estilos.css" />
    <p:layout fullPage="true" id="lay">
        <p:layoutUnit position="north" size="100" resizable="false"
            closable="false" collapsible="false">
            <img src="../images/logo.jpg" alt="PLL"
                style="width: 413px; height: 83px;" align="left"></img>ss
            <img src="../images/tel.jpg" alt="PLR"
                style="width: 413px; height: 83px;" align="right"></img>
        </p:layoutUnit>

        <p:layoutUnit position="west" size="200" header="Categorías"
            resizable="false" closable="false" collapsible="false">
            <h:form id="frWest">
                <p:growl id="message" showDetail="true" globalOnly="true"
                    autoUpdate="true"></p:growl>
                <p:tree id="treeSingle" value="#{controlMBean.raizArbol}"
                    var="rama" dynamic="true" selectionMode="single"
                    selection="#{controlMBean.ramaElegida}" expanded="true">
                    <p:ajax event="select"
                        update=":frCenter:pfSeg :frCenter:pfpInfo :frCenter:pfpIma"
                        listener="#{controlMBean.procesaInformacionArt}"></p:ajax>
                    <p:treeNode>
                        <h:outputText value="#{rama}" styleClass="encabezadoUiLight" />
                    </p:treeNode>
                </p:tree>
            </h:form>
        </p:layoutUnit>

        <p:layoutUnit position="center">
            <h:form id="frCenter">
                <p:outputPanel id="pfSeg" rendered="true">
                    <p:outputPanel id="pfpIma" rendered="#{not controlMBean.cargado}">
                        <img src="../images/luchadores.jpg" />
                    </p:outputPanel>

                    <p:outputPanel id="pfpInfo" rendered="#{controlMBean.cargado}"
                        autoUpdate="true">

                        <p:dataTable dynamic="true" var="prnda" rowKey="#{prnda.id}"
                            value="#{controlMBean.infoArts}" paginator="true" rows="10"
                            selectionMode="single" paginatorAlwaysVisible="false"
                            selection="#{controlMBean.artElegido}"
                            rendered="#{controlMBean.cargado}">
                            <p:ajax event="rowUnselect"
                                listener="#{prestalana.deseleccionar}"></p:ajax>
                            <f:facet name="header">Articulo(s)</f:facet>
                            <p:ajax update=":frCenter:ppImg :frCenter:pgInfo"
                                oncomplete="prnd.show()" event="rowSelect"
                                listener="#{controlMBean.elegirFila}"></p:ajax>
                            <p:column sortBy="#{prnda.id}">
                                <f:facet name="header">
                                    <h:outputText value="Id" />
                                </f:facet>
                                <h:outputText value="#{prnda.id}" />
                            </p:column>

                            <p:column sortBy="#{prnda.articulo}">
                                <f:facet name="header">
                                    <h:outputText value="Modelo" />
                                </f:facet>
                                <h:outputText value="#{prnda.articulo}" />
                            </p:column>

                            <p:column sortBy="#{prnda.marca}">
                                <f:facet name="header">
                                    <h:outputText value="Marca" />
                                </f:facet>
                                <h:outputText value="#{prnda.marca}" />
                            </p:column>

                            <p:column sortBy="#{prnda.edo}">
                                <f:facet name="header">
                                    <h:outputText value="Ubicación" />
                                </f:facet>
                                <h:outputText value="#{prnda.edo}" />
                            </p:column>

                            <p:column sortBy="#{prnda.stsArticulo}">
                                <f:facet name="header">
                                    <h:outputText value="Estatus" />
                                </f:facet>
                                <h:outputText value="#{prnda.stsArticulo} " />
                            </p:column>

                            <p:column sortBy="#{prnda.precio}">
                                <f:facet name="header">
                                    <h:outputText value="Precio" />
                                </f:facet>
                                <h:outputText value="$ #{prnda.precio}" />
                            </p:column>

                        </p:dataTable>
                        <p:commandButton action="#{controlMBean.probar2}"
                            actionListener="#{controlMBean.probar}" value="Prueba"></p:commandButton>

                    </p:outputPanel>
                    <br />
                    <h:outputText value="#{controlMBean.mensaje}"
                        styleClass="textoUiLight" id="hotMen" />
                </p:outputPanel>
                <p:remoteCommand actionListener="#{controlMBean.probar}"
                    name="pruebaRc" update=":frCenter:ppImg"></p:remoteCommand>
                <p:dialog appendToBody="true" dynamic="true" header="Info Prenda"
                    onShow="pruebaRc" widgetVar="prnd" resizable="false" width="750"
                    height="550" showEffect="fold" position="center"
                    hideEffect="explode">
                    <p:outputPanel id="ppImg" autoUpdate="true">
                        <h:panelGrid columns="2" id="pgInfo">
                            <p:galleria transitionInterval="3000" var="i"
                                value="#{controlMBean.imagenes}"
                                panelWidth="#{controlMBean.width}"
                                panelHeight="#{controlMBean.height}"
                                frameHeight="#{controlMBean.height/4}"
                                frameWidth="#{controlMBean.width/4}" effect="flash">
                                <p:graphicImage id="img" height="#{i.alto}" width="#{i.ancho}"
                                    value="#{controlMBean.ruta}#{i.nombre}.jpg" />
                            </p:galleria>
                            <h:panelGrid columns="2" width="350">
                                <h:outputLabel value="ID:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.id}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Prenda:" styleClass="etiqueta" />
                                <h:outputText
                                    value="#{controlMBean.artElegido.prenda} adasd"
                                    styleClass="resultado" />
                                <h:outputLabel value="Precio:" styleClass="etiqueta" />
                                <h:outputText value="$#{controlMBean.artElegido.precio}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Marca:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.marca}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Sucursal:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.suc}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Descripcion:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.descr}"
                                    styleClass="resultado" style="width:300px;height:100px;" />
                            </h:panelGrid>
                        </h:panelGrid>
                    </p:outputPanel>
                </p:dialog>
            </h:form>
        </p:layoutUnit>

    </p:layout>
</h:body>
</html>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I hope somebody could help me with the trouble I am having with JSF 2 and Primefaces 3.0M3.

the problem is that the back bean methods do not fired from any component in the layoutunit 'center' they are inside a form and nothing happens, even I tried to update the components with remoteCommand, autoUpdate of the outputpanel, commandButton with action and actionListener and nothing, there is no error message. In the layoutunit west works the components well, renders the outputpanel (pfpInfo) of the center layoutunit but I do not know what is happening.

here is the code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<h:head>
    <title>Articulos</title>
</h:head>
<h:body>
    <link rel="stylesheet" type="text/css" href="../css/estilos.css" />

            ss

            <h:form id="frWest">

                        <h:outputText value="#{rama}" styleClass="encabezadoUiLight" />

            </h:form>

            <h:form id="frCenter">

                            <f:facet name="header">Articulo(s)</f:facet>

                                <f:facet name="header">
                                    <h:outputText value="Id" />
                                </f:facet>
                                <h:outputText value="#{prnda.id}" />

                                <f:facet name="header">
                                    <h:outputText value="Modelo" />
                                </f:facet>
                                <h:outputText value="#{prnda.articulo}" />

                                <f:facet name="header">
                                    <h:outputText value="Marca" />
                                </f:facet>
                                <h:outputText value="#{prnda.marca}" />

                                <f:facet name="header">
                                    <h:outputText value="Ubicación" />
                                </f:facet>
                                <h:outputText value="#{prnda.edo}" />

                                <f:facet name="header">
                                    <h:outputText value="Estatus" />
                                </f:facet>
                                <h:outputText value="#{prnda.stsArticulo} " />

                                <f:facet name="header">
                                    <h:outputText value="Precio" />
                                </f:facet>
                                <h:outputText value="$ #{prnda.precio}" />

                    <h:outputText value="#{controlMBean.mensaje}"
                        styleClass="textoUiLight" id="hotMen" />

                        <h:panelGrid columns="2" id="pgInfo">

                            <h:panelGrid columns="2" width="350">
                                <h:outputLabel value="ID:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.id}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Prenda:" styleClass="etiqueta" />
                                <h:outputText
                                    value="#{controlMBean.artElegido.prenda} adasd"
                                    styleClass="resultado" />
                                <h:outputLabel value="Precio:" styleClass="etiqueta" />
                                <h:outputText value="$#{controlMBean.artElegido.precio}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Marca:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.marca}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Sucursal:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.suc}"
                                    styleClass="resultado" />
                                <h:outputLabel value="Descripcion:" styleClass="etiqueta" />
                                <h:outputText value="#{controlMBean.artElegido.descr}"
                                    styleClass="resultado" style="width:300px;height:100px;" />
                            </h:panelGrid>
                        </h:panelGrid>

            </h:form>

</h:body>


问:
WDIO cross browser parallel execution
Is there anyway we can execute all tests parallely in WDIO across mutliple browsers ?

Meaning, if I have 10 test cases and can I run 3 of in Chrome, 2 in firefox and 5 in safari, in parallel ?

How to set similar architecture in GRID ?

Many thanks

I can run the same set of tests in different browsers (with multiple instances) but not at the same time and in parallel

Title: WDIO cross browser parallel execution


Title: aes 128 encryption and decryption in c without any seperate libraries and header files needed mainly in diagnostics point of view

Body:
#include <stdio.h>
#include <stdint.h>

#define Nb 4
#define Nk 4
#define Nr 10

uint8_t state[4 * Nb];
uint8_t w[Nb * (Nr + 1) * 4];

#define mul2(x) ((x << 1) ^ (((x >> 7) & 1) * 0x1b))
#define mul3(x) (mul2(x) ^ x)
#define mul9(x) (mul2(mul2(mul2(x))) ^ x)
#define mul11(x) (mul2(mul2(mul2(x)) ^ x) ^ x)
#define mul13(x) (mul2(mul2(mul2(x) ^ x)) ^ x)
#define mul14(x) (mul2(mul2(mul2(x) ^ x) ^ x))

i dont want to use lookup table for xor multiplications so used this above method as reference to caliculate the values runtime

uint8_t sbox[256] = {
  0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
  0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
  0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
  0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
  0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
  0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
  0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
  0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
  0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
  0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
  0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
  0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
  0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
  0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
  0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
  0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};

uint8_t inv_sbox[256] = {
  0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
  0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
  0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
  0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
  0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
  0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
  0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
  0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
  0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
  0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
  0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
  0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
  0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
  0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
  0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
  0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d

};

uint8_t rcon[256] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39,
0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef,
0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b,
0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3,
0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20,
0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35,
0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04,
0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63,
0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d
};

uint32_t sub_bytes_word(uint32_t word) {
  uint8_t* bytes = (uint8_t*)&word;
  for (int i = 0; i < 4; i++) {
    bytes[i] = sbox[bytes[i]];
  }
  return word;
}

uint32_t inv_sub_bytes_word(uint32_t word) {
  uint8_t* bytes = (uint8_t*)&word;
  for (int i = 0; i < 4; i++) {
    bytes[i] = inv_sbox[bytes[i]];
  }
  return word;
}

uint32_t rot_word(uint32_t word) {
  return (word << 8) | (word >> 24);
}

uint32_t sub_word(uint32_t word) {
  return sub_bytes_word(word);
}

uint32_t inv_word(uint32_t word) {
  return inv_sub_bytes_word(word);
}

void key_expansion(uint8_t* key) {
  for (int i = 0; i < Nk; i++) {
    w[i] = key[4 * i] << 24 | key[4 * i + 1] << 16 | key[4 * i + 2] << 8 | key[4 * i + 3];
  }
  for (int i = Nk; i < 4 * (Nr + 1); i++) {
    uint32_t temp = w[i - 1];
    if (i % Nk == 0) {
      temp = sub_word(rot_word(temp)) ^ rcon[i / Nk - 1];
    } else if (Nk > 6 && i % Nk == 4) {
      temp = sub_word(temp);
    }
    w[i] = w[i - Nk] ^ temp;
  }
  for (int i = 0; i < 4 * (Nr + 1); i++) {
    w[i] = inv_word(w[i]);
  }
}

void sub_bytes() {
  for (int i = 0; i < 4 * Nb; i++) {
    state[i] = sbox[state[i]];
  }
}

void shift_rows() {
  uint8_t temp[4 * Nb];
  for (int i = 0; i < 4 * Nb; i++) {
    temp[i] = state[i];
  }
  for (int i = 0; i < Nb; i++) {
    state[i] = temp[i];
    state[i + 4] = temp[i + 4];
    state[i + 8] = temp[i + 8];
    state[i + 12] = temp[i + 12];
  }
  state[1] = temp[5];
  state[5] = temp[9];
  state[9] = temp[13];
  state[13] = temp[1];
  state[2] = temp[10];
  state[6] = temp[14];
  state[10] = temp[2];
  state[14] = temp[6];
  state[3] = temp[15];
  state[7] = temp[3];
  state[11] = temp[7];
  state[15] = temp[11];
}

void mix_columns() {
  uint8_t temp[4 * Nb];
  for (int i = 0; i < 4 * Nb; i++) {
    temp[i] = state[i];
  }
  for (int i = 0; i < Nb; i++) {
    state[0 + 4 * i] = mul2(temp[0 + 4 * i]) ^ mul3(temp[1 + 4 * i]) ^ temp[2 + 4 * i] ^ temp[3 + 4 * i];
    state[1 + 4 * i] = temp[0 + 4 * i] ^ mul2(temp[1 + 4 * i]) ^ mul3(temp[2 + 4 * i]) ^ temp[3 + 4 * i];
    state[2 + 4 * i] = temp[0 + 4 * i] ^ temp[1 + 4 * i] ^ mul2(temp[2 + 4 * i]) ^ mul3(temp[3 + 4 * i]);
    state[3 + 4 * i] = mul3(temp[0 + 4 * i]) ^ temp[1 + 4 * i] ^ temp[2 + 4 * i] ^ mul2(temp[3 + 4 * i]);
  }
}

void add_round_key(int round) {
  for (int i = 0; i < 4 * Nb; i++) {
    state[i] ^= w[round * 4 * Nb + i];
  }
}

void aes_round(int round) {
  sub_bytes();
  shift_rows();
  mix_columns();
  add_round_key(round);
}

void inv_sub_bytes() {
  for (int i = 0; i < 4 * Nb; i++) {
    state[i] = inv_sbox[state[i]];
  }
}
void inv_shift_rows() {
  uint8_t temp[4 * Nb];
  for (int i = 0; i < 4 * Nb; i++) {
    temp[i] = state[i];
  }
  for (int i = 0; i < Nb; i++) {
    state[i] = temp[i];
    state[i + 4] = temp[i + 4];
    state[i + 8] = temp[i + 8];
    state[i + 12] = temp[i + 12];
  }
  state[1] = temp[13];
  state[5] = temp[1];
  state[9] = temp[5];
  state[13] = temp[9];
  state[2] = temp[10];
  state[6] = temp[14];
  state[10] = temp[2];
  state[14] = temp[6];
  state[3] = temp[7];
  state[7] = temp[11];
  state[11] = temp[15];
  state[15] = temp[3];
}

void inv_mix_columns() {
  uint8_t temp[4 * Nb];
  for (int i = 0; i < 4 * Nb; i++) {
    temp[i] = state[i];
  }
  for (int i = 0; i < Nb; i++) {
    state[0 + 4 * i] = mul14(temp[0 + 4 * i]) ^ mul11(temp[1 + 4 * i]) ^ mul13(temp[2 + 4 * i]) ^ mul9(temp[3 + 4 * i]);
    state[1 + 4 * i] = mul9(temp[0 + 4 * i]) ^ mul14(temp[1 + 4 * i]) ^ mul11(temp[2 + 4 * i]) ^ mul13(temp[3 + 4 * i]);
    state[2 + 4 * i] = mul13(temp[0 + 4 * i]) ^ mul9(temp[1 + 4 * i]) ^ mul14(temp[2 + 4 * i]) ^ mul11(temp[3 + 4 * i]);
    state[3 + 4 * i] = mul11(temp[0 + 4 * i]) ^ mul13(temp[1 + 4 * i]) ^ mul9(temp[2 + 4 * i]) ^ mul14(temp[3 + 4 * i]);
  }
}

void inv_aes_round(int round) {
  add_round_key(round);
  inv_mix_columns();
  inv_shift_rows();
  inv_sub_bytes();
}

Here i tried encrypt and decrypt the plain text

void encrypt(uint8_t* plaintext, uint8_t* key) {
  for (int i = 0; i < 4 * Nb; i++) {
    state[i] = plaintext[i];
  }
  key_expansion(key);
  add_round_key(0);
  for (int i = 1; i <= Nr; i++) {
    aes_round(i);
  }
}

void decrypt(uint8_t* ciphertext, uint8_t* key) {
  for (int i = 0; i < 4 * Nb; i++) {
    state[i] = ciphertext[i];
  }
  key_expansion(key);
  add_round_key(Nr);
  for (int i = Nr - 1; i >= 1; i--) {
    inv_aes_round(i);
  }
  inv_aes_round(0);
}

My main function

int main() {
  // Set key and plaintext
  uint8_t key[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
  uint8_t plaintext[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
  uint8_t ciphertext[16];
  uint8_t decrypted[16];

  // Plaintext
    printf("Original plaintext:  ");
    for (int i = 0; i < 16; i++) {
        printf("%02x ", plaintext[i]);
    }
    printf("\n");
  // Encrypt plaintext
  encrypt(plaintext, key);
  printf("Ciphertext: ");
  for (int i = 0; i < 4 * Nb; i++) {
    printf("%02x ", state[i]);
    ciphertext[i] = state[i];
  }
  printf("\n");

  // Decrypt ciphertext
  decrypt(ciphertext, key);
  printf("Decrypted:  ");
  for (int i = 0; i < 4 * Nb; i++) {
    printf("%02x ", state[i]);
    decrypted[i] = state[i];
  }
  printf("\n");

  return 0;
}

i have tried improving the code many times by assigning seperate functions to implement but every time my output is wrong .\

This is my output ; whatever i tried iam not able to get correct decrypt . iam not sure where i did mistake .

Original plaintext:  01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef

Ciphertext: ec d5 9c a4 41 cb cb e5 08 02 a3 cc 7c 39 be 74

Decrypted:  37 b8 75 c5 01 5c 74 14 b4 e9 11 d8 3c 16 cd c2


问:
problem with Overriding toString on object
I am writing a myset class that has a Array of Object. I am trying override the toString method but it is not printing the elements when I call testing.

here is the method override

```<code>@Override
    public String toString()
    {
        if(size==0){
            return "[]";
        }else{
            string result="["+ arr[0];
            for(int i=1;i<size;i++)
            {
                result+=", "+arr[i];
            }
        }
        result+="]";
        return result;

    }
</code>```

this is the array I am Trying to call

private static  Object[] arr={1, 2, 3, 4 ,5, 6, 'A', 8 , "easha", 0, 44};

System.out.print(arr);

this is how I am calling it in the main

this is the result I get
[Ljava.lang.Object;@1dbd16a6%

FYI: I have a size method that calculates the size.

I was expecting the array to look like this {1, 2, 3, 4 ,5, 6, 'A', 8 , "easha", 0, 44}

but the result is  this [Ljava.lang.Object;@1dbd16a6% `

Body:
I am writing a myset class that has a Array of Object. I am trying override the toString method but it is not printing the elements when I call testing.

here is the method override

@Override
    public String toString()
    {
        if(size==0){
            return "[]";
        }else{
            string result="["+ arr[0];
            for(int i=1;i<size;i++)
            {
                result+=", "+arr[i];
            }
        }
        result+="]";
        return result;

    }

this is the array I am Trying to call

private static  Object[] arr={1, 2, 3, 4 ,5, 6, 'A', 8 , "easha", 0, 44};

System.out.print(arr);

this is how I am calling it in the main

this is the result I get
[Ljava.lang.Object;@1dbd16a6%

FYI: I have a size method that calculates the size.

I was expecting the array to look like this {1, 2, 3, 4 ,5, 6, 'A', 8 , "easha", 0, 44}

but the result is  this [Ljava.lang.Object;@1dbd16a6% `


问:
KQl to extract RCE attempts
I am trying to query For Remote Code Execution Attempt alerts, Does anyone have an idea how to go about this.

```<code>SecurityAlert
| where TimeGenerated >= ago(20d)
| where  AlertName contains "Remote code execution attempt"
| extend Entities = tostring(parse_json(Entities)[0])
| project Entities, AlertName, Status
</code>```

I am trying to output the Hostnames and other information

Title: KQl to extract RCE attempts

Body:
I am trying to query For Remote Code Execution Attempt alerts, Does anyone have an idea how to go about this.

SecurityAlert
| where TimeGenerated >= ago(20d)
| where  AlertName contains "Remote code execution attempt"
| extend Entities = tostring(parse_json(Entities)[0])
| project Entities, AlertName, Status

I am trying to output the Hostnames and other information


问:
How to start mysql.server in Workbench?
I just installed, in a mac M1, MySQL 8.0 (from hombrew) brew install mysql and also MySQL Workbench 8.0 Community edition.

The thing is that I cannot start the server since the workbench app. There is not a problem with the console commands: mysql.server start/stop...

In MySQL Workbench I go to Startup/Shutdown and in the config section I put /opt/homebrew/bin/mysql.server start and /opt/homebrew/bin/mysql.server stop

The problem I have is that the stop command works fine but the start does not work properly because after I click the start button, Workbench gets stuck.

Do you have solved this? How can I fix it?

Thanks

Title: How to start mysql.server in Workbench?


问:
How can I fix this error that I get from setting a character of a string equal to a element of a vector
I'm trying to make a program that converts decimal numbers to a certain base and then finding how many times the largest number (1-8) in that base appears.

string conv(int decimal, int base);
vector<int>base10nums;
vector<string>differentbase;

int main(){
    int num,base,start;
    cin>>num>>base>>start;
    for(int i=0;i<num;++i){
        base10nums.push_back(start+i);
    }
    for(int i=0;i<num;++i){
        string x=conv(base10nums[i],base);
        differentbase.push_back(x);
    }
    int u=0;
    int largestdigit=base-1;
    for(int i=0;i<num;++i){
        string l=differentbase[i];    //error here
        for(int j=0;j<differentbase[i].length();++i){
            if(largestdigit==8){
                if(l[j]=='8'){          //error here
                     u++;
                }
            }
            if(largestdigit==7){
               if(l[j]=='7'){
                     u++;
               }
            }
            if(largestdigit==6){
                if(l[j]=='6'){
                     u++;
               }
            }
            if(largestdigit==5){
                if(l[j]=='5'){
                     u++;
               }
            }
            if(largestdigit==4){
                if(l[j]=='4'){
                     u++;
               }
            }
            if(largestdigit==3){
                if(l[j]=='3'){
                     u++;
               }
            }
            if(largestdigit==2){
                if(l[j]=='2'){
                     u++;
               }
            }
            if(largestdigit==1){
                if(l[j]=='1'){
                     u++;
               }
            }
        }
    }
    std::cout<<u;
}

std::string conv(int decimal, int base){
    if(decimal == 0) return "0";
    char NUMS[] = "0123456789ABCDEF";
    std::string result = "";
    do{
        result.push_back(NUMS[decimal%base]);
        decimal /= base;
    }while(decimal != 0);
    return std::string(result.rbegin(), result.rend());
}
```

In the part with a bunch of ifs, I'm trying to compare each digit in each number in base base to the largest digit. I can run the program, but I don't get the right value and when I hover over the l[j] part in VSCode, I get the error:

"inline char &std::string::operator[](std::size_t __pos)

+1 overload

Subscript access to the data contained in the %string.

Parameters:

__pos – The index of the character to access.

Returns:

Read/write reference to the character. This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)"

Any help is appreciated!

Body:
I'm trying to make a program that converts decimal numbers to a certain base and then finding how many times the largest number (1-8) in that base appears.

string conv(int decimal, int base);
vector<int>base10nums;
vector<string>differentbase;

int main(){
    int num,base,start;
    cin>>num>>base>>start;
    for(int i=0;i<num;++i){
        base10nums.push_back(start+i);
    }
    for(int i=0;i<num;++i){
        string x=conv(base10nums[i],base);
        differentbase.push_back(x);
    }
    int u=0;
    int largestdigit=base-1;
    for(int i=0;i<num;++i){
        string l=differentbase[i];    //error here
        for(int j=0;j<differentbase[i].length();++i){
            if(largestdigit==8){
                if(l[j]=='8'){          //error here
                     u++;
                }
            }
            if(largestdigit==7){
               if(l[j]=='7'){
                     u++;
               }
            }
            if(largestdigit==6){
                if(l[j]=='6'){
                     u++;
               }
            }
            if(largestdigit==5){
                if(l[j]=='5'){
                     u++;
               }
            }
            if(largestdigit==4){
                if(l[j]=='4'){
                     u++;
               }
            }
            if(largestdigit==3){
                if(l[j]=='3'){
                     u++;
               }
            }
            if(largestdigit==2){
                if(l[j]=='2'){
                     u++;
               }
            }
            if(largestdigit==1){
                if(l[j]=='1'){
                     u++;
               }
            }
        }
    }
    std::cout<<u;
}

std::string conv(int decimal, int base){
    if(decimal == 0) return "0";
    char NUMS[] = "0123456789ABCDEF";
    std::string result = "";
    do{
        result.push_back(NUMS[decimal%base]);
        decimal /= base;
    }while(decimal != 0);
    return std::string(result.rbegin(), result.rend());
}

In the part with a bunch of ifs, I'm trying to compare each digit in each number in base base to the largest digit. I can run the program, but I don't get the right value and when I hover over the l[j] part in VSCode, I get the error:

"inline char &std::string::operator[](std::size_t __pos)

+1 overload

Subscript access to the data contained in the %string.

Parameters:

__pos – The index of the character to access.

Returns:

Read/write reference to the character. This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)"

Any help is appreciated!


问:
how to generate the tensorflow doc for offline viewing
How do you generate the tensorflow docs on windows (or wsl).

I have tried to run setup.py build and setup.py install but all that did was build and install the module.


问:
Different clustering results on Azure databricks (cloud) vs Jupyter Notebook (local) with same seed
I ran sklearn Kmeans clustering on a dataset with the same code and seed on both setup but why do I still get different clustering results?

```<code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import sklearn.cluster as cluster
import sklearn.metrics as metrics
from sklearn.preprocessing import MinMaxScaler
import seaborn as sns

df = pd.read_csv("sample_dataset.csv")

#return only unique records
df2 = df.drop_duplicates(subset=["ID"], keep = "first")

#remove outliers
df2[["AMT_INCOME_TOTAL", "DAYS_BIRTH"]] = df2[["AMT_INCOME_TOTAL", "DAYS_BIRTH"]].astype("float")
iqr = df2["AMT_INCOME_TOTAL"].quantile(q=0.75) - df2["AMT_INCOME_TOTAL"].quantile(q=0.25)
upperbound = df2["AMT_INCOME_TOTAL"].quantile(q=0.75) + 1.5 * iqr
#keep records lesser than upperbound
df2 = df2.where(df2["AMT_INCOME_TOTAL"] <= upperbound)
df2 = df2[df2["AMT_INCOME_TOTAL"].notna()]

df2["AGE"] = round(abs(df2["DAYS_BIRTH"]/365))

df3 = df2[["ID","AMT_INCOME_TOTAL","AGE"]]

#for simplicity, dod 2 cols only #amt income and age
#min max normalisation
scaler = MinMaxScaler()
scale = scaler.fit_transform(df3[["AMT_INCOME_TOTAL","AGE"]])
df_scale = pd.DataFrame(scale, columns=["AMT_INCOME_TOTAL","AGE"])
X= df_scale.values

#best K is 3
k_means_best = KMeans(n_clusters=3, init="k-means++", random_state=101)
y= k_means_best.fit_predict(X)
</code>```

I tried with two local machines and both produce the same results but when tested on Azure databricks, the results are different.

Body:
I ran sklearn Kmeans clustering on a dataset with the same code and seed on both setup but why do I still get different clustering results?

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import sklearn.cluster as cluster
import sklearn.metrics as metrics
from sklearn.preprocessing import MinMaxScaler
import seaborn as sns

df = pd.read_csv("sample_dataset.csv")

#return only unique records
df2 = df.drop_duplicates(subset=["ID"], keep = "first")

#remove outliers
df2[["AMT_INCOME_TOTAL", "DAYS_BIRTH"]] = df2[["AMT_INCOME_TOTAL", "DAYS_BIRTH"]].astype("float")
iqr = df2["AMT_INCOME_TOTAL"].quantile(q=0.75) - df2["AMT_INCOME_TOTAL"].quantile(q=0.25)
upperbound = df2["AMT_INCOME_TOTAL"].quantile(q=0.75) + 1.5 * iqr
#keep records lesser than upperbound
df2 = df2.where(df2["AMT_INCOME_TOTAL"] <= upperbound)
df2 = df2[df2["AMT_INCOME_TOTAL"].notna()]

df2["AGE"] = round(abs(df2["DAYS_BIRTH"]/365))

df3 = df2[["ID","AMT_INCOME_TOTAL","AGE"]]

#for simplicity, dod 2 cols only #amt income and age
#min max normalisation
scaler = MinMaxScaler()
scale = scaler.fit_transform(df3[["AMT_INCOME_TOTAL","AGE"]])
df_scale = pd.DataFrame(scale, columns=["AMT_INCOME_TOTAL","AGE"])
X= df_scale.values

#best K is 3
k_means_best = KMeans(n_clusters=3, init="k-means++", random_state=101)
y= k_means_best.fit_predict(X)

I tried with two local machines and both produce the same results but when tested on Azure databricks, the results are different.


问:
Moshi - Skip a object if it contains a certain value
Suppose I have the following JSON -

```<code>{
  "list": [
    {
      "name": "John",
      "age": 20
    },
    {
      "name": "Peter"
      "age": 18
    },
    {
      "name": "Jane",
      "age": 21
    }
  ]
}
</code>```

Is there a way in moshi in which we can skip the list item where the name is "Peter"?

My issue is that I need to show a list of items only if they match with certain values (eg. "imageType" = "jpeg") provided in json and skip everything else. I am wondering if one can do the skipping at the json parsing level rather than somewhere in the business logic where I would have to run a for loop and go through every element again.

Body:
Suppose I have the following JSON -

{
  "list": [
    {
      "name": "John",
      "age": 20
    },
    {
      "name": "Peter"
      "age": 18
    },
    {
      "name": "Jane",
      "age": 21
    }
  ]
}

Is there a way in moshi in which we can skip the list item where the name is "Peter"?

My issue is that I need to show a list of items only if they match with certain values (eg. "imageType" = "jpeg") provided in json and skip everything else. I am wondering if one can do the skipping at the json parsing level rather than somewhere in the business logic where I would have to run a for loop and go through every element again.


问:
My Flask app is running but could not load bootstrap and css,js files correctly
I am creating an app using Python Flask. When I am trying to load the bootstrap static files, the template could not correctly recognize those files. Here is my project structure:

flaskbook
-- apps
-- crud
-- static
-- css
-- bootstrap.css
-- bootstrap.min.css
-- style.css
-- js
-- bootstrap.bundle.min.js
-- templates
-- crud
-- create.html
-- init.py
-- forms.py
-- models.py
-- views.py
-- app.py

crud/templates/crud/create.html

```<code><html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增使出表單</title>
    ##Here could not load correctly the css and js files
    <link rel="stylesheet" href="{{ url_for('static',filename='css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.3/font/bootstrap-icons.css">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/style.css') }}">
    <!-- js文件載入 -->
    <script src="{{ url_for('static',filename='js/bootstrap.bundle.min.js') }}"></script>
</head>
<body>
    <div class="container">
        <h2 class="text-center">新增使用者</h2>
        <form action="{{  url_for('crud.create_user') }}" method="POST" novalidate="novalidate">
            {{  form.csrf_token }}
            <table class="table table-bordered">
                <tr>
                    <td class="form-label">{{ form.username.label }}</td>
                    <td>{{ form.username(placeholder="使用者名稱") }}</td>
                </tr>
                <tr>
                    <td class="form-label">{{ form.email.label }}</td>
                    <td>{{ form.email(placeholder="郵件地址") }}</td>
                </tr>
                <tr>
                    <td class="form-label">{{ form.password.label }}</td>
                    <td>{{ form.password(placeholder="密碼") }}</td>
                </tr>
            </table>
            <p class="btn btn-primary">{{  form.submit() }}</p>
        </form>
    </div>

</body>
</html>`

` * Serving Flask app 'apps.app:create_app' (lazy loading)
 * Environment: development
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 529-415-487
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/css/bootstrap.min.css HTTP/1.1" 404 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/css/style.css HTTP/1.1" 404 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 404 -
#The first time loading css and js static files
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/bootstrap.min.css HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/style.css HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -```

I am expecting the flask app should load the css and js files accordingly while running so can anyone figure out the problem of the project structure?
```

Body:
I am creating an app using Python Flask. When I am trying to load the bootstrap static files, the template could not correctly recognize those files. Here is my project structure:

flaskbook
-- apps
-- crud
-- static
-- css
-- bootstrap.css
-- bootstrap.min.css
-- style.css
-- js
-- bootstrap.bundle.min.js
-- templates
-- crud
-- create.html
-- init.py
-- forms.py
-- models.py
-- views.py
-- app.py

crud/templates/crud/create.html

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增使出表單</title>
    ##Here could not load correctly the css and js files
    <link rel="stylesheet" href="{{ url_for('static',filename='css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.3/font/bootstrap-icons.css">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/style.css') }}">

新增使用者

        <form action="{{  url_for('crud.create_user') }}" method="POST" novalidate="novalidate">
            {{  form.csrf_token }}

                    {{ form.username.label }}
                    {{ form.username(placeholder="使用者名稱") }}

                    {{ form.email.label }}
                    {{ form.email(placeholder="郵件地址") }}

                    {{ form.password.label }}
                    {{ form.password(placeholder="密碼") }}

{{  form.submit() }}

        </form>

`

` * Serving Flask app 'apps.app:create_app' (lazy loading)
 * Environment: development
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 529-415-487
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/css/bootstrap.min.css HTTP/1.1" 404 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/css/style.css HTTP/1.1" 404 -
127.0.0.1 - - [10/Jan/2023 10:12:32] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 404 -
#The first time loading css and js static files
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/bootstrap.min.css HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/style.css HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:12] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /crud/users/new HTTP/1.1" 200 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/css/style.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jan/2023 10:13:22] "GET /static/js/bootstrap.bundle.min.js HTTP/1.1" 304 -```

I am expecting the flask app should load the css and js files accordingly while running so can anyone figure out the problem of the project structure?


问:
How to set some nan values to null and work with sql server?
I am getting the following error:

```<code>and target_id = ? and gname_id = ? and weapon_id = ? and success = ? and claimed = ? and ishostkid = ?',date_id, region_id, attack_id, target_id, gname_id, weapon_id, success, claimed, ishostkid)
pyodbc.DataError: ('22018', "[22018] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value 'nan' to data type int. (245) (SQLExecDirectW)")
</code>```

The problem is that some values in success, claimed and ishostkid columns (in pandas dataframe) are nan-values. How to convert it to null and work with SQL Server? (which the columns are int type, but accept null values)

I have find out the following workarround: fill a nan-value with something else, in the following example is filled with -100:

```<code>df['success'] = df['success'].fillna(-100)
df['claimed'] = df['claimed'].fillna(-100)
df['ishostkid'] = df['ishostkid'].fillna(-100)
</code>```

But I'd like to store as null in the database.

Body:
I am getting the following error:

and target_id = ? and gname_id = ? and weapon_id = ? and success = ? and claimed = ? and ishostkid = ?',date_id, region_id, attack_id, target_id, gname_id, weapon_id, success, claimed, ishostkid)
pyodbc.DataError: ('22018', "[22018] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value 'nan' to data type int. (245) (SQLExecDirectW)")

The problem is that some values in success, claimed and ishostkid columns (in pandas dataframe) are nan-values. How to convert it to null and work with SQL Server? (which the columns are int type, but accept null values)

I have find out the following workarround: fill a nan-value with something else, in the following example is filled with -100:

df['success'] = df['success'].fillna(-100)
df['claimed'] = df['claimed'].fillna(-100)
df['ishostkid'] = df['ishostkid'].fillna(-100)

But I'd like to store as null in the database.


问:
Extracting layer types and parameters of torchscript models
I am trying to extract the layer types and parameters from some torchscript models.

I have a script for for the same task that works for pytorch models. The script uses model.named_modules() to extract the layers. However, named_modules() does not work the same way for torchscript models. All the layers are named RecursiveScriptModule and I'm confused how to know the layer type and other parameters from this. Can anyone help me with it?

I also tried converting the model to pytorch model but I couldn't.

Can anyone help me about this? Thanks!


问:
RecordRTCPromisesHandler: RecordRTCPromisesHandler Interface cannot be instantiated
I am new to muaz-khan/RecordRTC, first time using it, copy/pasted the default implementation below and it already throwing error.

Why is this code snippet showing this error?

```<code>import { useState, useEffect } from "react";
import RecordRTC, { RecordRTCPromisesHandler } from "recordrtc";

export const useRecorderPermission = (
    recordingType
) => {

    const [recorder, setRecorder] = useState(null);

    useEffect(() => {
        getPermissionInitializeRecorder();
    }, []);

    const getPermissionInitializeRecorder = async () => {

        let stream = await (navigator).mediaDevices.getUserMedia({
            video: true,
            audio: true,
        });

        let recorder = new RecordRTCPromisesHandler(stream, {
            type: recordingType,
        });

        setRecorder(recorder);

    };

    return recorder;

};
</code>```

https://prnt.sc/DpbBXr_9Fp0F

Body:
I am new to muaz-khan/RecordRTC, first time using it, copy/pasted the default implementation below and it already throwing error.

Why is this code snippet showing this error?

import { useState, useEffect } from "react";
import RecordRTC, { RecordRTCPromisesHandler } from "recordrtc";

export const useRecorderPermission = (
    recordingType
) => {

    const [recorder, setRecorder] = useState(null);

    useEffect(() => {
        getPermissionInitializeRecorder();
    }, []);

    const getPermissionInitializeRecorder = async () => {

        let stream = await (navigator).mediaDevices.getUserMedia({
            video: true,
            audio: true,
        });

        let recorder = new RecordRTCPromisesHandler(stream, {
            type: recordingType,
        });

        setRecorder(recorder);

    };

    return recorder;

};

https://prnt.sc/DpbBXr_9Fp0F


问:
Receiving error "SDK is not defined for Run Configuration" on Ubuntu
My wife is taking a programming class and is using an Ubuntu laptop. Whenever she enters code into PyCharm Edu, this is the error that comes up. Any suggestions?enter image description here

A Google search had some suggestions but as we are unfamiliar with the program, they weren't helpful


问:
ACTION_UP not working when click three button in the same time
I have 3 buttons, I want to handle some events when I touch those 3 buttons, I have considered the events of motion event, everything runs normally however if I touch those 3 buttons at the same time, the event The ACTION_UP of the 3 buttons will not be called instead the ACTION_CANCEL event. I don't know the cause of this and how can I call ACTION_UP in this case?
Here in my code:</p>
```<code>switch (motionEvent.getAction()){
            case MotionEvent.ACTION_DOWN:
                System.out.println("down");
                break;
            case MotionEvent.ACTION_UP:
                System.out.println("up");
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_CANCEL:
                System.out.println("cancel");
                break;
        }
</code>```

Body:
I have 3 buttons, I want to handle some events when I touch those 3 buttons, I have considered the events of motion event, everything runs normally however if I touch those 3 buttons at the same time, the event The ACTION_UP of the 3 buttons will not be called instead the ACTION_CANCEL event. I don't know the cause of this and how can I call ACTION_UP in this case?
Here in my code:

switch (motionEvent.getAction()){
            case MotionEvent.ACTION_DOWN:
                System.out.println("down");
                break;
            case MotionEvent.ACTION_UP:
                System.out.println("up");
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_CANCEL:
                System.out.println("cancel");
                break;
        }


问:
How to write testcase for django apis which has jwt?
I have python django project which has jwt implemented. And otp system and hash implementation for verifying email so any to write test cases for it.
I dont want to test every models and serializers. Just want to test api end points if its working or not
If anyone has any kind of example of it can share please</p>


问:
How to make an isometric room in XCode
I was wondering if it was possible to make a room, like a home design app, using tile maps.

It would require 3 grids:

An isometric base (10x20)

Two walls (6x20) & (10x6)

I have attempted to use the Scene Editor to layout everything, but that isn't working.

There isn't much online that I could find to solve it, but I have a feeling its just simple math.

I'm still quite new to this, so any advice would be greatly appreciated.

Title: How to make an isometric room in XCode


问:
How to add a tooltip at the right side of the image when hovering the image using javascript mouse events
I need to have a tooltip in to the right side of my image with some information as i hover this specific image using image map. Here is my code bellow.

```<code><img id="spell-1-sun" src="shm_resources/magic/1-mesomorph-body-unav.png" usemap="#spell-1-sun" border="0" alt="" class="magic-sun-1">

<map id="i-spell-1-sun" name="spell-1-sun">
<area shape="poly" coords="0,0,39,1,39,39,0,39" data-passage="Ultimate Test 2" alt="" title="" data-setter="$spellsunone to 'on'" onMouseOver="if(document.images) document.getElementById('spell-1-sun').src= 'shm_resources/magic/1-mesomorph-body-hover.png';" onMouseOut="if(document.images) document.getElementById('spell-1-sun').src= 'shm_resources/magic/1-mesomorph-body-unav.png';"/>
</map>
</code>```

Everything is working as intended, but i'm struggling to add this tooltip to the image to finally close this case. Please, help me.

So far everything that i have tried about adding a tooltip to the right side using image map() failed.
Thank you all in advance.

Body:
I need to have a tooltip in to the right side of my image with some information as i hover this specific image using image map. Here is my code bellow.

<map id="i-spell-1-sun" name="spell-1-sun">
<area shape="poly" coords="0,0,39,1,39,39,0,39" data-passage="Ultimate Test 2" alt="" title="" data-setter="$spellsunone to 'on'" onMouseOver="if(document.images) document.getElementById('spell-1-sun').src= 'shm_resources/magic/1-mesomorph-body-hover.png';" onMouseOut="if(document.images) document.getElementById('spell-1-sun').src= 'shm_resources/magic/1-mesomorph-body-unav.png';"/>
</map>

Everything is working as intended, but i'm struggling to add this tooltip to the image to finally close this case. Please, help me.

So far everything that i have tried about adding a tooltip to the right side using image map() failed.
Thank you all in advance.


问:
How to use elasticsearch 8.x ingest-attachment with Python
I am trying to read a pdf from python and send it to elasticsearch.
I tried to use ingest-attachment to help with that, but I don't know how.

https://www.elastic.co/guide/en/elasticsearch/reference/master/attachment.html

When I followed the official documentation, it worked. However, there doesn't seem to be a way to use Python in the official documentation.

so, I looked at the official documentation and created my own mapping

Data is entered but not attached.

Wandered around and found this.
but i don't know how to use

elasticsearch.exceptions.RequestError: RequestError(400, 'invalid_index_name_exception', 'Invalid index name [_ingest/pipeline/attachment_pipeline], must not contain the following characters ['\','/','*

','?','"','<','>','|',' ',',']')

If you just run it, it will come out like this: It looks like you have / in your index name. So this time I only ran the bottom part.

elasticsearch.exceptions.RequestError: RequestError(400, 'illegal_argument_exception', 'pipeline with id [attachment_pipeline] does not exist')

..........

I want to know how to use it..

How to make attachment plugin work in python


问:
TypeScript TypeError: create is not a function
New to React and I have this problem in typeScript.

Original class:

```<code>  const [isItDownResponse, setIsItDownResponse] = React.useState<IsItDownResponse | null>(null);
    fetch(IS_IT_DOWN_API)
      .then((response) => response.json())
      .then((result: IsItDownResponse) => {
        setIsItDownResponse(result);
      });
  let bannerType = MessageBannerType.Error;

  if (isItDownResponse != null) {
    switch (isItDownResponse.level) {
      case 0:
        bannerType = MessageBannerType.Success;
        break;
      case 1:
        bannerType = MessageBannerType.Informational;
        break;
      case 2:
        bannerType = MessageBannerType.Warning;
        break;
    }
  }

  return (
      <View className={styles.content}>
        {isItDownResponse === null || isItDownResponse.message === IS_IT_DOWN_GENERAL_MESSAGE ? (
          <></>
        ) : (
          <MessageBanner data-testid="isItDownBannerId" type={bannerType} isDismissible>
            {isItDownResponse.message}
          </MessageBanner>
        )}
      </View>
  );
};
export default Banner;
</code>```

The real banner set works fine in testing.
But in unit test, i got ‘TypeError: create is not a function’

Unit test i have:

```<code>describe('IsItDownBanner', () => {
    let setIsItDownResponse;
    let useStateSpy;
    beforeEach(() => {
      setIsItDownResponse = jest.fn();
      useStateSpy = jest.spyOn(React, 'useState');
      useStateSpy.mockImplementation(() => [null, setIsItDownResponse]);
    });

    test('renders nothing when there is no is-it-down response', () => {
      const { queryByTestId } = renderWithBasicProviders(<IsItDownBanner />);
      const description = queryByTestId('isItDownBannerId');
      expect(description).not.toBeInTheDocument();
    });

    test('renders correct information when there is override in is-it-down response', () => {
        useStateSpy.mockImplementation(() => [{message: 'test', level: 1}, setIsItDownResponse]);
        //fetch.mockResolvedValue({message: 'test', level: 1});
        const { queryByTestId } = renderWithBasicProviders(<IsItDownBanner />);
        const description = queryByTestId('isItDownBannerId');
        expect(description).not.toBeInTheDocument();
    });
});
</code>```

The interesting thing is the first test (with null in response) can pass. But when i tried to pass in some value into the response, it fail with error

```<code>TypeError: create is not a function

    > 77 |   return render(node, {
         |          ^
      78 |     wrapper: BasicProvidersWrapper,
      79 |   });
      80 | };
</code>```

Body:
New to React and I have this problem in typeScript.

Original class:

  const [isItDownResponse, setIsItDownResponse] = React.useState<IsItDownResponse | null>(null);
    fetch(IS_IT_DOWN_API)
      .then((response) => response.json())
      .then((result: IsItDownResponse) => {
        setIsItDownResponse(result);
      });
  let bannerType = MessageBannerType.Error;

  if (isItDownResponse != null) {
    switch (isItDownResponse.level) {
      case 0:
        bannerType = MessageBannerType.Success;
        break;
      case 1:
        bannerType = MessageBannerType.Informational;
        break;
      case 2:
        bannerType = MessageBannerType.Warning;
        break;
    }
  }

  return (
      <View className={styles.content}>
        {isItDownResponse === null || isItDownResponse.message === IS_IT_DOWN_GENERAL_MESSAGE ? (
          <></>
        ) : (
          <MessageBanner data-testid="isItDownBannerId" type={bannerType} isDismissible>
            {isItDownResponse.message}
          </MessageBanner>
        )}
      </View>
  );
};
export default Banner;

The real banner set works fine in testing.
But in unit test, i got ‘TypeError: create is not a function’

Unit test i have:

describe('IsItDownBanner', () => {
    let setIsItDownResponse;
    let useStateSpy;
    beforeEach(() => {
      setIsItDownResponse = jest.fn();
      useStateSpy = jest.spyOn(React, 'useState');
      useStateSpy.mockImplementation(() => [null, setIsItDownResponse]);
    });

    test('renders nothing when there is no is-it-down response', () => {
      const { queryByTestId } = renderWithBasicProviders(<IsItDownBanner />);
      const description = queryByTestId('isItDownBannerId');
      expect(description).not.toBeInTheDocument();
    });

    test('renders correct information when there is override in is-it-down response', () => {
        useStateSpy.mockImplementation(() => [{message: 'test', level: 1}, setIsItDownResponse]);
        //fetch.mockResolvedValue({message: 'test', level: 1});
        const { queryByTestId } = renderWithBasicProviders(<IsItDownBanner />);
        const description = queryByTestId('isItDownBannerId');
        expect(description).not.toBeInTheDocument();
    });
});

The interesting thing is the first test (with null in response) can pass. But when i tried to pass in some value into the response, it fail with error

TypeError: create is not a function

    > 77 |   return render(node, {
         |          ^
      78 |     wrapper: BasicProvidersWrapper,
      79 |   });
      80 | };


问:
how to make a function to create a listview using blockbuilder and json model array flutter
I have a problem implementing a json model and creating a function to display data in text form. I have made a json model and function but there is still something wrong with the function that I created, namely how to implement List

get_history_bloc.dart:

```<code>import 'package:core/core.dart';
import 'package:core/network/models/approval/get_historyuj.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dio/dio.dart';
import 'package:shared/shared.dart';
import 'get_historyuj_event.dart';
import 'get_historyuj_state.dart';

class GetHistoryujBloc extends Bloc<GetHistoryujEvent, GetHistoryujState> {
  final Dio dio;

  GetHistoryujBloc({required this.dio}) : super(GetInitializedUj()) {
    on<Historyuj>(_onGettedUj);
  }

  Future<void> _onGettedUj(
      Historyuj event, Emitter<GetHistoryujState> emit) async {
    try {
      emit(GetLoadingUj());
      var response = await dio.post(UrlConstant.apvUj,
          data: FormData.fromMap({
            'Auth': ApiConstant.authKey,
            'NIK': event.nikKar,
          }));
      if (response.statusCode == 200) {
        if (response.data['Response'] == ApiConstant.networkSuccess) {
          emit(GetHistoryujSuccess(Gethistoryuj.fromJson(response.data)));
        } else if (response.data['Response'] == ApiConstant.networkFailure) {
          emit(GetHistoryujFailure(response.data['Result']));
        }
      } else {
        emit(GetHistoryujFailure(ApiConstant.networkServer));
      }
    } on DioError catch (e) {
      if (e.type == DioErrorType.connectTimeout ||
          e.type == DioErrorType.receiveTimeout) {
        emit(GetHistoryujFailure(ApiConstant.networkNoInternet));
      } else if (e.type == DioErrorType.sendTimeout) {
        emit(GetHistoryujFailure(ApiConstant.networkTimeOut));
      } else if (e.type == DioErrorType.other) {
        emit(GetHistoryujFailure(ApiConstant.networkServer));
      } else {
        emit(GetHistoryujFailure(e.toString()));
      }
    }
  }
}

</code>```

Body:
I have a problem implementing a json model and creating a function to display data in text form. I have made a json model and function but there is still something wrong with the function that I created, namely how to implement List

get_history_bloc.dart:

import 'package:core/core.dart';
import 'package:core/network/models/approval/get_historyuj.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dio/dio.dart';
import 'package:shared/shared.dart';
import 'get_historyuj_event.dart';
import 'get_historyuj_state.dart';

class GetHistoryujBloc extends Bloc<GetHistoryujEvent, GetHistoryujState> {
  final Dio dio;

  GetHistoryujBloc({required this.dio}) : super(GetInitializedUj()) {
    on<Historyuj>(_onGettedUj);
  }

  Future<void> _onGettedUj(
      Historyuj event, Emitter<GetHistoryujState> emit) async {
    try {
      emit(GetLoadingUj());
      var response = await dio.post(UrlConstant.apvUj,
          data: FormData.fromMap({
            'Auth': ApiConstant.authKey,
            'NIK': event.nikKar,
          }));
      if (response.statusCode == 200) {
        if (response.data['Response'] == ApiConstant.networkSuccess) {
          emit(GetHistoryujSuccess(Gethistoryuj.fromJson(response.data)));
        } else if (response.data['Response'] == ApiConstant.networkFailure) {
          emit(GetHistoryujFailure(response.data['Result']));
        }
      } else {
        emit(GetHistoryujFailure(ApiConstant.networkServer));
      }
    } on DioError catch (e) {
      if (e.type == DioErrorType.connectTimeout ||
          e.type == DioErrorType.receiveTimeout) {
        emit(GetHistoryujFailure(ApiConstant.networkNoInternet));
      } else if (e.type == DioErrorType.sendTimeout) {
        emit(GetHistoryujFailure(ApiConstant.networkTimeOut));
      } else if (e.type == DioErrorType.other) {
        emit(GetHistoryujFailure(ApiConstant.networkServer));
      } else {
        emit(GetHistoryujFailure(e.toString()));
      }
    }
  }
}


问:
Cannot Established connection to Express Websocket Server from Nuxt JS using nuxt-socket-io
I have this following problem where I cannot establish connection from nuxt js app to express websocket

Here's my following code :

Server Side (websocket server) at index.js

```<code>const express = require('express');
const app = express();
const http = require('http').createServer(app);
const io = require('socket.io')(http, {
  cors: {
    origin: '*'
  }
});
const port = 4000;

http.listen(port, () => {
  console.log('server is up');
  io.on('connection', (socket) => {
    console.log('Connection established');
    console.log(socket.id);
  })
})
</code>```

Client Side (nuxt js)

In nuxt.config.js

```<code>...
modules: [
  ...
  'nuxt-socket-io'
]
...
io: {
  sockets: [{
    name: 'arena',
    default: true,
    url: 'http://localhost:4000',
  }]
}
</code>```

In component that uses websocket :

```<code><template></template>

<script>
export default {
  data() {
    return {
      socket: {},
    };
  },
  mounted() {
    this.socket = this.$nuxtSocket({
      name: "arena",
      channel: "/index",
      reconnection: false,
    });
    this.socket.emit('connection')
  },
};
</script>
</code>```

The error I got from console log is :
GET http://localhost:4000/socket.io/?EIO=4&transport=polling&t=OMPZ7YZ&sid=WOhe-UjXtVOJoPlIAAAG 400 (Bad Request)

And the console.log from the server does not produce any output

What did I missed?

Body:
I have this following problem where I cannot establish connection from nuxt js app to express websocket

Here's my following code :

Server Side (websocket server) at index.js

const express = require('express');
const app = express();
const http = require('http').createServer(app);
const io = require('socket.io')(http, {
  cors: {
    origin: '*'
  }
});
const port = 4000;

http.listen(port, () => {
  console.log('server is up');
  io.on('connection', (socket) => {
    console.log('Connection established');
    console.log(socket.id);
  })
})

Client Side (nuxt js)

In nuxt.config.js

...
modules: [
  ...
  'nuxt-socket-io'
]
...
io: {
  sockets: [{
    name: 'arena',
    default: true,
    url: 'http://localhost:4000',
  }]
}

In component that uses websocket :

<template></template>

The error I got from console log is :
GET http://localhost:4000/socket.io/?EIO=4&transport=polling&t=OMPZ7YZ&sid=WOhe-UjXtVOJoPlIAAAG 400 (Bad Request)

And the console.log from the server does not produce any output

What did I missed?


问:
How to fix "No module named..." error in Sphinx?
I am getting the following error :

```<code>WARNING: autodoc: failed to import module 'create_alias' from module 'src.create_alias'; the following exception was raised:
No module named 'helpers'
</code>```

Project Structure looks like

```<code>project-1
|
|---src
 |---create_alias
   |---__init__.py
   |---create_alias.py
         |---helpers
              |---__init__.py
              |---helper.py
 |---shared_lib
      |
      |---__init__.py
      |---common_helper.py
      |
|--__init__.py

</code>```

project-1 is the project directory and contains the following files/folder

```<code>README.md       docs            samconfig.toml  template.yml
__init__.py     pyproject.toml  src             venv
</code>```

I have added the following extensions in conf.py

```<code>sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../../project-1'))

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.todo',
    'sphinx.ext.napoleon',
    'sphinx.ext.intersphinx',
    'sphinx.ext.ifconfig',
    'sphinx.ext.githubpages',
    'sphinxcontrib.confluencebuilder'
]
</code>```

Sphinx version : v6.1.2

Body:
I am getting the following error :

WARNING: autodoc: failed to import module 'create_alias' from module 'src.create_alias'; the following exception was raised:
No module named 'helpers'

Project Structure looks like

project-1
|
|---src
 |---create_alias
   |---__init__.py
   |---create_alias.py
         |---helpers
              |---__init__.py
              |---helper.py
 |---shared_lib
      |
      |---__init__.py
      |---common_helper.py
      |
|--__init__.py

project-1 is the project directory and contains the following files/folder

README.md       docs            samconfig.toml  template.yml
__init__.py     pyproject.toml  src             venv

I have added the following extensions in conf.py

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../../project-1'))

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.todo',
    'sphinx.ext.napoleon',
    'sphinx.ext.intersphinx',
    'sphinx.ext.ifconfig',
    'sphinx.ext.githubpages',
    'sphinxcontrib.confluencebuilder'
]

Sphinx version : v6.1.2


问:
Excel Pivot Table - group totals at bottom of table
I want to know if it's possible to structure my table as per screenshot below, with the group totals all at the bottom of the table, not above or below the group itself. NOTE: in this sample the orange section is the actual pivot table and the green section are additional rows I created manually to describe what I'm trying to achieve.


问:
Active Directory on VM vs Azure AD Domain Services
We have a couple of VMs in Azure, and want to use one of them as an RDS session host for user workstations.  This requires us to buy CALs and setup the appropriate RDS services.

No problem there, but it also requires the VM to be joined to an Active Directory domain, which we don't have.

Azure offers AD Domain Services, but at USD$100 per month, it seems pricey, for not much return.

Since Active Directory is a standard Windows service, is there anything stopping us from simply installing this role on one of our existing VMs and running our own domain controller?

If not, why would anyone be paying monthly for Azure AD DS?

Any advantages to either approach?  We're a small enterprise, and will not be using AD for managing resources, only for identity management.


问:
How to find difference between timestamps in rows that share the same workflow ID?
I have a table that is arranged as such, need to get the average time each step takes, and am using the updated_at column to do so.

workflow_id
step_name
created_at
updated_at

25
data_capture
2022-03-21 10:20:34
2022-03-21 10:20:55

25
client_signature
2022-03-21 10:20:34
2022-03-22 17:25:15

25
pm_signature
2022-03-21 10:20:34
2022-03-22 23:05:12

105
data_capture
2022-03-24 05:20:34
2022-03-24 10:20:55

105
client_signature
2022-03-24 05:20:34
2022-03-24 17:25:15

105
pm_signature
2022-03-24 05:20:34
2022-03-24 23:05:12

My issue is with the query I have, it is subtracting row 4 from row 3 which are unrelated workflows and making the time spent on data_capture for workflow id 105 incorrect.

I have tried using LAG, LEAD, PARTITION BY, to try and create new rows but I have not found a way to keep the subtractions separate by workflow ID. Here is how the calculation should look:

updated_at from row 1 - created_at for row 1 = time spent on data_capture

updated_at from row 2 - value from step 1 = time spent on client_signature

updated_at from row 3 - value from step 2 = time spent on pm_signature

process restarts for workflow 105

Below are some of my attempts

```<code>`WITH tb1 AS (
SELECT
workflow_id,
workflow_type,
step_name,
step_status,
step_created_at,
step_updated_at,
TIMESTAMPDIFF(SECOND, updated_time, step_updated_at) / 3600 elapsed_time
FROM (
    SELECT *,
        LAG(step_updated_at) OVER (ORDER BY step_updated_at) updated_time
    FROM view_client_workflow_status
    ) s
)
SELECT
step_name,
AVG(elapsed_time)
FROM tb1
WHERE workflow_type = 'client_onboarding_fcc_ip'
GROUP BY 1`
</code>```

Body:
I have a table that is arranged as such, need to get the average time each step takes, and am using the updated_at column to do so.

workflow_id
step_name
created_at
updated_at

25
data_capture
2022-03-21 10:20:34
2022-03-21 10:20:55

25
client_signature
2022-03-21 10:20:34
2022-03-22 17:25:15

25
pm_signature
2022-03-21 10:20:34
2022-03-22 23:05:12

105
data_capture
2022-03-24 05:20:34
2022-03-24 10:20:55

105
client_signature
2022-03-24 05:20:34
2022-03-24 17:25:15

105
pm_signature
2022-03-24 05:20:34
2022-03-24 23:05:12

My issue is with the query I have, it is subtracting row 4 from row 3 which are unrelated workflows and making the time spent on data_capture for workflow id 105 incorrect.

I have tried using LAG, LEAD, PARTITION BY, to try and create new rows but I have not found a way to keep the subtractions separate by workflow ID. Here is how the calculation should look:

updated_at from row 1 - created_at for row 1 = time spent on data_capture

updated_at from row 2 - value from step 1 = time spent on client_signature

updated_at from row 3 - value from step 2 = time spent on pm_signature

process restarts for workflow 105

Below are some of my attempts

`WITH tb1 AS (
SELECT
workflow_id,
workflow_type,
step_name,
step_status,
step_created_at,
step_updated_at,
TIMESTAMPDIFF(SECOND, updated_time, step_updated_at) / 3600 elapsed_time
FROM (
    SELECT *,
        LAG(step_updated_at) OVER (ORDER BY step_updated_at) updated_time
    FROM view_client_workflow_status
    ) s
)
SELECT
step_name,
AVG(elapsed_time)
FROM tb1
WHERE workflow_type = 'client_onboarding_fcc_ip'
GROUP BY 1`


问:
tcp connection can still get eagain after receive fin packet?
this is my code

Firstly I init a tcp server

```<code>type server struct {
    serverConns chan net.Conn
    addr        string
}

func (s *server) init() error {
    s.serverConns = make(chan net.Conn)

    l, err := net.Listen(network, ":8888")
    if err != nil {
        return err
    }
    s.addr = l.Addr().String()
    fmt.Println(s.addr)

    go func() {
        for {
            conn, err := l.Accept()
            if err != nil {
                panic(err)
            }
            s.serverConns <- conn
        }
    }()

    return nil
}
</code>```

Then I create a tcp connection, and close connection from server. CheckConnErr call syscall.Read to read data from connection. In my opinion, after server close connection, client receive fin packet and syscall.read will get EOF. But in this case, syscall.Read get EAGAIN, that means connection is still alive.

```<code>func TestRemoteEOF(t *testing.T) {
  var s server
  require.Nil(t, s.init())

  // dial to server
  var n net.Conn

  // close connection from server
  serverConn := <-s.serverConns
  require.Nil(t, serverConn.Close())

  buf := make([]byte, 100)
  hit := time.Now()
  err2 := checkConnErr(n, buf)
  require.Equal(t, err2, io.EOF)
}
</code>```

I also check with wireshark, the time of hit is later than fin arrive time, so what is the cause of this phenomenon?
enter image description here
enter image description here

Body:
this is my code

Firstly I init a tcp server

type server struct {
    serverConns chan net.Conn
    addr        string
}

func (s *server) init() error {
    s.serverConns = make(chan net.Conn)

    l, err := net.Listen(network, ":8888")
    if err != nil {
        return err
    }
    s.addr = l.Addr().String()
    fmt.Println(s.addr)

    go func() {
        for {
            conn, err := l.Accept()
            if err != nil {
                panic(err)
            }
            s.serverConns <- conn
        }
    }()

    return nil
}

Then I create a tcp connection, and close connection from server. CheckConnErr call syscall.Read to read data from connection. In my opinion, after server close connection, client receive fin packet and syscall.read will get EOF. But in this case, syscall.Read get EAGAIN, that means connection is still alive.

func TestRemoteEOF(t *testing.T) {
  var s server
  require.Nil(t, s.init())

  // dial to server
  var n net.Conn

  // close connection from server
  serverConn := <-s.serverConns
  require.Nil(t, serverConn.Close())

  buf := make([]byte, 100)
  hit := time.Now()
  err2 := checkConnErr(n, buf)
  require.Equal(t, err2, io.EOF)
}

I also check with wireshark, the time of hit is later than fin arrive time, so what is the cause of this phenomenon?
enter image description here
enter image description here


问:
nil pointer evaluating interface {}.name when deploy helm chart
I am new to helm and kubernetes, so I maybe missed something.
I have created a Helm Chart to deploy MISP. Unfortunately, I am now getting the following error.

```<code>Error: INSTALLATION FAILED: template: misp/templates/serviceaccount.yaml:4:11: executing "misp/templates/serviceaccount.yaml" at <include "misp.fullname" .>: error calling include: template: misp/templates/_helpers.tpl:7:40: executing "misp.fullname" at <.Values.misp.name>: nil pointer evaluating interface {}.name
</code>```

My helpers.tpl looks like this:

```<code>{{/*
This is a helper template file that defines the misp.name variable.
*/}}

{{- define "misp.fullname" -}}
{{- printf "%s-%s" .Release.Name .Values.misp.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "misp.name" -}}
misp
{{- end -}}

{{- define "misp-chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "misp-chart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "misp-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "misp-chart.labels" -}}
helm.sh/chart: {{ include "misp-chart.chart" . }}
{{ include "misp-chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "misp-chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "misp-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "misp-chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "misp-chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
</code>```

and my templates/serviceaccount.yaml like this:

```<code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "misp.fullname" . }}
  labels:
    app: {{ include "misp.name" . }}
    chart: {{ include "misp.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
</code>```

And here my values.yaml

```<code># Default values for misp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1

image:
  repository: coolacid/misp
  tag: latest
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 8080

ingress:
  enabled: false
  # Used to create an Ingress record.
  hosts:
    - misp.example.com
  annotations:
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  tls:
    # Secrets must be manually created in the namespace.
    - secretName: misp-tls
      hosts:
        - misp.example.com

database:
  mariadb:
    enabled: true
    image:
      repository: bitnami/mariadb
      tag: 10.3.23-debian-10-r44
      pullPolicy: IfNotPresent
    rootUser:
      password: password
    # databaseName: misp
    # user: misp
    # password: misp

redis:
  enabled: true
  image:
    repository: bitnami/redis
    tag: 6.0.6-debian-10-r0
    pullPolicy: IfNotPresent

resources:
  limits:
    cpu: 100m
    memory: 128Mi
  requests:
    cpu: 100m
    memory: 128Mi

</code>```

Thank you for your help

try to regenerate the files

Body:
I am new to helm and kubernetes, so I maybe missed something.
I have created a Helm Chart to deploy MISP. Unfortunately, I am now getting the following error.

Error: INSTALLATION FAILED: template: misp/templates/serviceaccount.yaml:4:11: executing "misp/templates/serviceaccount.yaml" at <include "misp.fullname" .>: error calling include: template: misp/templates/_helpers.tpl:7:40: executing "misp.fullname" at <.Values.misp.name>: nil pointer evaluating interface {}.name

My helpers.tpl looks like this:

{{/*
This is a helper template file that defines the misp.name variable.
*/}}

{{- define "misp.fullname" -}}
{{- printf "%s-%s" .Release.Name .Values.misp.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "misp.name" -}}
misp
{{- end -}}

{{- define "misp-chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "misp-chart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "misp-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "misp-chart.labels" -}}
helm.sh/chart: {{ include "misp-chart.chart" . }}
{{ include "misp-chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "misp-chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "misp-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "misp-chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "misp-chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

and my templates/serviceaccount.yaml like this:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "misp.fullname" . }}
  labels:
    app: {{ include "misp.name" . }}
    chart: {{ include "misp.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}

And here my values.yaml

# Default values for misp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1

image:
  repository: coolacid/misp
  tag: latest
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 8080

ingress:
  enabled: false
  # Used to create an Ingress record.
  hosts:
    - misp.example.com
  annotations:
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  tls:
    # Secrets must be manually created in the namespace.
    - secretName: misp-tls
      hosts:
        - misp.example.com

database:
  mariadb:
    enabled: true
    image:
      repository: bitnami/mariadb
      tag: 10.3.23-debian-10-r44
      pullPolicy: IfNotPresent
    rootUser:
      password: password
    # databaseName: misp
    # user: misp
    # password: misp

redis:
  enabled: true
  image:
    repository: bitnami/redis
    tag: 6.0.6-debian-10-r0
    pullPolicy: IfNotPresent

resources:
  limits:
    cpu: 100m
    memory: 128Mi
  requests:
    cpu: 100m
    memory: 128Mi

Thank you for your help

try to regenerate the files