Browsed by
Category: Software Snippets

Noise Cancellation for Remote Communication

Noise Cancellation for Remote Communication

In the wake of the past few years, virtual meetings have changed the way we communicate. However, we have generally embraced remote communication without considering how remote communication differs from the in-person or phone communication we’ve traditionally used. While turning on cameras and speaking face to face gives us more connection, and embracing a slower and more formal discussion style can make the meeting more enjoyable, the most essential communication still happens through audio. As the audio quality we use…

Read More Read More

PreProcessor Overloading

PreProcessor Overloading

While it is simple to overload methods in C++, the preprocessor doesn’t work the same way. To define overloaded methods in the preprocessor, we need to define a method for each number of arguments we want to overload. Option 1: https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments However, this method is not the most portable, and sometimes doesn’t work with MSVC, so a better approach is using the solution from rextester ONP80107. Option 2: However, this solution doesn’t work out of the box on Windows, as…

Read More Read More

Debug Tools

Debug Tools

When working with STL containers, smart pointers, and boost signals, it is nice to debug directly into your own code without making side trips into container internals. These configs also provide custom object views which make debugging easier in MSVC. To Use You need to reference these files from your project or copy them into <user>\Documents\Visual Studio ####\Visualizers. If you copy them, you must copy the files directly, VS will not recognize any files in subfolders. VS will usually detect…

Read More Read More

Invoker

Invoker

Some code, including direct UI updates, needs to run directly on the main application thread. When application code becomes increasingly parallelized, we need a simple, easy pattern to invoke back to the main thread which can be used directly across our applications. The standard way to invoke in MFC would be to create a new WM_USER message and handler for every method which needs to be invoked. This works, but gets very clunky when creating a large number of invokes….

Read More Read More

Leaky Destructors

Leaky Destructors

When dealing with inheritance, it is possible that the destructors for our objects may never be called if the class has virtual functions, but the base class has a non-virtual destructor. This leads to our derived classes being inadvertently leaky as we leak any memory allocated within the derived class. A detailed description of this bug is available in a Microsoft DevBlog writeup available at: C4265, Part 1 C4265, Part 2 Since this error is not always easy to detect…

Read More Read More

SourceTree Password Change

SourceTree Password Change

When updating your repository password, SourceTree doesn’t completely remove the old password. It will continually try both the new and old passwords automatically in the background when trying to authenticate with your repository. To use only your new password, you need to manually remove the old password from: And double check SourceTree’s application settings in:

BiDirectional Pimpl Pattern

BiDirectional Pimpl Pattern

While the Pimpl pattern is commonly used to hide implementation and private methods and variables from public interfaces, the common implementations often require a large amount of boilerplate code. This can make it hard to introduce this pattern into a large existing class. If we use bi-directional friend references with the private implementation, we can easily add a small private implementation into an existing class, allowing for better design patterns and performance optimizations to be gently introduced into existing code….

Read More Read More

SQLite Optimizations: Query Planning

SQLite Optimizations: Query Planning

If a query is running really slowly in SQLite immediately after you have performed a large number of inserts, the query optimizer may be out of sync. If you run the ANALYZE command, SQLite calculate a bunch of statistics about your tables which the query analyzer can then use to optimize further queries. It can be an expensive command to run, but you can more than make up for it with improved query performance afterwards. If you want to check…

Read More Read More

Custom Debug Visualizers

Custom Debug Visualizers

When working with custom data structures, the debugger can show too much information layered through how you’ve constructed it. To make it easier to debug, you can create a custom visualizer which will present only the information you want, to make it easier to debug. Here’s an example of a custom *.natvis file: Let’s look at a few elements here: If you’re using a previous version of Visual Studio, you’ll need to modify your autoexp.dat file to achieve the same…

Read More Read More