201
202
203
 
 

A seemingly simple question which sent me down into the murky depths of standards. How many consecutive hyphens can you have in a domain name? It probably isn't sensible to name your online presence a----------hyphen.com - but is there anything technically stopping you? Table of ContentsHistoryTLD RestrictionsAnomaliesSo What? History Let's do some history! This is 1978's "HOST NAMES…

204
 
 

I found few resources online which may have lead me astray, as I can't get even basic functionality out of LLDB.

I used the dotnet-sos tool to supposedly automatically load SOS into LLDB and I attached LLDB to my program's process, but I am getting errors when trying to use any command:

error: 'bpmd' is not a valid command.
error: 'clrstack' is not a valid command.

Its behaving as if SOS isn't installed, I think? I really don't know what is going on, searching for these errors gives me nothing which is insane, usually there would be GitHub issues or Stack Overflow posts. I think I'm about to never touch C# ever again.

205
 
 

Though I primarily use vim, I got VSCodium so I could use it as a debugger since its much easier to set up. I am having alot of trouble getting any use out of it though, when I run the program the IDE gives me errors if I type in the debug console, and closes the terminal if I type in the integrated terminal. I've changed the config to allow integrated terminal, but nothing has changed.

Can anyone help me figure this out, or recommend an alternative tool for debugging a C# program?

Edit: I finally found my answer: https://discuss.cachyos.org/t/debugging-c-console-apps-on-linux-with-vs-codium-readline-input-not-working/16493

Unfortunately there is no FOSS way to debug a C# application in VSCodium. Might have to see what this lldb tool is.

206
 
 

Delimited flat-file parsing often leads to brittle index-based code. In this post, I show how enums make field positions easier to read and maintain.

In the examples below, we assume the input has already been split:

String[] split = delimitedData.split("\\|");

There are caveats of using the split method this way, but they are outside the scope of this post.

Direct indexing

DbData existingData = dbHandler.getExistingData(
    split[2],
    split[7],
    split[8],
    split[9]
);

Direct indexing is compact, but brittle and hard to scan.

Local variables

String id = split[2];
String date = split[7];
String time = split[8];
String reason = split[9];

DbData existingData = dbHandler.getExistingData(
    id, 
    date, 
    time, 
    reason
);

Local variables improves readability at the call site, but field mappings are still scattered across the code base.

Enum mapping

public enum FlatFileField {
    ID(2),
    DATE(7),
    TIME(8),
    REASON(9);

    private final int index;

    FlatFileField(int index) {
        this.index = index;
    }

    public int index() {
        return index;
    }
}

DbData existingData = dbHandler.getExistingData(
    split[FlatFileField.ID.index()],
    split[FlatFileField.DATE.index()],
    split[FlatFileField.TIME.index()],
    split[FlatFileField.REASON.index()]
);

Comparison

Approach         Pros                                         Cons                                                        
Direct indexing Concise                                     Uses magic numbers, hard to maintain, higher cognitive load
Local variables Readable at call site                       Field mapping still scattered                              
Enum mapping     Centralized field positions, clearer intent Require an additional enum                                  

Takeaway

Enums are a simple way to replace magic numbers with meaningful names when working with delimited data. They improve readability and centralize field positions. When parsing logic grows beyond simple positional access, a dedicated parser or DTO is usually a better choice.

207
Doing nothing at work (www.seangoedecke.com)
 
 

Many engineers should be doing less work. I don’t necessarily mean producing less code or fewer changes, but literally working fewer hours in the day. When they do work, they should be working at a slower pace. I like to aim to be running at 80% utilization by default: unless I have a high-pressure project going on, I spend 20% of my workday away from the computer.

208
209
 
 

Using Kubernetes Event Driver Autoscaling to scale worker pods to 0 based on reading queues or checking APIs. Implemented for Pixelfed, Bookwyrm, and gitea action runners, with the runners scaling up to 4 pods, with examples.

210
 
 

Given how quickly things evolve, it's easy to get lost in the numerous offerings and hard to get the best deal. So, what do you use? Both clients/harnesses and LLM providers or local setups would be interesting.

Personally, I've been using opencode with Github copilot for work. I'm currently looking for cost-effective provider for personal work. Maybe openrouter with one of the cheap models?

211
212
 
 

The text is a bit abstract. Disallowing mutation of values can have a lot of practical advantages, not unlike disallowing global variables. For example, strings and tuples are immutable objects in Python, and this makes it possible that they can be used in dictionaries as keys.

Here is an tutorial/example which shows how changing physical entities can be modeled in this way, with the example of describing a rocket: https://aphyr.com/posts/312-clojure-from-the-ground-up-modeling .

This has a lot in common with how things are described in physics, for example.

213
 
 

I posted this because I think it is really cool: Clojure is a great and extremely elegant language, which has a powerful approach to concurrency: Data is immutable by default, like Python's strings and tuples. (Here more about this idea.)

Because this Clojure dialect runs in the Python bytecode interpreter, it has via its interop features access to all of Python's libraries.

And there is one more advantage, which is less obvious: Python can be extended with native extension modules via a C API. And this does not only allows code written in C and C++ to be called (via boost::python and pybind11), but also code written in Rust - because Rust supports calls via the C ABI, and this can be used in comfortable Python wrappers like PyO3, in the same way as C++ with pybind11. And the concrete advantage of Rust here is that it is a far better match to Clojure's immutability-by-default, and its safe concurrency support.

214
215
 
 

cross-posted from: https://infosec.pub/post/47574072

Hello lemmings, I made a program to ping every IPv4 address and collect data on respondents. I am almost done, but I want feedback on things I should change or how I can improve my current record of 5,000 pings / second.

I am currently aware that I need to properly parse the data I receive on the receive socket, since it's possible the TTL router messages might be confused as replies. ICMP is used on networks to inform other machines of network problems.

One issue I'm aware of is the tuning that has to go into maximizing throughput while also avoiding a total system freeze. My code seems to spend too much time opening sockets that it leaves no room for the actual OS. My only fix currently is limiting the CPU time to the ping timeout I used.

The overall program works like this: It keeps a linked list / pool of task objects. All objects are initially in the "free list" and then when they become associated with a socket, they move to the "active list". The program first checks for updated sockets with epoll which results in like 5% of sockets giving a response. It then closes any tasks that have timed out via linked list in O(1) each. The slow part is when it creates new sockets, since it doesn't really know when to stop, besides when the non-blocking socket informs it that it would block. I implemented a time limit on sending that is currently the maximum of the ping timeout. To increase throughput it seems like I need to streamline how I send ICMP packets.

https://github.com/bneils/PingStorm

216
submitted 1 month ago* (last edited 1 month ago) by to c/programming@programming.dev
 
 

Let's says you want to make a program that takes user input and follows the CRUD structure for some data. This program would be executed from the terminal and wouldn't be used in any other projects.

If this program was made in a language that supports creating packages for other programs (e.g. Python, Rust, NodeJS), should this program be a 'package', or should it be a standalone program that has a simple "setup" script?

Assume this is a CLI/TUI app that runs in a Linux terminal.

EDIT: I'll provide some more details since it seems I was too vague:

This program would allow the user to create 'Script' objects that would be saved to a file on their system. These objects would contain metadata such as a name, the command to run, and a description.

These Script objects would only be used by this program, and by the user. (i.e not a system program)

217
218
219
 
 

I have been thinking of learning some programming recently, but I don't feel confident enough. Is there any point in beginning with something like Zig or Go, and switching to something more serious later?

220
221
222
 
 

nesbot/carbon is a popular date time library for php, included by default in Laravel, for example. It has amassed almost 700 million downloads on packagist.org.

Yesterday, I was looking through the repository, looking for documentation, when I noticed the sponsor section of their readme.

Almost all of the companies listed are betting/gambling sites, some of them specifically made to circumvent for example GamStop, Britain's system where gamblers can block themselves from gambling. One of the sponsor's images links to a TrustPilot profile that has been removed for breaking their guidelines.
Until just now I had not even noticed the "show more" button. I found at least another one with a deleted TrustPilot profile. There's so many more.

I raised an issue about this on their repository, but it just got deleted, not closed.

What the hell is going on here? Why are all these shady companies sponsoring this project? Is the one circumventing GamStop even legal?

image

223
 
 

Dave explains the magic of fopen and the multiple ways it can be used that many programmers do not even know about.

224
225
Gaussian Point Splatting (momentsingraphics.de)
submitted 1 month ago by to c/programming@programming.dev
view more: ‹ prev next ›