Random snippets of all sorts of code, mixed with a selection of help and advice.
Having problem when using parameter as conditional
31 May 2026 @ 10:59 am
I am having problem with a parameter being used as a conditional. It gives me a bit width mismatch, regardless of the DW value being used in the calling routine (either 16'hxxx or 32'hxxx).
I thought DW is a read-only parameter and will be processed at elaborate time. I am not sure what I am missing. I know generate is an alternative, but this example is taken from a rather lengthy code (>1,000 lines of Verilog).
I am using:
Test #(DW) Test
(
.Clock (Clock),
.Reset (Reset),
.Data (Data)
);
module Test
#(parameter DW = 1)
(
input wire Clock,
input wire Reset,
output reg [DW-1: 0] Data
);
always @(posedge Clock)
begin
if (DW == 16)
Data = 16'h0
SUBDIRS and dependencies in makefiles
31 May 2026 @ 8:59 am
I've got a project with directories theme-d-intr, theme-d-intr/base, and theme-d-intr/dbus. File theme-d-intr/Makefile.am consists only of line SUBDIRS = base dbus. Some files in dbus depend on the files generated to base during the build. If I make a parallel build of the code is it possible that the files in dbus are built before the necessary files in base are built? ChatGPT claimed that this is so and suggested the following fixes:
Add the following lines to base/Makefile.am:
BASE_OUTPUTS = \
$(nodist_gintrlib_DATA) \
$(nodist_linkedlib_DATA)
base.stamp: $(BASE_OUTPUTS)
@touch $@
and the following line to dbus/Makefile.am:
dbus_DEPENDENCIES = ../base/base.stamp
Variables nodist_gintrlib_DATA and nodist_linkedlib_DATA in base/Mak
Error sending HTML form data with JavaScript front end through Flask backend to MySQL database
31 May 2026 @ 5:50 am
I get the error "400 (BAD REQUEST)" in the browser (dev tools) console when trying to send HTML form data with JS frontend to MySQL database through a flask back end.
HTML form:
<form id="form" method="POST">
<label> Date ID </label>
<input type="text" id="dateID" name="dateID">
<br>
<label> Day of the Week </label>
<input type="text" id="week_day" name="week_day">
<br>
<label> Day </label>
<input type="date" id="day" name="day">
<br>
<label> Rate </label>
<input type="text" id="rate" name="rate">
<br>
<input type="submit">
</form>
How can I avoid using LLMs as a software developer?
29 May 2026 @ 9:39 pm
Introduction
I've been developing software very successfully for many years. The reason I have chosen this profession is multifold:
I'm a creative person and I need to create things
I have an insatiable drive to think
Financial compensation one may expect for doing this
I can do my thing without constantly socializing with superficial small-talk
The drive to solve real-world problems and to be a force for the better
To work from home
It has been a great ride to do this and I achieved quite a lot of things. Yet, the industry gradually deteriorated. I do know that sometimes libraries and APIs are needed, but I witnessed too many times the drive to use some library only to solve some problem we could have otherwise easily solved, which to me meant that the specific decision was "going with the vibes" rather than a rational choice. Sure thing, there
Can I use the LLVM linker (or related tool) to embed the data from a file into an object file?
29 May 2026 @ 7:09 pm
Using the GNU linker, it is possible to embed the contents of a file into an object file (and eventually, an executable). For example, suppose my input is foo.bin and I want an object file named bar.o; I would write:
ld --format binary --relocatable -o bar.o foo.bin
(discussed in more detail in this question). Is it possible to do this with the LLVM linker? Or a related LLVM tool? If so, how? And if not - is that a real deficiency, or is it just that GNU ld is very "flexible" in what it's willing to do for you?
Note: I'm mainly concerned with GNU/Linux systems, where the executable format is ELF.
Return Json in a web api application
28 May 2026 @ 8:50 pm
I'm using ASP.NET Core Web API which is returning an object including a list. From Postman's results, the list does not get returned.
Here is my code:
[HttpGet]
public IActionResult GetNested()
{
var rv = new RuleViewDTO
{
Id = 3,
Pth = "",
Ttl = "ere",
Lvl = 1,
Sev = "",
ErrMsg = "",
Formulas = {new ViewParam //this list is missing from Postman.
{
RId = 3,
Opd = "",
Opr = "",
Idx =1,
RRId = 2
} }
};
var aq = new JsonResult(rv);
// debug sees RuleViewDTO in full, including Formulas -- one item
// return Ok(rv);
return aq; // same here.breakpoint sees RuleViewDTO and Formulas with one list item
}
Here are the classes:
public class RuleViewDTO
{
How do I do microcontroller programming nicely?
27 February 2026 @ 5:36 am
One person asked me to help with a program for their hobby device on ATTiny2313 which interfaces with PS2 keyboard. A device has been designed around specific microcontroller, Arduino won't fit. I have been programming on C# for more than 5 years but I have education in IT, and C feels plain simple.
That person uses Gromov programmer scheme which feels outdated and unsafe in 2026. Should I purchase special board for programming and debugging ATTiny2313? I have explored programmer boards available on internet - they have USB on one side and some black connector on other side. Should I somehow solder wires to contacts of ATTiny2313 and attach them to that connector? Is there some safe plug-like connector so I won't have to solder wires to contacts of microcontroller, but instead put microcontroller in that connector and solder wires to that connector?
I have downloaded Microchip Studio for that purpose. Do I use gcc compiler or other option?
Adding a inverse relationship to already existing One-To-Many
26 September 2024 @ 10:36 am
My problem is: I already have a One-To-Many relationship. I just didn't implement the reverse property in the Many part, bc I didn't need it at the time. Now I do and here comes the problems.
Those are my two schemas and the respecting models in it (The names are placeholder bc I can't share the real entity names and so on):
actor SchemaV1_0_0: VersionedSchema {
static let versionIdentifier = Schema.Version(1, 1, 0)
static var models: [any PersistentModel.Type] {
[EntityA.self, EntityB.self, SubEntityC.self, User.self]
}
}
actor SchemaV1_1_0: VersionedSchema {
static let versionIdentifier = Schema.Version(1, 1, 0)
static var models: [any PersistentModel.Type] {
[EntityA.self, EntityB.self, SubEntityC.self, User.self]
}
}
extension SchemaV1_0_0 {
@Model
class EntityA: Hashable {
let uuid: UUID = UUID()
var start: EntityB?
var end: EntityB?
@Relation
Firebase and Stripe integration - Stripe doesn't show my metadata on invoice.paid()
1 August 2024 @ 4:20 pm
I am trying to integrate stripe on my SaaS. I have been stuck for the last 3 days trying to send unique userID metadata to stripe. my UUID doesn't show on invoice.paid() hence i can't tell which unique user has made the payment.
const db = admin.firestore();
module.exports = async (req, res) => {
if (req.method === 'POST') {
const { userId, priceId } = req.body;
try {
console.log('Creating session for Firebase UID:', userId);
// Fetch the user from Firestore
const userDoc = await db.collection('users').doc(userId).get();
if (!userDoc.exists) {
return res.status(404).json({ error: 'User not found' });
}
const userData = { uid: userDoc.id, ...userDoc.data() };
// Create a checkout session
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [{ price: priceId, quantity: 1 }],
mode: 'subscription',
success_url: `${req.hea
Building a tree structure from a flat array
7 June 2024 @ 7:46 pm
I have an array of objects. Each contains a "lv" property, which is an integer >= 0.
[
{lv: 0, name: "A"},
{lv: 1, name: "B"},
{lv: 1, name: "C"},
{lv: 2, name: "D"},
{lv: 3, name: "E"},
{lv: 1, name: "F"},
{lv: 0, name: "G"},
]
This is exported from an old software and represents a tree structure: "lv" represents how deep the node is, and its place in the tree is always relative to the previous node in the array. So the first object (A) is level 0 (root); B is level 1, and therefore a child of the previous level 0 entry (A); C is also level 1, and therefore a sibling of B (and also a child of A); and so on. The resulting structure looks like this:
├ A
│ ├ B
│ ├ C
│ │ └ D
│ │ └ E
│ └ F
└ G
I want to write a function to transform this flat array into a structure that would more closely