Trying to understand why my C++ program is slowing down after running for long time

Advertisements None of the threads close to the topic that I could find (like this one) helped me so far. I have a C++ program that reads some data from a file, runs pretty complex and intensive operations and then writes outputs to new files. When I let the process run for few hours, here… Read More Trying to understand why my C++ program is slowing down after running for long time

Flask render template doesn't render my html page keep getting "internal server error"

Advertisements Running flask 2.1 w/ python 3.10 trying to create a small app here’s my main.py file contents and directory setup from waitress import serve app = Flask(__name__, template_folder=’/templates’) @app.route("/") def startService(): return "Simple Web app" @app.route("/home") def ohok(): return render_template(‘home.html’) if __name__ == "__main__": serve(app, host="127.0.0.1", port=8080) I have my home.html file correctly formatted… Read More Flask render template doesn't render my html page keep getting "internal server error"

Why is StreamWriter adding random bytes to a file?

Advertisements 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,… Read More Why is StreamWriter adding random bytes to a file?

pip and python referring to different interpreters

Advertisements I know "multiple-versions-of-python-mess" is nothing new but my question is more specific. I’m learning how to use venv (and pyenv, etc.) and I’ve run into a strange situation. I have a number of different versions of python installed (as one does). I use one of them, 3.9, to create a venv: $ /usr/local/Cellar/python@3.9/3.9.12_1/bin/python3 -m… Read More pip and python referring to different interpreters

How do I write a JSON file using GSON in the resources folder without using src/main/resources?

Advertisements I’m trying to write a JSON file with GSON in the resources folder without using src/main/resources: package repository; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import org.tinylog.Logger; import java.io.*; import java.util.List; public class GsonRepository<T> extends Repository<T> { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); public GsonRepository(Class<T> elementType) { super(elementType); } public void saveToFile(String resourceName)… Read More How do I write a JSON file using GSON in the resources folder without using src/main/resources?

How do I fix "AttributeError: 'TextChannel' object has no attribute 'news'" in Pycord?

Advertisements I have recently started using Pycord to make a Discord bot. However, I have quickly run into an error that I’m not sure how to deal with. Here is my code: import discord bot = discord.Bot(debug_guilds=[<my guild ID>]) @bot.event async def on_ready(): print(f’Logged in as {bot.user}!’) @bot.event async def on_message(message: discord.Message): print(message) bot.run(‘token’) Here… Read More How do I fix "AttributeError: 'TextChannel' object has no attribute 'news'" in Pycord?

How do I correctly destruct a derived object that was constructed using placement new

Advertisements Say we have a C++ program with this sort of class inheritance: class A { public: virtual ~A() {/* … */} }; class B : public A { public: virtual ~B() {/* … */} }; class C : public A { public: virtual ~C() {/* … */} }; And furthermore, there are specialized memory… Read More How do I correctly destruct a derived object that was constructed using placement new