问:
Why i can't connect to gorilla websocket server from front page?
backend code:

```<code>func WsHandler(c *gin.Context) {
    upgrader.CheckOrigin = func(r *http.Request) bool {
        return true
    }
    conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
    if err != nil {
        log.Println(err)
        return
    }
    client := wsserver.Client{
        Id:         wsserver.AutoId(),
        Connection: conn,
        IsConnect:  true,
        MessageCh:  make(chan wsserver.WsMessage),
    }
    global.GD_WS.AddClient(client)
    // defer conn.Close()
    fmt.Println("New Client is connected, total: ", len(global.GD_WS.Clients))
    go handleReciveMsg(client)
    go global.GD_WS.PublishNew(client)

}

</code>```

//router:

```<code>func initWebsocketRouter(Router *gin.RouterGroup) {
    Router.GET("ws",apis.WsHandler)
}
</code>```

the finally router path is:
"/system/ws"

//front page code:

```<code>const wsInit =async()=>{
    const ws = window.WebSocket ? new WebSocket('ws://127.0.0.1:6666/system/ws') : null
    ws.onopen = function () {
        console.log('success!')
        ws.send('startting...')
      }
      ws.onclose = function () {
        console.log('close')
      }
      ws.onerror = function () {
        console.log('error')
      }
      ws.onmessage = function (e) {
        console.log(e.data)
      }
    //
}
wsInit()
</code>```

then i got error:
"WebSocket connection to 'ws://127.0.0.1:6666/system/ws' failed: " with no reason

but in a single nodejs file it works fine,nodejs file code blew:

```<code>var WebSocketClient = require('websocket').client;

var client = new WebSocketClient();

client.on('connectFailed', function(error) {
    console.log('Connect Error: ' + error.toString());
});

client.on('connect', function(connection) {
    connection.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });
    connection.on('close', function() {
        console.log('echo-protocol Connection Closed');
    });
    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log("Received: '" + message.utf8Data + "'");
        }
    });
    connection.send('{"action":"subscribe","topic":"coin"}')
    connection.send('{"action":"subscribe","topic":"gas"}')
});

client.connect('ws://localhost:6666/system/ws');
</code>```

why this happen?

hope someone can help,it alrea confused me two days

Body:
backend code:

func WsHandler(c *gin.Context) {
    upgrader.CheckOrigin = func(r *http.Request) bool {
        return true
    }
    conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
    if err != nil {
        log.Println(err)
        return
    }
    client := wsserver.Client{
        Id:         wsserver.AutoId(),
        Connection: conn,
        IsConnect:  true,
        MessageCh:  make(chan wsserver.WsMessage),
    }
    global.GD_WS.AddClient(client)
    // defer conn.Close()
    fmt.Println("New Client is connected, total: ", len(global.GD_WS.Clients))
    go handleReciveMsg(client)
    go global.GD_WS.PublishNew(client)

}

//router:

func initWebsocketRouter(Router *gin.RouterGroup) {
    Router.GET("ws",apis.WsHandler)
}

the finally router path is:
"/system/ws"

//front page code:

const wsInit =async()=>{
    const ws = window.WebSocket ? new WebSocket('ws://127.0.0.1:6666/system/ws') : null
    ws.onopen = function () {
        console.log('success!')
        ws.send('startting...')
      }
      ws.onclose = function () {
        console.log('close')
      }
      ws.onerror = function () {
        console.log('error')
      }
      ws.onmessage = function (e) {
        console.log(e.data)
      }
    //
}
wsInit()

then i got error:
"WebSocket connection to 'ws://127.0.0.1:6666/system/ws' failed: " with no reason

but in a single nodejs file it works fine,nodejs file code blew:

var WebSocketClient = require('websocket').client;

var client = new WebSocketClient();

client.on('connectFailed', function(error) {
    console.log('Connect Error: ' + error.toString());
});

client.on('connect', function(connection) {
    connection.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });
    connection.on('close', function() {
        console.log('echo-protocol Connection Closed');
    });
    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log("Received: '" + message.utf8Data + "'");
        }
    });
    connection.send('{"action":"subscribe","topic":"coin"}')
    connection.send('{"action":"subscribe","topic":"gas"}')
});

client.connect('ws://localhost:6666/system/ws');

why this happen?

hope someone can help,it alrea confused me two days


来源: stackexchange

问:
compiled typescript code not working with certain package
Whenever i try to compile and run my typescript program I get this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\project\node_modules\pocketbase\dist\pocketbase.es.mjs not supported. Instead change the require of C:\project\node_modules\pocketbase\dist\pocketbase.es.mjs to a dynamic import() which is available in all CommonJS modules.

It is caused by the package not supporting require but the compiled code using require anyways.

my tsconfig.json is attached below:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "es6",
    "strict": false,
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "dist/",
    "baseUrl": "./src/"
  },
  "exclude": [
    "node_modules",
    "./node_modules",
    "./node_modules/*",
    "./node_modules/@types/node/index.d.ts"
  ]
}
```

I have tried changing my tsconfig.json a few times expecting it to fix the issue. But it has not resolved the issue.

ContentLicense: CC BY-SA 4.0

Body:
Whenever i try to compile and run my typescript program I get this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\project\node_modules\pocketbase\dist\pocketbase.es.mjs not supported. Instead change the require of C:\project\node_modules\pocketbase\dist\pocketbase.es.mjs to a dynamic import() which is available in all CommonJS modules.

It is caused by the package not supporting require but the compiled code using require anyways.

my tsconfig.json is attached below:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "es6",
    "strict": false,
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "dist/",
    "baseUrl": "./src/"
  },
  "exclude": [
    "node_modules",
    "./node_modules",
    "./node_modules/*",
    "./node_modules/@types/node/index.d.ts"
  ]
}

I have tried changing my tsconfig.json a few times expecting it to fix the issue. But it has not resolved the issue.


问:
TypeError: str.replace is not a function
I have a problem with my server in digital ocean.
When I run npm run build, I get this error message.

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap
out of memory  1: 0xb09c10 node::Abort()
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  2: 0xa1c193
node::FatalError(char const*, char const*)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  3: 0xcf8dbe
v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  4: 0xcf9137
v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char
const*, bool) [/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]
5: 0xeb09d5  [/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]
6: 0xec069d
v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,
v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  7: 0xec339e
v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int,
v8::internal::AllocationType, v8::internal::AllocationOrigin,
v8::internal::AllocationAlignment)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  8: 0xe84612
v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType,
v8::internal::AllocationAlignment)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]  9: 0xe7cc24
v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int,
v8::internal::AllocationType, v8::internal::Map,
v8::internal::AllocationAlignment)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node] 10: 0xe7ec81
v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int,
v8::internal::AllocationType)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node] 11: 0x121c9e9
v8::internal::Runtime_StringBuilderConcat(int, unsigned long*,
v8::internal::Isolate*)
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node] 12: 0x15f2099
[/home/andifaizal/.nvm/versions/node/v16.15.0/bin/node]

How can I fix this? I use the server ubuntu in digital ocean.


问:
Python to find IQR of grouped data
I have data that comes grouped. For example:

Group.
Count

0-5
3

6-10
2

11-15
7

16-20
5

I want to use Python to find the Quartiles and then the Inter Quartile Range of this data set. Does Pandas or Numpy offer a quick solution to this, or do I do this manually?

I tried reading the docs, but I only found information about non-aggregated data, or how to group raw data. I cannot get this data in a non-grouped format.

Title: Python to find IQR of grouped data


问:
How to make the admin side display and player side display interactive in flutter?
I am developing a Quiz App using flutter framework and firestore as it's database. It allows admin to create rooms and publish quiz in the room. The players need to join the room and wait until the admin clicks on the
"Start Quiz" button situated in the Appbar of admin side display of room. The clicking "Start Quiz", the admin side navigates to a results page(where he could see realtime results) and the player side navigates to questions display where he starts answering question. I am not getting how to implement this.

Admin side room display

Player side room display

These are the code of the two pages

Display_playerSide.dart

```<code>> class PlayerSideDisplay extends StatefulWidget {
  // const PlayerSideDisplay({super.key});
  final String RoomID;
  PlayerSideDisplay({required this.RoomID});

  @override
  State<PlayerSideDisplay> createState() => _PlayerSideDisplayState();
}

class _PlayerSideDisplayState extends State<PlayerSideDisplay> {
  DatabaseService _databaseInstance = new DatabaseService();

  Stream playerstream = Stream.empty();
  Widget playerList() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 24),
      child: StreamBuilder(
          stream: playerstream,
          builder: ((context, AsyncSnapshot snapshot) {
            return snapshot.data == null
                ? Container()
                : ListView.builder(
                    itemCount: snapshot.data!.docs.length,
                    itemBuilder: ((context, index) {
                      return PlayerTile(
                          playerID: snapshot.data!.docs
                              .elementAt(index)
                              .get("player"));
                    }));
          })),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    _databaseInstance.GetPlayers(widget.RoomID).then((value) {
      setState(() {
        playerstream = value;
      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.deepPurple[800],
        title: Text("Players"),
      ),
      body: playerList(),
    );
    ;
  }
}

class PlayerTile extends StatelessWidget {
  // const PlayerTile({super.key});

  final String playerID;
  PlayerTile({required this.playerID});
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration:
          BoxDecoration(border: Border.all(color: Colors.black, width: 3)),
      margin: EdgeInsets.only(bottom: 10, top: 7),
      height: 100,
      child: Stack(
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.network(
              "https://cdn-icons-png.flaticon.com/512/166/166344.png",
              width: MediaQuery.of(context).size.width - 48,
              fit: BoxFit.contain,
              alignment: Alignment.centerLeft,
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "Player ID :$playerID",
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 18,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
</code>```

player_displayAdmin.dart

```<code>> class DisplayPlayers extends StatefulWidget {
  // const DisplayPlayers({super.key});
  final String RoomID;
  DisplayPlayers(this.RoomID);

  @override
  State<DisplayPlayers> createState() => _DisplayPlayersState();
}

class _DisplayPlayersState extends State<DisplayPlayers> {
  DatabaseService _databaseInstance = new DatabaseService();

  Stream playerstream = Stream.empty();
  Widget playerList() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 24),
      child: StreamBuilder(
          stream: playerstream,
          builder: ((context, AsyncSnapshot snapshot) {
            return snapshot.data == null
                ? Container()
                : ListView.builder(
                    itemCount: snapshot.data!.docs.length,
                    itemBuilder: ((context, index) {
                      return PlayerTile(
                          playerID: snapshot.data!.docs
                              .elementAt(index)
                              .get("player"));
                    }));
          })),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    _databaseInstance.GetPlayers(widget.RoomID).then((value) {
      setState(() {
        playerstream = value;
      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.deepPurple[800],
        actions: <Widget>[
          TextButton.icon(
              onPressed: (() {}),
              icon: Icon(Icons.quiz_sharp),
              label: Text("Start Quiz"))
        ],
        title: Text("Players"),
      ),
      body: playerList(),
    );
  }
}

class PlayerTile extends StatelessWidget {
  // const PlayerTile({super.key});

  final String playerID;
  PlayerTile({required this.playerID});
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration:
          BoxDecoration(border: Border.all(color: Colors.black, width: 3)),
      margin: EdgeInsets.only(bottom: 10, top: 7),
      height: 100,
      child: Stack(
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.network(
              "https://cdn-icons-png.flaticon.com/512/166/166344.png",
              width: MediaQuery.of(context).size.width - 48,
              fit: BoxFit.contain,
              alignment: Alignment.centerLeft,
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "Player ID :$playerID",
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 18,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}

</code>```

Body:
I am developing a Quiz App using flutter framework and firestore as it's database. It allows admin to create rooms and publish quiz in the room. The players need to join the room and wait until the admin clicks on the
"Start Quiz" button situated in the Appbar of admin side display of room. The clicking "Start Quiz", the admin side navigates to a results page(where he could see realtime results) and the player side navigates to questions display where he starts answering question. I am not getting how to implement this.

Admin side room display

Player side room display

These are the code of the two pages

Display_playerSide.dart

> class PlayerSideDisplay extends StatefulWidget {
  // const PlayerSideDisplay({super.key});
  final String RoomID;
  PlayerSideDisplay({required this.RoomID});

  @override
  State<PlayerSideDisplay> createState() => _PlayerSideDisplayState();
}

class _PlayerSideDisplayState extends State<PlayerSideDisplay> {
  DatabaseService _databaseInstance = new DatabaseService();

  Stream playerstream = Stream.empty();
  Widget playerList() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 24),
      child: StreamBuilder(
          stream: playerstream,
          builder: ((context, AsyncSnapshot snapshot) {
            return snapshot.data == null
                ? Container()
                : ListView.builder(
                    itemCount: snapshot.data!.docs.length,
                    itemBuilder: ((context, index) {
                      return PlayerTile(
                          playerID: snapshot.data!.docs
                              .elementAt(index)
                              .get("player"));
                    }));
          })),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    _databaseInstance.GetPlayers(widget.RoomID).then((value) {
      setState(() {
        playerstream = value;
      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.deepPurple[800],
        title: Text("Players"),
      ),
      body: playerList(),
    );
    ;
  }
}

class PlayerTile extends StatelessWidget {
  // const PlayerTile({super.key});

  final String playerID;
  PlayerTile({required this.playerID});
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration:
          BoxDecoration(border: Border.all(color: Colors.black, width: 3)),
      margin: EdgeInsets.only(bottom: 10, top: 7),
      height: 100,
      child: Stack(
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.network(
              "https://cdn-icons-png.flaticon.com/512/166/166344.png",
              width: MediaQuery.of(context).size.width - 48,
              fit: BoxFit.contain,
              alignment: Alignment.centerLeft,
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "Player ID :$playerID",
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 18,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}

player_displayAdmin.dart

> class DisplayPlayers extends StatefulWidget {
  // const DisplayPlayers({super.key});
  final String RoomID;
  DisplayPlayers(this.RoomID);

  @override
  State<DisplayPlayers> createState() => _DisplayPlayersState();
}

class _DisplayPlayersState extends State<DisplayPlayers> {
  DatabaseService _databaseInstance = new DatabaseService();

  Stream playerstream = Stream.empty();
  Widget playerList() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 24),
      child: StreamBuilder(
          stream: playerstream,
          builder: ((context, AsyncSnapshot snapshot) {
            return snapshot.data == null
                ? Container()
                : ListView.builder(
                    itemCount: snapshot.data!.docs.length,
                    itemBuilder: ((context, index) {
                      return PlayerTile(
                          playerID: snapshot.data!.docs
                              .elementAt(index)
                              .get("player"));
                    }));
          })),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    _databaseInstance.GetPlayers(widget.RoomID).then((value) {
      setState(() {
        playerstream = value;
      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.deepPurple[800],
        actions: <Widget>[
          TextButton.icon(
              onPressed: (() {}),
              icon: Icon(Icons.quiz_sharp),
              label: Text("Start Quiz"))
        ],
        title: Text("Players"),
      ),
      body: playerList(),
    );
  }
}

class PlayerTile extends StatelessWidget {
  // const PlayerTile({super.key});

  final String playerID;
  PlayerTile({required this.playerID});
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration:
          BoxDecoration(border: Border.all(color: Colors.black, width: 3)),
      margin: EdgeInsets.only(bottom: 10, top: 7),
      height: 100,
      child: Stack(
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.network(
              "https://cdn-icons-png.flaticon.com/512/166/166344.png",
              width: MediaQuery.of(context).size.width - 48,
              fit: BoxFit.contain,
              alignment: Alignment.centerLeft,
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "Player ID :$playerID",
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 18,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}


问:
Custom hook to call Axios POST request and sending from data but response keeps saying product_id is empty
I generally call apis using custom hooks so I'm trying to get a response  from axios POST call and the data needs to be passed as form-data plus it also needs params but for some reason, it keeps showing an error saying product_id is empty because this API works in postman

Custom hook

const useProductDetails = ({ form }: ListProps) => {
  console.log("form:", form);
  const [response, setResponse] = useState<any>(null);
  const [error, setError] = useState("");

  const fetchData = (data?: any) => {
    console.log("data:", data);
    axios({
      method: "POST",
      url: BaseUrl.baseurl + "product_detail",
      data: form ? form : data,
      params: { endpoint: "product_detail" },
      headers: {
        accept: "application/json",
        "Content-Type": "multipart/form-data",
      },
    })
      .then(function (res) {
        if (res) {
          setResponse(res.data);
        }
        console.log("datainside", data);
        console.log("responsedetail", res.data);
      })
      .catch(function (error) {
        console.log("error123", error.response);
        setError(error.response.data.msg);
        console.log("errorcode", error.response.status);
      });
  };

  const callFunc = (data: any) => {
    fetchData(data);
  };

  return { response, error, callFunc };
};
```
<p>Calling Custom hook</p>
<pre class="lang-js prettyprint-override"><code>const { response, error, callFunc } = useProductDetails({
    form: null,
  });

  useEffect(() => {
    callFunc({
      product_id: "3",
    });
  }, []);

  useEffect(() => {
    if (response !== null) {
      setproduct(response.data?.product_detail);
      console.log("responsedet", response);
    }
  }, [response]);`
</code>```

Body:
I generally call apis using custom hooks so I'm trying to get a response  from axios POST call and the data needs to be passed as form-data plus it also needs params but for some reason, it keeps showing an error saying product_id is empty because this API works in postman

Custom hook

const useProductDetails = ({ form }: ListProps) => {
  console.log("form:", form);
  const [response, setResponse] = useState<any>(null);
  const [error, setError] = useState("");

  const fetchData = (data?: any) => {
    console.log("data:", data);
    axios({
      method: "POST",
      url: BaseUrl.baseurl + "product_detail",
      data: form ? form : data,
      params: { endpoint: "product_detail" },
      headers: {
        accept: "application/json",
        "Content-Type": "multipart/form-data",
      },
    })
      .then(function (res) {
        if (res) {
          setResponse(res.data);
        }
        console.log("datainside", data);
        console.log("responsedetail", res.data);
      })
      .catch(function (error) {
        console.log("error123", error.response);
        setError(error.response.data.msg);
        console.log("errorcode", error.response.status);
      });
  };

  const callFunc = (data: any) => {
    fetchData(data);
  };

  return { response, error, callFunc };
};

Calling Custom hook

const { response, error, callFunc } = useProductDetails({
    form: null,
  });

  useEffect(() => {
    callFunc({
      product_id: "3",
    });
  }, []);

  useEffect(() => {
    if (response !== null) {
      setproduct(response.data?.product_detail);
      console.log("responsedet", response);
    }
  }, [response]);`


问:
How to clean the browser cache, each time a new version of the web application is deployed? Only nextjs
It has already been well explained in this section

We cannot clear the user's browser cache due to security issues.

One solution is to set the caching time to zero.
The second solution: We communicate the values of the api version through a header with the Api and based on that the uploads are done.

Other than these two solutions, how can we update the front-end side after providing a new version of the application and not allow the browser to be cached?


问:
Is there any possibility to get optimal number of clusters in Hierarchical clustering without using dendrogram
I have been using KMeans, in which elbow plot is used to get optimal number of clusters. However having a range of numbers to check of optimal clusters number from, it was difficult to visually check each and every time and decide optimal cluster number. I came across Knee Locator python package which helped to resolve this issue and I was able to programmatically get "KNEE" location which returns optimal number of clusters.

Now I am experimenting with Agglomerative Hierarchical clustering (AHC) and I observed that in AHC, the way to get optimal number of clusters is to visualize it in the form of dendrogram and get optimal  number of clusters by visually analyzing dendrogram.

Is there any  way we can get optimal number of clusters for AHC, programmatically without visualizing dendrogram?


问:
Criterion C header not found on macOS
I have the requirement to install Criterion (which is a testing framework for C) on my laptop running macOS. I use Homebrew daily so I thought it will be be easy to just run the brew command:

brew install criterion
```
<p>But, every time I try to run a C file with the criterion header with GCC or CLANG, it just can't find Criterion, although it is installed. (I use the simple sample from the official Criterion repo)</p>
<pre class="lang-c prettyprint-override"><code>#include <criterion/criterion.h>

Test(misc, failing) {
    cr_assert(0);
}

Test(misc, passing) {
    cr_assert(1);
}
</code>```

$ gcc -o test test.c -lcriterion
test.c:1:10: fatal error: 'criterion/criterion.h' file not found
#include <criterion/criterion.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
<pre class="lang-bash prettyprint-override"><code>$ brew install criterion
Warning: criterion 2.4.1_1 is already installed and up-to-date.
To reinstall 2.4.1_1, run:
  brew reinstall criterion
</code>```

I'm struggling with that for almost 2 days and I'm out of ideas...
I even tried to install gcc via Homebrew but it doesn't seem to work either

$ /opt/homebrew/Cellar/gcc/12.2.0/bin/gcc-12 -o test test.c -lcriterion
test.c:1:10: fatal error: criterion/criterion.h: No such file or directory
    1 | #include <criterion/criterion.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```

I use the Apple clang version 14.0.0 for gcc and the homebrew gcc uses gcc 12.2.0. I run a MacBook Air M1 2020 with Ventura 13.1 (22C65)

Title: Criterion C header not found on macOS

Body:
I have the requirement to install Criterion (which is a testing framework for C) on my laptop running macOS. I use Homebrew daily so I thought it will be be easy to just run the brew command:

brew install criterion

But, every time I try to run a C file with the criterion header with GCC or CLANG, it just can't find Criterion, although it is installed. (I use the simple sample from the official Criterion repo)

#include <criterion/criterion.h>

Test(misc, failing) {
    cr_assert(0);
}

Test(misc, passing) {
    cr_assert(1);
}

$ gcc -o test test.c -lcriterion
test.c:1:10: fatal error: 'criterion/criterion.h' file not found
#include <criterion/criterion.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

$ brew install criterion
Warning: criterion 2.4.1_1 is already installed and up-to-date.
To reinstall 2.4.1_1, run:
  brew reinstall criterion

I'm struggling with that for almost 2 days and I'm out of ideas...
I even tried to install gcc via Homebrew but it doesn't seem to work either

$ /opt/homebrew/Cellar/gcc/12.2.0/bin/gcc-12 -o test test.c -lcriterion
test.c:1:10: fatal error: criterion/criterion.h: No such file or directory
    1 | #include <criterion/criterion.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I use the Apple clang version 14.0.0 for gcc and the homebrew gcc uses gcc 12.2.0. I run a MacBook Air M1 2020 with Ventura 13.1 (22C65)


问:
problem with connecting with the serial port in php
I'm trying to send/receive data from my PC to the serial port with the "PhpSerial.php" library. the code works fine when I run it with php CLI php -f test.php. but when I load the php file from the browser it doesn't work and prompts this warning "Warning: Specified serial port is not valid in /opt/lampp/htdocs/examples/PhpSerial.php on line 120".

so How to solve this problem?

I use ubuntu 20.04 and xampp 8.1.2.

```<code> <?php
include "PhpSerial.php";

// Let's start the class
$serial = new PhpSerial;

$serial->deviceSet("/dev/ttyACM0");

// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(115200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

// Then we need to open it
$serial->deviceOpen();

sleep(3);

// To write into
$serial->sendMessage("1");

$serial->deviceClose();
?>
</code>```

The user is added to dailout group.

Body:
I'm trying to send/receive data from my PC to the serial port with the "PhpSerial.php" library. the code works fine when I run it with php CLI php -f test.php. but when I load the php file from the browser it doesn't work and prompts this warning "Warning: Specified serial port is not valid in /opt/lampp/htdocs/examples/PhpSerial.php on line 120".

so How to solve this problem?

I use ubuntu 20.04 and xampp 8.1.2.

 <?php
include "PhpSerial.php";

// Let's start the class
$serial = new PhpSerial;

$serial->deviceSet("/dev/ttyACM0");

// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(115200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

// Then we need to open it
$serial->deviceOpen();

sleep(3);

// To write into
$serial->sendMessage("1");

$serial->deviceClose();
?>

The user is added to dailout group.


问:
Collision blocks not rendering on tilemap
First off, sorry if this is a basic question as I am still pretty new to the Javascript language. I used the 'Tiled' software to develop a Tilemap for a scrolling 2D platformer (this was done following a tutorial). In the tutorial, the collision block appeared on top of the map and was later coded with collision detection between it and the player. The collision blocks, based on "Tiled's" attribution of values, appear when the background.update() function is removed. The blocks however neither scale nor appear on top of the tilemap png. Is it to do with the layering? Is there a form of Z-index for Javascript? There are no errors that appear when inspecting the code that I think would be expected if it was not rendering (e.g. cannot set properties of null due to the function being called before the object appears.)

I tried various methods like changing the order in which the collision blocks and script tags load, changing the Tilemap itself and adding a separate scaling section for the collision block const but all attempts were futile in loading the collision blocks above the image. The tutorial was on the vertical platformer by Chris courses. (I realized halfway through that I mislabeled ConTeXt to cxt instead of ctx but all the code works fine using it.) I have been stuck on this for 2 days and would really appreciate any help.

Specific Section:

Javascript:

```<code>const floorCollisions2D = []

for (let i=0; i<floorCollisions.length; i += 49) {
floorCollisions2D.push(floorCollisions.slice(i, i + 49))
}

const collisionBlocks = []
floorCollisions2D.forEach((row, y) => {
 row.forEach((symbol, x) => {
if(symbol === 4079)
//console.log('draw')
collisionBlocks.push(new CollisionBlock({position: {x: x * 16, y: y * 16},}))
console.log(collisionBlocks)
})
})

function animate() {
 window.requestAnimationFrame(animate)
cxt.fillStyle = 'rgb(255,255,255)'
cxt.fillRect(0, 0, canvas.width, canvas.height)

cxt.save()
cxt.scale(2,2)
cxt.translate(0, -background.image.height + scaledCanvas.height)
background.update()
collisionBlocks.forEach((collisionBlock) => {collisionBlock.update() })
cxt.restore()
</code>```

Classes and Data:

```<code>class Sprite {
  constructor({position, imageSrc}) {
   this.position = position,
   this.image = new Image()
   this.image.src = imageSrc
 }
draw() { if(!this.image) return
cxt.drawImage(this.image, this.position.x, this.position.y)}

update() {
this.draw()

 }
}
</code>```
```<code>class CollisionBlock {
  constructor({position}) {
   this.position = position
   this.width = 16
   this.height = 16

 }
draw() {
cxt.fillStyle = 'rgba(255, 0, 0, 1.0)'
cxt.fillRect(this.position.x, this.position.y, this.width, this.height)

}

update() {
this.draw()

 }
}
</code>```
```<code>const floorCollisions = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            4079, 4079, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
</code>```

HTML:

```<code><!DOCTYPE HTML>

<html>

<style>

#java-paragraph {height:126px; width:1500px; background-color:black; color:rgb(74,246,38); position: relative; top:-15px}

</style>

<canvas id="Canvas"></canvas>

<p id="java-paragraph" contenteditable='true'>This is simply a test paragraph</p>

<script src="CollisionBlock.js"></script>
<script src="Sprite.js"></script>
<script src="Player.js"></script>
<script src="Bug.js"></script>
<script src="Collision.js"></script>
<script src="Lvl-1.js"></script>

<head>
</head>

<body>

</code>```

This is the entire JS, maybe it has something to do with that?

```<code>const canvas = document.querySelector('canvas');
    const cxt = canvas.getContext('2d');
canvas.width=1500;
canvas.height=730;

const scaledCanvas = {width: canvas.width / 2, height: canvas.height / 2}

const floorCollisions2D = []

for (let i=0; i<floorCollisions.length; i += 49) {
floorCollisions2D.push(floorCollisions.slice(i, i + 49))
}

const collisionBlocks = []
floorCollisions2D.forEach((row, y) => {
 row.forEach((symbol, x) => {
if(symbol === 4079)
//console.log('draw')
collisionBlocks.push(new CollisionBlock({position: {x: x * 16, y: y * 16},}))
console.log(collisionBlocks)
})
})

const gravity = 0.2

const player = new Player({
position: {x:0, y:0}, velocity: {x: 0, y: 0}})

const bug = new Bug({
position: {x:1400, y:0}, velocity: {x: 0, y: 0}})

const background = new Sprite({position: {x:0, y:50}, imageSrc: './Images/Level1.png'})

console.log(player)

const keys = {
 a: {pressed: false},
 d: {pressed: false},
 w: {pressed: false}

}

let lastKey

function animate() {
 window.requestAnimationFrame(animate)
cxt.fillStyle = 'rgb(255,255,255)'
cxt.fillRect(0, 0, canvas.width, canvas.height)

cxt.save()
cxt.scale(2,2)
cxt.translate(0, -background.image.height + scaledCanvas.height)
background.update()
collisionBlocks.forEach((collisionBlock) => {collisionBlock.update() })
cxt.restore()

player.update()
bug.update()

player.velocity.x = 0

if (keys.a.pressed && lastKey === 'a') {player.velocity.x = -3 }
else if (keys.d.pressed && lastKey === 'd') {player.velocity.x = 3}
}

animate()

window.addEventListener('keydown', (event) => {
 switch (event.key) {
case 'd':
keys.d.pressed = true
lastKey = 'd'
break
case 'a':
keys.a.pressed = true
lastKey = 'a'
break
case 'w':
if (player.velocity.y == 0) {player.velocity.y=-10}
break
}

 //console.log(event.key)
})

window.addEventListener('keyup', (event) => {
 switch (event.key) {
case 'd':
keys.d.pressed = false
break
case 'a':
keys.a.pressed = false
break
case 'w':
keys.w.pressed = false
break
}

  //console.log(event.key)

})

//document.getElementById('java-paragraph').onclick = function pauseGame() {
   //document.getElementById("Canvas").disabled = false; }

//document.getElementById('Canvas').onclick = function resumeGame() {
 //document.getElementById('java-paragraph').onclick = true;}

//Needs bug fixing later

</code>```

Body:
First off, sorry if this is a basic question as I am still pretty new to the Javascript language. I used the 'Tiled' software to develop a Tilemap for a scrolling 2D platformer (this was done following a tutorial). In the tutorial, the collision block appeared on top of the map and was later coded with collision detection between it and the player. The collision blocks, based on "Tiled's" attribution of values, appear when the background.update() function is removed. The blocks however neither scale nor appear on top of the tilemap png. Is it to do with the layering? Is there a form of Z-index for Javascript? There are no errors that appear when inspecting the code that I think would be expected if it was not rendering (e.g. cannot set properties of null due to the function being called before the object appears.)

I tried various methods like changing the order in which the collision blocks and script tags load, changing the Tilemap itself and adding a separate scaling section for the collision block const but all attempts were futile in loading the collision blocks above the image. The tutorial was on the vertical platformer by Chris courses. (I realized halfway through that I mislabeled ConTeXt to cxt instead of ctx but all the code works fine using it.) I have been stuck on this for 2 days and would really appreciate any help.

Specific Section:

Javascript:

const floorCollisions2D = []

for (let i=0; i<floorCollisions.length; i += 49) {
floorCollisions2D.push(floorCollisions.slice(i, i + 49))
}

const collisionBlocks = []
floorCollisions2D.forEach((row, y) => {
 row.forEach((symbol, x) => {
if(symbol === 4079)
//console.log('draw')
collisionBlocks.push(new CollisionBlock({position: {x: x * 16, y: y * 16},}))
console.log(collisionBlocks)
})
})

function animate() {
 window.requestAnimationFrame(animate)
cxt.fillStyle = 'rgb(255,255,255)'
cxt.fillRect(0, 0, canvas.width, canvas.height)

cxt.save()
cxt.scale(2,2)
cxt.translate(0, -background.image.height + scaledCanvas.height)
background.update()
collisionBlocks.forEach((collisionBlock) => {collisionBlock.update() })
cxt.restore()

Classes and Data:

class Sprite {
  constructor({position, imageSrc}) {
   this.position = position,
   this.image = new Image()
   this.image.src = imageSrc
 }
draw() { if(!this.image) return
cxt.drawImage(this.image, this.position.x, this.position.y)}

update() {
this.draw()

 }
}

class CollisionBlock {
  constructor({position}) {
   this.position = position
   this.width = 16
   this.height = 16

 }
draw() {
cxt.fillStyle = 'rgba(255, 0, 0, 1.0)'
cxt.fillRect(this.position.x, this.position.y, this.width, this.height)

}

update() {
this.draw()

 }
}

const floorCollisions = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            4079, 4079, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 4079, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079, 4079,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

HTML:

<!DOCTYPE HTML>

<canvas id="Canvas"></canvas>

This is simply a test paragraph

This is the entire JS, maybe it has something to do with that?

const canvas = document.querySelector('canvas');
    const cxt = canvas.getContext('2d');
canvas.width=1500;
canvas.height=730;

const scaledCanvas = {width: canvas.width / 2, height: canvas.height / 2}

const floorCollisions2D = []

for (let i=0; i<floorCollisions.length; i += 49) {
floorCollisions2D.push(floorCollisions.slice(i, i + 49))
}

const collisionBlocks = []
floorCollisions2D.forEach((row, y) => {
 row.forEach((symbol, x) => {
if(symbol === 4079)
//console.log('draw')
collisionBlocks.push(new CollisionBlock({position: {x: x * 16, y: y * 16},}))
console.log(collisionBlocks)
})
})

const gravity = 0.2

const player = new Player({
position: {x:0, y:0}, velocity: {x: 0, y: 0}})

const bug = new Bug({
position: {x:1400, y:0}, velocity: {x: 0, y: 0}})

const background = new Sprite({position: {x:0, y:50}, imageSrc: './Images/Level1.png'})

console.log(player)

const keys = {
 a: {pressed: false},
 d: {pressed: false},
 w: {pressed: false}

}

let lastKey

function animate() {
 window.requestAnimationFrame(animate)
cxt.fillStyle = 'rgb(255,255,255)'
cxt.fillRect(0, 0, canvas.width, canvas.height)

cxt.save()
cxt.scale(2,2)
cxt.translate(0, -background.image.height + scaledCanvas.height)
background.update()
collisionBlocks.forEach((collisionBlock) => {collisionBlock.update() })
cxt.restore()

player.update()
bug.update()

player.velocity.x = 0

if (keys.a.pressed && lastKey === 'a') {player.velocity.x = -3 }
else if (keys.d.pressed && lastKey === 'd') {player.velocity.x = 3}
}

animate()

window.addEventListener('keydown', (event) => {
 switch (event.key) {
case 'd':
keys.d.pressed = true
lastKey = 'd'
break
case 'a':
keys.a.pressed = true
lastKey = 'a'
break
case 'w':
if (player.velocity.y == 0) {player.velocity.y=-10}
break
}

 //console.log(event.key)
})

window.addEventListener('keyup', (event) => {
 switch (event.key) {
case 'd':
keys.d.pressed = false
break
case 'a':
keys.a.pressed = false
break
case 'w':
keys.w.pressed = false
break
}

  //console.log(event.key)

})

//document.getElementById('java-paragraph').onclick = function pauseGame() {
   //document.getElementById("Canvas").disabled = false; }

//document.getElementById('Canvas').onclick = function resumeGame() {
 //document.getElementById('java-paragraph').onclick = true;}

//Needs bug fixing later


问:
Attempted import error: 'canUseDOM' is not exported from '@vkontakte/vkjs'
I'm trying to create and run vk app.

```<code>cd c:\projects_vk\
npx @vkontakte/create-vk-mini-app aff3
cd c:\projects_vk\aff3\
npm start
</code>```

I got error:

```<code>Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
</code>```

Than I run:

```<code>npx browserslist@latest --update-db
</code>```

I got message:

```<code>caniuse-lite has been successfully updated
</code>```

Than I tried to start again:

```<code>npm start
</code>```

I got error:

```<code>Starting the development server...
Failed to compile.
./node_modules/@vkontakte/vkui/dist/lib/animate.js
Attempted import error: 'canUseDOM' is not exported from '@vkontakte/vkjs'.
</code>```

OS: Windows 10

Node version: v12.16.3

NPM version: 6.14.4

Body:
I'm trying to create and run vk app.

cd c:\projects_vk\
npx @vkontakte/create-vk-mini-app aff3
cd c:\projects_vk\aff3\
npm start

I got error:

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Than I run:

npx browserslist@latest --update-db

I got message:

caniuse-lite has been successfully updated

Than I tried to start again:

npm start

I got error:

Starting the development server...
Failed to compile.
./node_modules/@vkontakte/vkui/dist/lib/animate.js
Attempted import error: 'canUseDOM' is not exported from '@vkontakte/vkjs'.

OS: Windows 10

Node version: v12.16.3

NPM version: 6.14.4


问:
strategy entry and exit setting
I have a few questions I want to ask. I have a Pine script v5 script, my strategy actually works fine, but there are some problems with them in this position entry and exit. For example, when the long is opened, it should first close the short, then open the long, and do the same in the reverse operation, first to open the short, first close the long and then open the short, I could not achieve this. They told me to write strategy.close before strategy.entry, but that doesn't work in order, sometimes the entry code works first, sometimes the close code works first, the most important thing for me is that close should work first and then entry should work. But in the code that I have mentioned below, even though close start is done, mostly the entry code works first, then the close code comes into play and sometimes the opposite happens.

Thank you for your help.

```<code>longCondition = bull
if long  and (isFirstTrade() or secondTrade) and okToTrade and okToTradeInSession and open_all_longs

    strategy.close(id= 'Short', comment = "Exit SL Short" , alert_message=i_alert_txt_exit_SL_short)
    strategy.entry('Long', strategy.long,  alert_message=i_alert_txt_entry_long, comment = "Long")
    strategy.exit(id='Exit SL Long', comment = "Exit SL Long", from_entry='Long', stop= final_SL_Long , limit = TP2longPrice , alert_message = i_alert_txt_exit_SL_long)

shortCondition = bear
if  short and (isFirstTrade() or secondTrade) and okToTrade and okToTradeInSession and open_all_shorts

    strategy.close(id = 'Long', comment = "Exit SL Long", alert_message=i_alert_txt_exit_SL_long)
    strategy.entry('Short', strategy.short, oca_type = strategy.oca.cancel , alert_message=i_alert_txt_entry_short, comment = "Short")
    strategy.exit(id='Exit SL Short', comment = "Exit SL Short", from_entry='Short', stop=final_SL_Short , limit =TP2shortPrice,  alert_message = i_alert_txt_exit_SL_short)

</code>```

Title: strategy entry and exit setting

Body:
I have a few questions I want to ask. I have a Pine script v5 script, my strategy actually works fine, but there are some problems with them in this position entry and exit. For example, when the long is opened, it should first close the short, then open the long, and do the same in the reverse operation, first to open the short, first close the long and then open the short, I could not achieve this. They told me to write strategy.close before strategy.entry, but that doesn't work in order, sometimes the entry code works first, sometimes the close code works first, the most important thing for me is that close should work first and then entry should work. But in the code that I have mentioned below, even though close start is done, mostly the entry code works first, then the close code comes into play and sometimes the opposite happens.

Thank you for your help.

longCondition = bull
if long  and (isFirstTrade() or secondTrade) and okToTrade and okToTradeInSession and open_all_longs

    strategy.close(id= 'Short', comment = "Exit SL Short" , alert_message=i_alert_txt_exit_SL_short)
    strategy.entry('Long', strategy.long,  alert_message=i_alert_txt_entry_long, comment = "Long")
    strategy.exit(id='Exit SL Long', comment = "Exit SL Long", from_entry='Long', stop= final_SL_Long , limit = TP2longPrice , alert_message = i_alert_txt_exit_SL_long)

shortCondition = bear
if  short and (isFirstTrade() or secondTrade) and okToTrade and okToTradeInSession and open_all_shorts

    strategy.close(id = 'Long', comment = "Exit SL Long", alert_message=i_alert_txt_exit_SL_long)
    strategy.entry('Short', strategy.short, oca_type = strategy.oca.cancel , alert_message=i_alert_txt_entry_short, comment = "Short")
    strategy.exit(id='Exit SL Short', comment = "Exit SL Short", from_entry='Short', stop=final_SL_Short , limit =TP2shortPrice,  alert_message = i_alert_txt_exit_SL_short)


问:
cannot turn on Wi-Fi and hotspot at the same time
I have a Redmi 9 (LAVA) android phone. I'm using custom ROMs and I just upgraded my android 12 custom ROM to android 13. Now I only have one problem. I cannot turn on wifi and hotspot at the same time as before. At first I thought it was because of S vendor firmware, so I reinstall R vendor firmware and after hours of searching I found an android 13 Custom ROM that runs on R vendor firmware. but I still have that problem. Does anyone know how to fix it? In older androids like 12 or 11, I don't have this problem in both customs and stock ROM.

Some of those ROMs that I installed and had this problem:
Project Elixir official build
Pixel Experience official build
LineAge OS unofficial android 13 build that can be installed on R vendor firmware


问:
Error on ajv dependency when trying to build my application
I run into this error when trying to build my app on the ajv dependency

```<code>[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
✖ Compilation failed with errors
\node_modules\ajv\lib\refs\data.json: Missing semicolon. (2:13)
  1 | {
> 2 |     "$schema": "http://json-schema.org/draft-07/schema#",
    |              ^
  3 |     "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
  4 |     "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
  5 |     "type": "object",
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)
</code>```

I have tried using yarn or npm still same issue. Also tried using older versions of ajv and still run into same issue

Body:
I run into this error when trying to build my app on the ajv dependency

[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
✖ Compilation failed with errors
\node_modules\ajv\lib\refs\data.json: Missing semicolon. (2:13)
  1 | {
> 2 |     "$schema": "http://json-schema.org/draft-07/schema#",
    |              ^
  3 |     "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
  4 |     "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
  5 |     "type": "object",
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)

I have tried using yarn or npm still same issue. Also tried using older versions of ajv and still run into same issue


问:
Clip the x axis tick labels in matplotlib
In matplotlib, if the constrained_layout or tight_layout is set to true in the subplot, when we pan the axes the axes are automatically resized to fit the x axis tick labels, but I want them to be clipped without resizing the axes.

This problem can be seen in the matplotlib example provided here

If I run the example, the plot is shown like this.

If I pan to left, the axes are resized to fit the left most xtick label as shown here. The axes are shifter to the right to fully show the xtick label "Jul 2014" (at bottom left). This gives a bad user experience when we pan the chart as it continuously resizes the axes to leave space for the tick labels.

What I want is the tick label to be clipped instead of resizing the plot like this.

I tried to set margins and paddings but they are not helping, I want to use the tight or constrained layout but dont want the resize to happen because of the axis tick labels not fitting. Is there any way to overcome this?


问:
[Error: Operands could not be broadcast together with shapes 285 and 285,39.]
I am a beginner in Machine Learning, I am currently doing this for my thesis application. I am trying to integrate MobilenetV3 with React-Native Expo. I trained my mobilenetv3 following this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/tensorflow-1.14/training.html
inserting mobilenetv3 into the pipeline.config and adjusting steps and batches.

After succesfully training and exporting (from the tutorial), I then converted the exported files using tensorflowjs and tensorflowjs_converter. I followed the tutorial from: https://www.tensorflow.org/js/tutorials/conversion/import_saved_model
I have even tried both tf_frozen_model and tf_saved_model as input, and specified output_node_names. I have successfully converted on both types. I also successfully loaded (as far as I can understand) it when running in the mobile application. The problem is after putting an image in the loaded model it displays this error **[Error: Operands could not be broadcast together with shapes 285 and 285,39.]

code from my file Camera.js:

```<code>    const processImagePrediction = async (base64Image) => {
        const model = await getModel();
        const croppedData = await cropPicture(base64Image);
        setImage(croppedData.uri);
        const tensor = convertBase64ToTensor(croppedData.base64);
        console.log(tensor);
        console.log("Tensor z is: ", tensor._z);
        const output = model.executeAsync(tensor._z).then((output) => {
            console.log("Output is ", output);
        }).catch((Error) => {
            console.log(Error);
        });
</code>```

code from my file Model.js:

```<code>export const  getModel = async () => {
    try {
        // wait until tensorflow is ready
        await tf.ready();
        // load the trained model
        return await tf.loadGraphModel(bundleResourceIO(modelJson, modelWeights));
    } catch (error) {
        console.log("Cannot load model. There has been an error: ", error);
    }
};
</code>```

This is a log of the output:

LOG: {"_A": null, "_x": 0, "_y": 1, "_z": {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}}

LOG: Tensor z is:  {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}

LOG: [Error: Operands could not be broadcast together with shapes 285 and 285,39.]

The output should be properly predicted without error if I'm not mistaken in following tutorials and documentations.

Body:
I am a beginner in Machine Learning, I am currently doing this for my thesis application. I am trying to integrate MobilenetV3 with React-Native Expo. I trained my mobilenetv3 following this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/tensorflow-1.14/training.html
inserting mobilenetv3 into the pipeline.config and adjusting steps and batches.

After succesfully training and exporting (from the tutorial), I then converted the exported files using tensorflowjs and tensorflowjs_converter. I followed the tutorial from: https://www.tensorflow.org/js/tutorials/conversion/import_saved_model
I have even tried both tf_frozen_model and tf_saved_model as input, and specified output_node_names. I have successfully converted on both types. I also successfully loaded (as far as I can understand) it when running in the mobile application. The problem is after putting an image in the loaded model it displays this error **[Error: Operands could not be broadcast together with shapes 285 and 285,39.]

code from my file Camera.js:

    const processImagePrediction = async (base64Image) => {
        const model = await getModel();
        const croppedData = await cropPicture(base64Image);
        setImage(croppedData.uri);
        const tensor = convertBase64ToTensor(croppedData.base64);
        console.log(tensor);
        console.log("Tensor z is: ", tensor._z);
        const output = model.executeAsync(tensor._z).then((output) => {
            console.log("Output is ", output);
        }).catch((Error) => {
            console.log(Error);
        });

code from my file Model.js:

export const  getModel = async () => {
    try {
        // wait until tensorflow is ready
        await tf.ready();
        // load the trained model
        return await tf.loadGraphModel(bundleResourceIO(modelJson, modelWeights));
    } catch (error) {
        console.log("Cannot load model. There has been an error: ", error);
    }
};

This is a log of the output:

LOG: {"_A": null, "_x": 0, "_y": 1, "_z": {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}}

LOG: Tensor z is:  {"dataId": {"id": 283}, "dtype": "int32", "id": 284, "isDisposedInternal": false, "kept": false, "rankType": "4", "scopeId": 0, "shape": [1, 285, 285, 3], "size": 243675, "strides": [243675, 855, 3]}

LOG: [Error: Operands could not be broadcast together with shapes 285 and 285,39.]

The output should be properly predicted without error if I'm not mistaken in following tutorials and documentations.


问:
How to model with django-taggit and django-filters when you need to do AND/OR operations?
```<code>#models.py
class Part(models.Model):
    title = models.CharField(max_length=70, unique=True)
    category = models.IntegerField(choices=PartTypes.choices(), default=PartTypes.DEFAULT)
    pictures = models.CharField(max_length=200)
    tags = TaggableManager()
</code>```
```<code>#filters.py
class Tagfilter(filters.CharFilter):
    field_class = TagField

    def __init__(self, *args, **kwargs):
        kwargs.setdefault('lookup_expr', 'in')
        super().__init__(*args, **kwargs)

class PartFilter(filters.FilterSet):
    category = filters.NumberFilter(field_name='category', lookup_expr='exact')
    tags = Tagfilter(field_name='tags__slug')

    class Meta:
        model = Part
        fields = ['category', 'tags']

</code>```

Currently, my Part model supports different categories let's say car, truck, and suv for simplicity.
Each category basically has a field tags (djang-taggit) that allows me to add any tags I want.

I have a UI where the user can filter based on:

First set of filters: (check boxes)

car

truck

suv

Second set of filters: (check-boxes)

AWD

4x4

FWD

RWD

The expected behavior is that if multiple filters in the same set are checked like (cars, suv) then the request should return cars OR suv only.

However, the issue is when the user selects (cars, suv, and AWD) it currently returns  cars OR suv OR AWD. The expected user experience should be like (cars OR suv) AND (AWD).

I am not sure if I need to redo my models.. or I can somehow fix this issue with the way I implement my filters.

Any suggestions?

Thanks!

Body:
#models.py
class Part(models.Model):
    title = models.CharField(max_length=70, unique=True)
    category = models.IntegerField(choices=PartTypes.choices(), default=PartTypes.DEFAULT)
    pictures = models.CharField(max_length=200)
    tags = TaggableManager()

#filters.py
class Tagfilter(filters.CharFilter):
    field_class = TagField

    def __init__(self, *args, **kwargs):
        kwargs.setdefault('lookup_expr', 'in')
        super().__init__(*args, **kwargs)

class PartFilter(filters.FilterSet):
    category = filters.NumberFilter(field_name='category', lookup_expr='exact')
    tags = Tagfilter(field_name='tags__slug')

    class Meta:
        model = Part
        fields = ['category', 'tags']

Currently, my Part model supports different categories let's say car, truck, and suv for simplicity.
Each category basically has a field tags (djang-taggit) that allows me to add any tags I want.

I have a UI where the user can filter based on:

First set of filters: (check boxes)

car

truck

suv

Second set of filters: (check-boxes)

AWD

4x4

FWD

RWD

The expected behavior is that if multiple filters in the same set are checked like (cars, suv) then the request should return cars OR suv only.

However, the issue is when the user selects (cars, suv, and AWD) it currently returns  cars OR suv OR AWD. The expected user experience should be like (cars OR suv) AND (AWD).

I am not sure if I need to redo my models.. or I can somehow fix this issue with the way I implement my filters.

Any suggestions?

Thanks!


问:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. Build Error
I am currently migrated my old version to latest flutter version. I am getting this issue when i tried to build the android version.

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :gms_check.
     Required by:
         project :app
      > No matching configuration of project :gms_check was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

</code>```

can anyone please help me how to fix this.

Thanks in advance.

Body:
I am currently migrated my old version to latest flutter version. I am getting this issue when i tried to build the android version.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :gms_check.
     Required by:
         project :app
      > No matching configuration of project :gms_check was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

can anyone please help me how to fix this.

Thanks in advance.


问:
How to set default Container size relative to the breakpoint in Chakra UI?
I am exploring Chakra UI in my React project. But I'm unable to figure out how to make the Container size/width relatively limited to the breakpoint by default.

I can set the maxW prop to the Container to stop expanding width. But the problem is, every time I use a Container component, I have to set the maxW every time. I don't want to repeat that. Instead, I want the Container size to be as the breakpoint defined and it will be responsive based on the breakpoint.

How can I do that?

Here is my main.tsx and App.tsx files.

```<code>// main.tsx

import { ChakraProvider, extendTheme } from "@chakra-ui/react";
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";

// Extend theme
const breakpoints = {
    sm: "320px",
    md: "768px",
    lg: "960px",
    xl: "1200px",
    "2xl": "1536px",
};

const theme = extendTheme({ breakpoints });

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
    <React.StrictMode>
        <ChakraProvider theme={theme}>
            <App />
        </ChakraProvider>
    </React.StrictMode>
);

</code>```
```<code>// App.tsx

import { Container } from "@chakra-ui/react";

const App = () => {
    return (
        <Container maxW='8xl'>
            <h1>Hello project</h1>
        </Container>
    );
};

export default App;
</code>```

Body:
I am exploring Chakra UI in my React project. But I'm unable to figure out how to make the Container size/width relatively limited to the breakpoint by default.

I can set the maxW prop to the Container to stop expanding width. But the problem is, every time I use a Container component, I have to set the maxW every time. I don't want to repeat that. Instead, I want the Container size to be as the breakpoint defined and it will be responsive based on the breakpoint.

How can I do that?

Here is my main.tsx and App.tsx files.

// main.tsx

import { ChakraProvider, extendTheme } from "@chakra-ui/react";
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";

// Extend theme
const breakpoints = {
    sm: "320px",
    md: "768px",
    lg: "960px",
    xl: "1200px",
    "2xl": "1536px",
};

const theme = extendTheme({ breakpoints });

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
    <React.StrictMode>
        <ChakraProvider theme={theme}>
            <App />
        </ChakraProvider>
    </React.StrictMode>
);

// App.tsx

import { Container } from "@chakra-ui/react";

const App = () => {
    return (
        <Container maxW='8xl'>

Hello project

        </Container>
    );
};

export default App;


问:
Feature Normalisation
I am trying to predict the score for a single data point having 20+ feature including numerical and categorical features.

I have normalised the training data something like this for training the model:

```<code>#payment_sequential feature
payment_sequential_train = std_scaler.fit_transform(X_train.payment_sequential.values.reshape(-1,1))
payment_sequential_test = std_scaler.transform(X_test.payment_sequential.values.reshape(-1,1))

#payment_installments feature
payment_installments_train = std_scaler.fit_transform(X_train.payment_installments.values.reshape(-1,1))
payment_installments_test = std_scaler.transform(X_test.payment_installments.values.reshape(-1,1))
</code>```

Now I want to predict for a single data point for the web app. I am confused, how can I Normalise all the features?
I understand that I can pickle each scaler. But that seems like a long process as I have 20+ features.

Any leads on how can I get it done?

Thanks in advance.

Title: Feature Normalisation

Body:
I am trying to predict the score for a single data point having 20+ feature including numerical and categorical features.

I have normalised the training data something like this for training the model:

#payment_sequential feature
payment_sequential_train = std_scaler.fit_transform(X_train.payment_sequential.values.reshape(-1,1))
payment_sequential_test = std_scaler.transform(X_test.payment_sequential.values.reshape(-1,1))

#payment_installments feature
payment_installments_train = std_scaler.fit_transform(X_train.payment_installments.values.reshape(-1,1))
payment_installments_test = std_scaler.transform(X_test.payment_installments.values.reshape(-1,1))

Now I want to predict for a single data point for the web app. I am confused, how can I Normalise all the features?
I understand that I can pickle each scaler. But that seems like a long process as I have 20+ features.

Any leads on how can I get it done?

Thanks in advance.


问:
Multi-threaded Client/Socket application gets laggy
I am building Many Clients/One Server console application. I have read and understood why I should use multiple threads and I done so, but when I run application it only works fine for one client, when I try to access server with second client it gets stuck.

Overview:
Server class gets message from client which is read from clients console. This message is parsed and categorized by type.

If client types 'WHOIS' server returns all active client names and the time when they joined the chat!

If client types simple message (anything different from options)
,it will be sent to all of the active clients excluding the sender.

If client types '@client_name(space)message' , message will be sent to specific client provided by client_name variable.

If client types 'LOGOUT', it exits.

If client types 'PINGU', interesting information about penguins will be sent to all of the active clients.

Server

```<code>public class ChatServer {
    private static List<Socket> activeSockets = new ArrayList<>(50);

    public static List<CleverSocket> getCleverSockets() {
        return cleverSockets;
    }

    protected static List<Socket> getActiveSockets() {
        return activeSockets;
    }

    private static List<CleverSocket> cleverSockets = new ArrayList<>(50);

    public static void main(String[] args) throws IOException {
        int port = 3000;
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        }
        ServerSocket server = null;
        try {
            server = new ServerSocket(port);
        } catch (IOException e) {
            server.close();
            throw new RuntimeException(e);
        }
        serverWaitingMsg(port);
        try (Socket socket = server.accept()) {
            var clientProcess = new NonBlockingClient(socket);
            Thread runClient = new Thread(clientProcess);
            runClient.start();

            while (true) {
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    protected static String connectionAccepted(Socket socket) {
        String hostName = socket.getInetAddress().getHostName();
        LocalTime now = LocalTime.now();
        String hostAddress = socket.getInetAddress().getHostAddress();
        String out = (now + " Connection accepted " + hostName + "/" + hostAddress);
        return out;
    }

    protected static void serverWaitingMsg(int port) {
        StringBuilder sb;
        sb = new StringBuilder();
        sb.append(LocalTime.now());
        sb.append(": Server is waiting on port/N ").append(port);
        System.out.println(sb);
    }

    protected static void clientJoinMsg(String clientInput) {
        StringBuilder sb;
        sb = new StringBuilder();
        LocalTime now = LocalTime.now();
        sb.append(now);
        sb.append(": *** ").append(clientInput).append(" has joined the chat room. ***");
        System.out.println(sb);
    }
}

class NonBlockingClient implements Runnable {
    private Socket client;

    public NonBlockingClient(Socket client) {
        this.client = client;
    }

    @Override
    public void run() {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);) {
            //Read client's name
            String clientName = in.readLine();

            //Write that connection accepted!
            out.println(ChatServer.connectionAccepted(client));

            CleverSocket CLS = new CleverSocket(LocalTime.now(), clientName, client);

            ChatServer.getCleverSockets().add(CLS);
            ChatServer.getActiveSockets().add(client);

            //Print that client has joined
            ChatServer.clientJoinMsg(CLS.getName());

            //Now server is till waiting
            ChatServer.serverWaitingMsg(client.getPort());

            while (true) {
                String message = in.readLine();
                String result = parseMessage(message);
                if (result.equals("skip")) out.println("");
                else out.println(result);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String parseMessage(String message) {
        List<CleverSocket> cleverSockets = ChatServer.getCleverSockets();
        StringBuilder sb = new StringBuilder();
        sb.append(("List of all active clients: "));
        if (message.equalsIgnoreCase("whois")) {
            int i = 1;
            for (CleverSocket cs : cleverSockets) {
                sb.append("-" + i + ") " + cs.getName() + " since " + cs.getTime());
                i++;
            }

            return sb.toString();
        }

        if (message.contains("@")) {
            String filtered = message.substring(message.indexOf("@") + 1);
            String clientInfo[] = filtered.split(" ");
            ChatServer.getCleverSockets().forEach((cs) -> {
                if (cs.getName().equals(clientInfo[0])) {
                    String msg = clientInfo[1];
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(cs.getSocket().getOutputStream()), true);
                        out.println(msg);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
            return "skip";
        }

        if (message.equalsIgnoreCase("pingu")) {
            for (CleverSocket cleverSocket : ChatServer.getCleverSockets()) {
                if (cleverSocket.getSocket() != client) {
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(cleverSocket.getSocket().getOutputStream()), true);
                        out.println("Penguin is seabird!");
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }

            return "skip";
        }

        if (message.equalsIgnoreCase("logout")) {
            for (var it = ChatServer.getCleverSockets().iterator(); it.hasNext(); ) {
                CleverSocket tmp = it.next();
                if (tmp.getSocket() == client) {
                    it.remove();
                }
            }

            for (var it = ChatServer.getActiveSockets().iterator(); it.hasNext(); ) {
                var tmp = it.next();
                if (tmp == client) {
                    it.remove();
                }
            }

            return "skip";
        } else {
            ChatServer.getActiveSockets().forEach((as) -> {
                if (as != client) {
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(as.getOutputStream()), true);
                        out.println(message);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });

            return "skip";
        }
    }
}

class CleverSocket {
    private LocalTime time;
    private String name;
    private Socket socket;

    public LocalTime getTime() {
        return time;
    }

    public String getName() {
        return name;
    }

    public Socket getSocket() {
        return socket;
    }

    public CleverSocket(LocalTime time, String name, Socket socket) {
        this.time = time;
        this.name = name;
        this.socket = socket;
    }
}

</code>```

Client

```<code>public class ChatClient {
    public static void main(String[] args) {
        String hostName = "localhost";
        int port = 3000;
        if (args.length > 0) {
            String tmp[] = args[0].split(":");
            hostName = tmp[0];
            port = Integer.parseInt(tmp[1]);
        }
        try (Socket client = new Socket(hostName, port);

             BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);) {

            System.out.println("Enter your username: ");
            out.println(stdIn.readLine());
            System.out.println();
            //connection accepted
            System.out.println(in.readLine());

            welcome();

            String exit = "";
            while (!exit.equalsIgnoreCase("logout")) {
                String clientMsg = stdIn.readLine();
                exit = clientMsg;
                out.println(clientMsg);
                System.out.println();
                System.out.println(in.readLine());
            }
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static void welcome() {
        System.out.println();
        System.out.println("--- Welcome to the chatroom! ---");
        System.out.println("Instructions:");
        String text = """
                1. Simply type the message to broadcast it to all active clients!
                2. Type \"@username<space>message\" without quotes to send message to the specific client
                3. Type \"WHOIS\" without quotes to see list of active clients
                4. Type \"LOGOUT\" (not case sensitive) without quotes to logoff from server
                5. Type \"PINGU\" (not case sensitive) to req/send interesting fact about penguins
                """;
        System.out.println(text);
    }
}
</code>```

I have tried to change design of application, which you can see here,but it still does not work.

Body:
I am building Many Clients/One Server console application. I have read and understood why I should use multiple threads and I done so, but when I run application it only works fine for one client, when I try to access server with second client it gets stuck.

Overview:
Server class gets message from client which is read from clients console. This message is parsed and categorized by type.

If client types 'WHOIS' server returns all active client names and the time when they joined the chat!

If client types simple message (anything different from options)
,it will be sent to all of the active clients excluding the sender.

If client types '@client_name(space)message' , message will be sent to specific client provided by client_name variable.

If client types 'LOGOUT', it exits.

If client types 'PINGU', interesting information about penguins will be sent to all of the active clients.

Server

public class ChatServer {
    private static List<Socket> activeSockets = new ArrayList<>(50);

    public static List<CleverSocket> getCleverSockets() {
        return cleverSockets;
    }

    protected static List<Socket> getActiveSockets() {
        return activeSockets;
    }

    private static List<CleverSocket> cleverSockets = new ArrayList<>(50);

    public static void main(String[] args) throws IOException {
        int port = 3000;
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        }
        ServerSocket server = null;
        try {
            server = new ServerSocket(port);
        } catch (IOException e) {
            server.close();
            throw new RuntimeException(e);
        }
        serverWaitingMsg(port);
        try (Socket socket = server.accept()) {
            var clientProcess = new NonBlockingClient(socket);
            Thread runClient = new Thread(clientProcess);
            runClient.start();

            while (true) {
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    protected static String connectionAccepted(Socket socket) {
        String hostName = socket.getInetAddress().getHostName();
        LocalTime now = LocalTime.now();
        String hostAddress = socket.getInetAddress().getHostAddress();
        String out = (now + " Connection accepted " + hostName + "/" + hostAddress);
        return out;
    }

    protected static void serverWaitingMsg(int port) {
        StringBuilder sb;
        sb = new StringBuilder();
        sb.append(LocalTime.now());
        sb.append(": Server is waiting on port/N ").append(port);
        System.out.println(sb);
    }

    protected static void clientJoinMsg(String clientInput) {
        StringBuilder sb;
        sb = new StringBuilder();
        LocalTime now = LocalTime.now();
        sb.append(now);
        sb.append(": *** ").append(clientInput).append(" has joined the chat room. ***");
        System.out.println(sb);
    }
}

class NonBlockingClient implements Runnable {
    private Socket client;

    public NonBlockingClient(Socket client) {
        this.client = client;
    }

    @Override
    public void run() {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);) {
            //Read client's name
            String clientName = in.readLine();

            //Write that connection accepted!
            out.println(ChatServer.connectionAccepted(client));

            CleverSocket CLS = new CleverSocket(LocalTime.now(), clientName, client);

            ChatServer.getCleverSockets().add(CLS);
            ChatServer.getActiveSockets().add(client);

            //Print that client has joined
            ChatServer.clientJoinMsg(CLS.getName());

            //Now server is till waiting
            ChatServer.serverWaitingMsg(client.getPort());

            while (true) {
                String message = in.readLine();
                String result = parseMessage(message);
                if (result.equals("skip")) out.println("");
                else out.println(result);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String parseMessage(String message) {
        List<CleverSocket> cleverSockets = ChatServer.getCleverSockets();
        StringBuilder sb = new StringBuilder();
        sb.append(("List of all active clients: "));
        if (message.equalsIgnoreCase("whois")) {
            int i = 1;
            for (CleverSocket cs : cleverSockets) {
                sb.append("-" + i + ") " + cs.getName() + " since " + cs.getTime());
                i++;
            }

            return sb.toString();
        }

        if (message.contains("@")) {
            String filtered = message.substring(message.indexOf("@") + 1);
            String clientInfo[] = filtered.split(" ");
            ChatServer.getCleverSockets().forEach((cs) -> {
                if (cs.getName().equals(clientInfo[0])) {
                    String msg = clientInfo[1];
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(cs.getSocket().getOutputStream()), true);
                        out.println(msg);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
            return "skip";
        }

        if (message.equalsIgnoreCase("pingu")) {
            for (CleverSocket cleverSocket : ChatServer.getCleverSockets()) {
                if (cleverSocket.getSocket() != client) {
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(cleverSocket.getSocket().getOutputStream()), true);
                        out.println("Penguin is seabird!");
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }

            return "skip";
        }

        if (message.equalsIgnoreCase("logout")) {
            for (var it = ChatServer.getCleverSockets().iterator(); it.hasNext(); ) {
                CleverSocket tmp = it.next();
                if (tmp.getSocket() == client) {
                    it.remove();
                }
            }

            for (var it = ChatServer.getActiveSockets().iterator(); it.hasNext(); ) {
                var tmp = it.next();
                if (tmp == client) {
                    it.remove();
                }
            }

            return "skip";
        } else {
            ChatServer.getActiveSockets().forEach((as) -> {
                if (as != client) {
                    try {
                        var out = new PrintWriter(new OutputStreamWriter(as.getOutputStream()), true);
                        out.println(message);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });

            return "skip";
        }
    }
}

class CleverSocket {
    private LocalTime time;
    private String name;
    private Socket socket;

    public LocalTime getTime() {
        return time;
    }

    public String getName() {
        return name;
    }

    public Socket getSocket() {
        return socket;
    }

    public CleverSocket(LocalTime time, String name, Socket socket) {
        this.time = time;
        this.name = name;
        this.socket = socket;
    }
}

Client

public class ChatClient {
    public static void main(String[] args) {
        String hostName = "localhost";
        int port = 3000;
        if (args.length > 0) {
            String tmp[] = args[0].split(":");
            hostName = tmp[0];
            port = Integer.parseInt(tmp[1]);
        }
        try (Socket client = new Socket(hostName, port);

             BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);) {

            System.out.println("Enter your username: ");
            out.println(stdIn.readLine());
            System.out.println();
            //connection accepted
            System.out.println(in.readLine());

            welcome();

            String exit = "";
            while (!exit.equalsIgnoreCase("logout")) {
                String clientMsg = stdIn.readLine();
                exit = clientMsg;
                out.println(clientMsg);
                System.out.println();
                System.out.println(in.readLine());
            }
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static void welcome() {
        System.out.println();
        System.out.println("--- Welcome to the chatroom! ---");
        System.out.println("Instructions:");
        String text = """
                1. Simply type the message to broadcast it to all active clients!
                2. Type \"@username<space>message\" without quotes to send message to the specific client
                3. Type \"WHOIS\" without quotes to see list of active clients
                4. Type \"LOGOUT\" (not case sensitive) without quotes to logoff from server
                5. Type \"PINGU\" (not case sensitive) to req/send interesting fact about penguins
                """;
        System.out.println(text);
    }
}

I have tried to change design of application, which you can see here,but it still does not work.


问:
why do cvxpy code using cvxpy.logistic say DCP Error
Why cvxpy said DCP ERROR ?

```<code>import cvxpy as cp

-cp.logistic(-yi*xi.T@beta ) <= s1[i]
</code>```

cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:
The following constraints are not DCP:
-logistic([[ 0.34119207 -1.09868391]] @ var315) <= var318[0] , because the following subexpressions are not:
|--  -logistic([[ 0.34119207 -1.09868391]] @ var315) <= var318[0]
-logistic([[ 1.17921346 -0.94992175]] @ var315) <= var318[1] , because the following subexpressions are not:
|--  -logistic([[ 1.17921346 -0.94992175]] @ var315) <= var318[1]
-logistic([[ 1.55135968 -0.84252651]] @ var315) <= var318[2] , because the following subexpressions are not:
|--  -logistic([[ 1.55135968 -0.84252651]] @ var315) <= var318[2]

I can not understand why cvxpy tell me DCP ERROR.

Body:
Why cvxpy said DCP ERROR ?

import cvxpy as cp

-cp.logistic(-yi*xi.T@beta ) <= s1[i]

cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:
The following constraints are not DCP:
-logistic([[ 0.34119207 -1.09868391]] @ var315) <= var318[0] , because the following subexpressions are not:
|--  -logistic([[ 0.34119207 -1.09868391]] @ var315) <= var318[0]
-logistic([[ 1.17921346 -0.94992175]] @ var315) <= var318[1] , because the following subexpressions are not:
|--  -logistic([[ 1.17921346 -0.94992175]] @ var315) <= var318[1]
-logistic([[ 1.55135968 -0.84252651]] @ var315) <= var318[2] , because the following subexpressions are not:
|--  -logistic([[ 1.55135968 -0.84252651]] @ var315) <= var318[2]

I can not understand why cvxpy tell me DCP ERROR.


问:
configure eclipse server console for wildfly
I've migrated to log4j2.xml and now my application log files are going to another file - application.log instead of server.log.  How do I configure eclipse server console to show the log4j2 log file instead of the default server.log file?</p>


问:
How to undo the selection of a Grid Cell in Flutter?
Ref: How can I select Widgets by dragging over them but also clicking them individually in flutter?

I followed the codebase on this link and I am successful in creating a grid view where on selection the color changes however I am unable to understand the way of undoing it.

Suppose a user selected a cell and now he wants to undo it, then how to do it. Further, I want to save this data in DB through JSON regarding which all cells were selected and how will the grid be.