Why is StreamWriter adding random bytes to a file?

I’m trying to translate a virtual key code with ToAsciiEx() and write it to a debug file. For some reason, the output file contains a load of random trash bytes interspersed with the key codes I want to log. I’m importing ToAsciiEx() like this: [DllImport("user32.dll")] static extern int ToAsciiEx(uint uVirtKey, uint uScanCode, byte[] lpKeyState, [Out]… Read More Why is StreamWriter adding random bytes to a file?

Remove items from one list if they contain strings from another list

I’m looking for the most efficient way to remove items from one list if they contain strings from another list. For example: B list contains: TomWentFishing SueStayedHome JohnGoesToSchool JimPlaysTennis A list contains: GoesToSchool SueStayed C list should contain: TomWentFishing JimPlaysTennis I’ve used this code, but it takes up a lot of time as the lists… Read More Remove items from one list if they contain strings from another list

C# – Can't get this seemingly simple web request working

I have the following powershell Web-Request that works correctly for sending a command to a PTZ camera: Invoke-WebRequest -UseBasicParsing -Uri "http://192.168.111.75/ajaxcom" ` -Method "POST" ` -Headers @{ "Accept"="application/json, text/javascript, */*; q=0.01" "Accept-Encoding"="gzip, deflate" "Accept-Language"="en-US,en;q=0.9" "DNT"="1" "Origin"="http://192.168.111.75" "X-Requested-With"="XMLHttpRequest" } ` -ContentType "application/x-www-form-urlencoded; charset=UTF-8" ` -Body "szCmd=encodedStringHere" I’m trying to recreate this in C# but I can’t… Read More C# – Can't get this seemingly simple web request working

How to remove string pattern and all the string behind?

For example : pattern := "helloworld." myString := "foo.bar.helloworld.qwerty.zxc" func removeFromPattern(p, ms string) { // I confused here (in efficient way) } res := removeFromPattern(pattern, myString) I want to get res = "qwerty.zxc" how do I get qwerty.zxc only, and remove foo.bar.helloworld. from myString using pattern ? >Solution : 1- Using _, after, _ =… Read More How to remove string pattern and all the string behind?

How to make a multipart request from node js to spirng boot

I have a node js backend that needs to send a file to a spring boot application. The file is local uploads/testsheet.xlsx. Here is the code to upload the file using form-data npm module and axios. const formData = new FormData() formData.append("file", fs.createReadStream("uploads/testsheet.xlsx")); formData.append("status", status); const path = `/endpoint` const auth = { username: username,… Read More How to make a multipart request from node js to spirng boot

Why is my QPushButton overlapping the QMenuBar

I have this QMenuBar and I wanted to put a button on the screen and for some reason it just overlaps the menubar…? Here is my code: class LeagueHelperWindow(QMainWindow): def __init__(self) -> None: super().__init__() self.setWindowTitle(‘League Helper’) self.load_saved_settings() self.setup_menu_bar() self.vbox = QVBoxLayout(self) self.setLayout(self.vbox) self.button = QPushButton(‘Test’, self) self.vbox.addWidget(self.button) self.vbox.addStretch() self.setLayout(self.vbox) def setup_menu_bar(self): menu_bar = QMenuBar(self) file_menu… Read More Why is my QPushButton overlapping the QMenuBar

How to store data from reading lines in nodejs

Hello I have external txt file with data to my function. How can I store read line to variable const fs = require("fs"); const readline = require("readline"); const firstVariable; [it is firstLine] const secondVariable; [it is secondLine] const thirdVariable; [it is thirdLine] const fourthVariable; [it is fourthLine] const readInterface = readline.createInterface({ input: fs.createReadStream("./slo1.in"), output: process.stdout,… Read More How to store data from reading lines in nodejs

Matching multiple unicode characters in Golang Regexp

As a simplified example, I want to get ^⬛+$ matched against ⬛⬛⬛ to yield a find match of ⬛⬛⬛. r := regexp.MustCompile("^⬛+$") matches := r.FindString("⬛️⬛️⬛️") fmt.Println(matches) But it doesn’t match successfully even though this would work with regular ASCII characters. I’m guessing there’s something I don’t know about Unicode matching, but I haven’t found any… Read More Matching multiple unicode characters in Golang Regexp