Random snippets of all sorts of code, mixed with a selection of help and advice.
WinVerifyTrust is displaying a UI even though the WTD_UI_NONE flag is specified
15 April 2026 @ 11:10 pm
I have a specific file that is signed with a digital signature. The digital signature is valid. If I open the file's properties, I can see the signature is correct. The signtool verify /pa Project1.exe command also succeeds, returning no errors.
I use the following code:
WinTrustData.dwUIChoice := WTD_UI_NONE; // - don't display any UI
WinTrustData.fdwRevocationChecks := WTD_REVOKE_WHOLECHAIN; // also tried WTD_REVOKE_NONE - made no difference
WinTrustData.dwProvFlags := WTD_REVOCATION_CHECK_CHAIN; // also tried WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT - made no difference
WinTrustData.dwUnionChoice := WTD_CHOICE_FILE;
WinTrustData.InfoUnion.pFile := @FileData;
WinVerifyTrust(INVALID_HANDLE_VALUE, WINTRUST_ACTION_GENERIC_VERIFY_V2, WinTrustData);
Calling this code will show a "Security warning" dialog with the following call stack:
How to load a Delphi TService driver early?
15 April 2026 @ 10:53 pm
I am wondering what the best approach is to writing a Delphi service (using the TService class) to load my basic driver that simply writes a message to a file on disk. No network access is needed, or anything advanced.
I am unsure of the StartType setting and LoadGroup name I need to use. AI keeps suggesting a load group of "System Reserved" from a quick search, but I want better real-world advice from developers that have implemented Delphi TService apps that use early loading for executing a driver load.
I use ZwLoadDriver directly, in case this matters, as I don't use the Service Control Manager that is built-in to Windows.
Any suggestions for loading a very basic "Hello world!" driver from an early-started service?
BigQuery: How to replace 0 with NULL in a FLOAT64 column during a SELECT statement?
15 April 2026 @ 10:43 pm
I am trying to clean a dataset in BigQuery where missing entries were uploaded as 0. I want these to be NULL so they don't affect my AVG() calculations.
My attempt:
SELECT
Date,
NULLIF(Sales, 0) AS Sales_Cleaned
FROM `my_project.my_dataset.my_table`
The Issue:
I'm getting an error: No matching signature for function NULLIF for argument types: INT64, FLOAT64. How do I handle this type mismatch?
How do I check if a deviation has a "Created using AI tools" disclaimer with the DeviantArt API?
15 April 2026 @ 9:53 pm
I am trying to use the DeviantArt API to check if a deviation has a "created using AI tools" disclaimer. (Example). I wrote Python code that authorizes and retrieves a deviation's extended metadata, but the response doesn't include the AI notice disclaimer.
Code:
import requests
import os
# Authorize
url = "https://www.deviantart.com/oauth2/token";
params = {
'grant_type': 'client_credentials',
'client_id': os.environ['client_id'],
'client_secret': os.environ['client_secret'],
}
response = requests.get(url, params=params)
access_token = response.json().get("access_token")
# Get deviation metadata
url = 'https://www.deviantart.com/api/v1/oauth2/deviation/metadata'
params = {
Unspecific error for Firebase Data Connect nested SQL inserts
15 April 2026 @ 9:10 pm
I need to insert data in multiple tables at once in my Firebase Data Connect db with native SQL. When calling the mutation from my cloud function it fails and Data Connect will always throw the same Invalid SQL statement error without any further information, making it really difficult to find the cause.
I cannot find documentation on how to debug this Firebase Data Connect error further.
When extracting each insert and testing it by individually calling it from my app sequentially via the standard mutations.gql, everything works, however calling the inserts together in a nested SQL statement from my cloud function does not and I just get the error "Invalid SQL statement", even though the SQL and input data is definitely correct as each insert individually works.
Does anyone else have experience with nested raw SQL inserts in Fire
How can I implement modulo (%) using only addition, multiplication, and comparison on the natural numbers (excluding 0)?
15 April 2026 @ 8:45 pm
I am implementing a Natural class where the natural numbers are defined as {1, 2, 3, ...}, and 0 is deliberately excluded.
For this exercise, subtraction and division are not allowed, because they would take us outside the set of naturals. Only these operations are permitted:
addition
multiplication
comparison (<)
equality
I want to implement the modulo operator (a % b) under these constraints.
Note: In my question as originally posed, I did not account for what happens when we take the mod of a natural with itself. Zero is explicitly not allowed. A comment by user @JaMiT suggests returning from this operation the original value.
Here is the relevant class structure:
class Natural:
"""
The set of natural numbers: {1, 2, 3, ...}.
They are commutative, distributive, and associative under addition
and multiplication.
Subtraction a
How to build artificial dataset for simulation power calculation in simr R for between-within subject deisgn
15 April 2026 @ 8:34 pm
I am running a power calculation in R for a linear mixed model analysis using simr in R. I would like to double-check if I understood correctly how to build my artificial dataset prior to running makeLmer and PowerCurve.
I plan a between-within-subject design. There are 2 groups (A & B). Each person in each group has 2 time points. I built an artificial dataset including time, group, and 1000 IDs. Half IDs are from group A and half IDs from group B. ID is stored as factor.
I run powerCurve along ID to estimate the power for 40, 60, 80, and 100 levels of ID to detect an interaction effect between group and time.
Originally, I structured the data so that all IDs belonging to group A came first, followed by all IDs belonging to group B (See example). When I do so, I obtain a power of 0%. Using Gemini, I understand that this option is wrong because PowerCurve would consider only the ID belonging to one group.
Visual Studio Extension - Cannot Import Any Converters in User Control XAML When Using Metalama
15 April 2026 @ 7:56 pm
In my extension, there is a tool window with a WPF UserControl. For one of the bindings, I am attempting to implement an enum <--> string value converter. I have my converter defined:
and Visual Studio sees it:
However the project won't build. There are no errors after I fully added it, but if I add it then close Visual Studio, delete the hidden .vs folder, as well as the bin & obj folders (based on suggestions I have seen), re-open the solution, do a clean of the solution, and then rebuild the solution, I get a bunch of errors:
If I take out
<converters:EnumToStringConverter x:Key="EnumToStringConverter"></co
and Visual Studio sees it:
However the project won't build. There are no errors after I fully added it, but if I add it then close Visual Studio, delete the hidden .vs folder, as well as the bin & obj folders (based on suggestions I have seen), re-open the solution, do a clean of the solution, and then rebuild the solution, I get a bunch of errors:
If I take out
<converters:EnumToStringConverter x:Key="EnumToStringConverter"></coDelphi, hooking TBitmap.Create & stack trace
15 April 2026 @ 5:43 pm
Posting this because I could not find an answer and code produced by two AIs I queried, would not compile. And when I did get it to compile it crashed at some point.
I needed to hook TBitmap.Create and log the calling function/procedure name. I did not parse the stack dump from madExcept
madExcept and DDetours is required.
I am using Delphi 10.2
Here is code to hook the constructor:
unit Main;
interface
uses
Winapi.Windows,Winapi.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,Vcl.Forms,Vcl.Dialogs,DDetours,Vcl.StdCtrls;
type
TForm2 = class(TForm)
CreateBitmapBtn: TButton;
RemoveHookBtn: TButton;
procedure CreateBitmapBtnClick(Sender: TObject);
procedure RemoveHookBtnClick(Sender: TObject);
private
How to instantiate a connected PowerSyncDatabase by calling a suspend function inside a synchronized block?
15 April 2026 @ 2:50 pm
I'm trying to create a singleton to return an instance of a PowerSyncDatabase.
class OnlineSyncDatabase {
companion object {
// @Volatile
private val instance: PowerSyncDatabase? = null
val dotenv = dotenv()
suspend fun getDatabase(applicationContext: Context): PowerSyncDatabase {
return instance?: synchronized(this) {
val driverFactory = DatabaseDriverFactory(applicationContext)
val supabaseClient = createSupabaseClient(
supabaseUrl = dotenv["SUPABASE_URL"],
supabaseKey = dotenv["SUPABASE_KEY"]
) {
install(Postgrest)
install(Auth)
}
val powerSyncDatabase = PowerSyncDatabase(
factory = driverFactory,
schema = AppSchema,
dbFilename = "powersync.db"