Random snippets of all sorts of code, mixed with a selection of help and advice.
Django Allauth email verification
30 April 2026 @ 4:07 pm
Im running into an issue with email verification by code with Django Allauth. I've configured my settings to turn on verification by code instead of the regular URL, however I am running into an issue:
ACCOUNT_EMAIL_VERFICATION_BY_CODE requires ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
While I do have the required setting enabled:
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
ACCOUNT_EMAIL_VERIFICATION_BY_CODE_ENABLED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
Has anyone run into this issue before? I've tried turning on the verification for social accounts aswell but this does not resolve the issue.
Reducing significant digits and eliminating scientific notation when float/double approaches zero
30 April 2026 @ 3:49 pm
Surely, a number of ways to reduce rounding error of
1.78814e-07
variable assignment to
0.000000
are at a developer's disposal, but what is best practice?
My best solution is to include a method as such:
#include <cstdlib>
#include <cmath>
float returnZero(float inValue)
{
if(inValue < std::abs(0.000001))
return 0.000000;
else return inValue;
}
However, I'm curious about best practice. I'm not concerned with std out or printf.
Unable to git pull from TFS on some wifi networks. ssh: connect to host tfs port 22: Connection timed out
30 April 2026 @ 3:47 pm
We use TFS for hosting our git repo, and I have a work laptop that I've been using for hybrid work the past two years. I connect it to my home's guest wifi network (to keep it separate from my own devices), with a vpn into the company network required to access tfs. Nothing has changed about my home networking on my end, but after a recent Windows upgrade, I'm now having issues getting git pull/push to work on my home network.
I'm getting the following error:
ssh: connect to host tfs port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I did a little digging and found:
I contacted IT and made sure there are no access locks or expired passwords of any kind on my corporate account. Their recommendations were to "do a wifi reset" (which they did immediately) and "try different wifi networks" (which I did next).
Difference between __const and __const__ extension keywords
30 April 2026 @ 3:42 pm
The GCC and Clang frontends for C, as well as their C++ counterparts, support both __const and __const__ as alternate spellings of the C99 const keyword in all language modes.
What is the difference between the two? If there is no difference, what is the reason that both spellings supported?
How can I set a placeholder (sentinel) without using None?
30 April 2026 @ 1:56 pm
I have a value that always needs to be defined but may not always be meaningful, and I need a placeholder for when it doesn't yet have a meaningful value. Usually, I would use None as that placeholder value:
import ast
user_input = None
while user_input is None:
try:
user_input = ast.literal_eval(input("Enter a Python literal."))
except:
pass
This is one use case, but I've also used this pattern to create placeholders in data structures, to control loops, and in other instances.
However, None is sometimes itself a meaningful value! In the above example, the user should be allowed to input None, but they can't since that won't terminate the while loop. In other cases, they might want to store None in a tree or something similar, so I wouldn't be able to use None to represent missing values.
What should I
Gradle Shared Project with Spring Dependencies and Conventions
30 April 2026 @ 1:22 pm
I'm trying to build a single Gradle project that creates a single JAR file that is deployed to a repository and used by multiple Spring Boot service projects. The project needs to have:
Common library dependencies for all services
Common (minimal) code and configurations
Groovy based conventions configured as plugins
Shared by Spring Boot projects from an Artifactory repository
I've been able to find examples that come close to what I'm looking for, but nothing that 100% fits. I've made the shared library with common libraries and code/configuration, but when I tried to add the Groovy conventions following the "buildSrc" instructions, I was only able to get it to work by building 2 JAR files. I would prefer to have it bundled altogether.
Unfortunately, I'm unable to share what I have, I'm on a different network. I'm mainly hoping for a good example and hopefully, the commands to build and deploy the project.
Populating and passing array between functions in TypeScript
30 April 2026 @ 1:03 pm
I have an object model that has an array as one of its values. I'm trying to populate it but I get an error in my VS Code environment:
Type 'Promise<GenericViewModel[]>' is missing the following properties from type 'GenericViewModel': rating, reportingDate, comments, and 4 more.ts(2740)
I have searched and can't determine how to populate the property correctly. Everything I have seen online says that this is the correct way. I am using Visual Studio Code and building an Angular application.
My function and model are as follows:
async getRawData(){
let pList: PViewModel[] = [];
let criteria = {storedProcedure: 'sp_Get_Data_For_ESM'};
await super.post('universal-sp-pass-thru/spPassThroughnoBody',criteria,'api-eprs');
pList = this.apiPostResponse.data;
const scorecardData: ScorecardModel = {pcorecardModel: []};
// Process each
pList.forEach((p) =&g
Saving GDB tracepoint information into a dump file
30 April 2026 @ 12:47 pm
GDB allows collecting tracepoint information, as a non-intrusive operation, without a need for a breakpoint and a context switch to gdb. The data collected by tracepoints can be viewed, frame-by-frame, within gdb, or dumped to a file using the tsave command.
Trying to open the saved tracepoint file doesn't work well, for both the native file format as well as CTF file format.
It seems that the file cannot be parsed by gdb, or by the Eclipse Compass tracepoints analyzer external tools.
Using the following work-around (as found here) works nicely, running inside the gdb session:
tfind start
while ($trace_frame != -1)
How to shrink size of the expander when collapsing the content and also how to make button interactive when used inside expander in avalonia?
30 April 2026 @ 11:49 am
I am trying to fix issue of the custom expander style that I made in order to fix the height of the expander when user presses button to collapse the expander contents. Here is how I approached it,
In Main Window Application:
<Expander Classes="UIExpander" IsVisible="{Binding HideExpanders}" Background="#66000000" BorderThickness="1" BorderBrush="Black" Margin="0,0,0,10">
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Width="30" Height="30" anim:ImageBehavior.AnimatedSource="avares://project/Assets/Gifs/gifimage.gif" RenderOptions.BitmapInterpolationMode="HighQuality" Margin="5&quo
Is CPU allowed to perform a speculative execution on nullptr branch conditions?
30 April 2026 @ 10:35 am
CPU often performs speculative execution on code branches like
if ( a > b)
And discards the result in case of misprediction.
However let's consider the following:
int* ptr = nullptr;
if (ptr != nullptr) {
std::cout << *ptr << std::endl;
} else {
// do something else
}
Can CPU speculate on such condition? How does it happen? In this case misprediction would result in dereferencing nullptr and UB. Logically that would exclude possibility of discarding wrong result since the program has crashed.
If speculative execution of such branch is allowed, is it always assumes that there is nullptr (to avoid UB) and jumps to else branch? Or it can speculate for both conditions (== nullptr and != nullptr) depending on euristics? If it can speculate on dereferencing nullptr, what are the mechanics allowing CPU to avoid UB?