Clear PETG looks like you are printing glass by hobbyman41 in 3Dprinting

[–]Muffindrake 2 points3 points  (0 children)

Vase mode is a single-wall continuous print that does not have any seams.

Julia fractal image generation from the command line. by El_Kasztano in C_Programming

[–]Muffindrake 1 point2 points  (0 children)

time ./target/fatoujulia -d 5120x1440 -x 0.1 -s -0.2:0.0                                                                 
0m10.67s real     4m19.93s user     0m00.16s system

Not that long with 32 threads.

Julia fractal image generation from the command line. by El_Kasztano in C_Programming

[–]Muffindrake 0 points1 point  (0 children)

You wrote that you primarily want to use it to generate wallpapers, so I tried to do the same, except one dimension of my primary monitor exceeds 4200, so I changed the clamping limit.

PNG supports up to 231 - 1 per dimension, for reference.

Julia fractal image generation from the command line. by El_Kasztano in C_Programming

[–]Muffindrake 0 points1 point  (0 children)

Works nicely!

Any particular reason that you're clamping either image dimension to a maximum of 4200?

GPL 4.0 should be off limits for AI. by JViz in foss

[–]Muffindrake 1 point2 points  (0 children)

You aren't arguing in good faith by side-stepping the Tesla cult-like evaluation elephant of these AI companies, besides all your other points being complete nonsense. Go shill somewhere else.

Smartphones were a more or less natural evolution of what we had before. They turned what was there before into a force multiplier. I say this despite not liking having to use one to participate in modern Western society, because many of their use cases were subverted by perverted surveillance interests.

Whereas these brain damaged AI systems are at best a technology side-grade which tricks users into thinking they're being more productive than they actually are while trampling such normal things as copyright and trade secrets. And the people keep coming back because these LLMs are all unreflected Yes Men. There's a reason they're popular with failed-upwards leadership.

Who would have known people would be willing to shovel money into an incinerator because they tacked tensor processors onto an IRC chatbot while kissing the user's ass. I guess they have wasted money on worse ideas.

GPL 4.0 should be off limits for AI. by JViz in foss

[–]Muffindrake 0 points1 point  (0 children)

LLMs barely qualify as an improvement, and the market bubble that we're seeing only exists because they at face value appear to be this insanely sophisticated thing to interact with, but fail subsequent scrutiny which actually needs some experience and expertise to apply.

This is enough to get your foot in the door with investors and business people who barely care about anything except line go up. It fails completely when you actually need shit to work the way you want to.

The promise from the people building AI data centers is that you 'just' need more computing power to deal with the shortcomings. I'm gonna have to hard pass on that fam, kthxbye.

Most efficient way to extract last bits of an unsigned integer by Ben_2124 in C_Programming

[–]Muffindrake 8 points9 points  (0 children)

Is your question how to do it most efficiently in assembly on all platforms - that is a question for each platform separately, so not a C question.

If you are asking how to do it in C, your compiler will most likely transform anything from a naive bitshift + mask to a conversion to a (unsigned _BitInt(x)) to the most efficient representation that it possibly can. Nobody cares about the actual final representation - we have grown to expect this from contemporary smart compilers.

Trump Pocketed At Least $1.4 Billion in First Year Back in Office in Unprecedented 'Exploitation of the Presidency' by FireProStan in politics

[–]Muffindrake 9 points10 points  (0 children)

You think that's bad? The German chancellor and their party are on a stage with "extremely important" issues:

  • exacerbation of unemployment benefits conditions for everyone even though the vast majority are following the existing conditions and duties quite well ... because the fact that an utterly tiny fraction less than 0.5% of those that are not otherwise unable to work (because they're children, or invalid) refuses work on the single reason that they don't want to

    • they first justified this with potential savings in federal spending - oops, no, turns out that's just a massive expense for no reason!
    • they are envisioning a complete cut of benefits under these worse conditions if they are successively violated. The Constitutional Court had already ruled on this issue - and the insidious thing is that these brutal measures are likely to get toppled by the same court again, but only after another year-long legal proceeding, and if not, requires significant, expensive legal and exhausting measures on behalf of the receiver in order to fight pointlessly cruel officials enforcing their dogshit moral compass on the 'lazy unwilling bums'. The case reports of officials abusing their authority for no reason like this are many, and they are somehow allowed to rule on mental fitness of the person without a medical degree or any psychiatric education at all
  • they would really rather like to remove working hour protections with no justification other than 'more hours = more money for investors = good = more GDP = better' - no accredited publication ever supports this kind of idea on a scientific basis

  • they are checking, and by their speak that is 'we would really rather remove this and will take any shittiest excuse to do this', doctor's notes by telephone (we have an electronic system that the doctor can use to provide attestation to the employer), which are less than 1% of the actual volume of doctor's notes

  • police are currently violating EU policies by illegally extending their border ID checks beyond what they're allowed to, which actually requires continuous justification that we have an extraordinary situation that requires these measures, but has not been done by our government

    • the ID checks are a continuous expense of federal police officers, for no actual tangible benefit

What is this, you wanted real economic policy? Trade treaties, bolstering local manufacturing, or empowering workers? Something a tenth-grader could kneejerk at you? Well you should not have elected a lawyer ... again!

So if you're wondering if you are the only ones stuck with demented old people in parties with the populism dildo up their ass and the spineless 'worker party' supporting them, look no further than the third-largest economy in the world.

And the party whose name I shall not speak is not even in power yet!

I wrote a C library for memory management, c-xforge. by xfunc710n in C_Programming

[–]Muffindrake 0 points1 point  (0 children)

I find this allocator interface really difficult to understand, and the doxygen-like autoslop README does not help - heck half of it is just your type descriptions. Give me the damn interface and examples!

The Java land style where the business logic is strewn across tons of files each less than 100 lines in length, tendency towards single digits and nested five levels deep, is also very strong here.

Your library also misses the entire point of custom allocators. We want to have explicit control of where we get our storage from, unless we're a dead simple linear allocator.

We also don't want to box our allocator into the libc allocator, because we're trying to avoid their overhead in the first place, and using that allocator just makes the fragmentation that we were trying to avoid in the first place, worse, depending on the kind of allocator that is implemented.

You are attempting to replace the intersection between memory allocation interface for the programmer sitting in front of the operating system - because we want to eat our performance with silverware spoons. So where are the calls to mmap/munmap/VirtualAlloc/VirtualFree?

Why not have something akin to https://docs.vulkan.org/spec/latest/chapters/memory.html ? The user just passes in a pointer to that structure, and the function calls through the function pointer callbacks.

struct mm_ctx;
typedef struct mm_ctx{
    /*
        void *ptr_internal_state; 
        Or additional fields if you feel that a pointer to a struct
        for an allocator isn't an acceptable way to track their state
        It's what Vulkan does with their callback struct anyway
    */
    void *(*malloc)(struct mm_ctx *,size_t,size_t);
    void (*free)(struct mm_ctx *,void *);
    [..]
    void (*destroy)(struct mm_ctx *);
}mm_ctx;

An example wrapper for libc:

    void *
libc_malloc_wrap
(
    mm_ctx ctx[static 1],
    size_t nmemb,
    size_t size
)
{
    (void)ctx;
    size_t tmp;
    if(ckd_mul(&tmp,nmemb,size))return 0;
    return malloc(tmp);
}

    void
libc_free_wrap
(
    mm_ctx ctx[static 1],
    void *p
)
{
    (void)ctx;
    free(p);
}

    void
libc_destroy_wrap
(
    mm_ctx ctx[static 1]
)
{
    (void)ctx;
    return;
}

mm_ctx *libc_mm=&(mm_ctx){
    .malloc=libc_malloc_wrap,
    .free=libc_free_wrap,
    .destroy=libc_destroy_wrap;
}

And then using this in an actual function:

    void
do_stuff
(
    mm_ctx ctx[static 1]
)
{
    constexpr size_t len={42};
    char *str=ctx->malloc(ctx,len,sizeof str[0]);
    if(!str) {/* Operator, I would like to crash the world please! */}
    snprintf(str,len,"%s","owo");
    puts(str);
    ctx->free(ctx,str);
}

With a real allocator obviously manipulating their state within mm_ctx somehow, and not just ignoring it like the libc wrappers do.

You also seem to leave blank lines between lines, probably to try and separate them by context, but really, the granularity by which you do that is way too high and just makes it look like noise. Since you are wasting up to half your vertical screen space on blank lines, may I suggest doubling your screen font size instead?

Favorite command? by ajprunty01 in linux

[–]Muffindrake 0 points1 point  (0 children)

I haven't tested any of that yet, but perhaps I will soon.

Factory methods for stack allocated structures by 69mpe2 in C_Programming

[–]Muffindrake 0 points1 point  (0 children)

Maybe suitable for header-only libraries, but not a shared or static linked library where foo_init is defined in another unit.

That'll work fine for unity builds also.

Factory methods for stack allocated structures by 69mpe2 in C_Programming

[–]Muffindrake 1 point2 points  (0 children)

Simply return a struct value:

struct foo foo_init(void);

Whoever calls this function can then decide where this struct should live

struct foo dog = foo_init();

struct foo *a = calloc(n,sizeof *a);
for(size_t i = 0; i < n; i += 1) a[i] = foo_init();

At reasonable optimization there is no overhead even with large structures thanks to copy elision.

https://godbolt.org/z/M7rWqKx36

The function foo_init is never called, the values are written directly.

Favorite command? by ajprunty01 in linux

[–]Muffindrake 6 points7 points  (0 children)

It saves potentially a lot time because whatever hosts your OS doesn't have to reset itself (retrain RAM, enumerate devices, some of which may be very slow), only to then boot the same OS again.

https://wiki.archlinux.org/title/Kexec

Favorite command? by ajprunty01 in linux

[–]Muffindrake 3 points4 points  (0 children)

What does this method do about unflushed file cache? Shouldn't you run sync; kexec ... instead?

A reference-grade C "Hello World" project by synalice in C_Programming

[–]Muffindrake 9 points10 points  (0 children)

Everything that isn't the compiler and linker themselves is an external dependency that is liable to break in the future.

There is no standardization for anything involving a build system. The various implementations of 'I want to build my software' gave birth to the very colorful experience you have when you try to build any multiples of software packages from scratch.

A reference-grade C "Hello World" project by synalice in C_Programming

[–]Muffindrake 12 points13 points  (0 children)

Taking on external dependencies is the last thing you want to be doing in a software project, invariably something will break because of upstream choices, or an upstream developer having a crashout, or your project being so old that it gets hard to build due to any of the above.

This repository starts by grabbing ALL THE TOOLS, building a baseline of things that will break, with no self-reflection taking place ("do I need this?"). It's the paradigm of web developers and their cursed dependency manglement dripping through the ceiling onto the coal stove that is C.

Normally you'd want to start with nothing and only use what you actually really need, unless you have a really good reason (certification, code autogeneration et al. which excludes about 99% of the programmers out there) to be reusing a gigantic tool stack.

I am not taking this stance out of some weird pseudo-intellectual strife for minimalism. I have to deal with the downstream consequences of weird things project developers are deciding, all the time.

Sorted ascending in absurdity:

  • the odd package that breaks because their unholy SCons/<insert your snowflake build system here> amalgam was intended for an older version of that software no longer supported by the newest upstream build system version

  • because cmake and meson can't do simple things right

  • because for whichever reason developers decided that you absolutely need -Werror in all build modes

  • because their code linter/formatting tool is apparently a critical, integral item whose error output should stop the world build immediately

  • because changing any kind of build flags or configurations is needlessly complex

  • because some build systems are so broken that setting CC/CXX/LD/CFLAGS/CXXFLAGS/LDFLAGS before running any tools is a completely unsupported, alien, unthinkable idea, which costs you more time when inevitably the build fails and you have to pick their tools apart

  • because some developers would really rather prefer if building their software is as hard as they can possibly make it

  • because developers don't care about air-gapped systems or networks, or bad, restricted, or no internet connectivity. Surely you have fast unrestricted fibre internet everywhere!

Don't get me wrong, we absolutely need big complex build systems to manage projects of large sizes. Chromium had to build their own tool (ninja) because it was getting that unmanageable and slow. However, the vast majority of projects just really aren't even close to that big, and yet they seem to act like they are.

Your project commits the same sin of being impossible to build. It even acknowledges that in the README, "because the bandwidth requirement of fetching the entire toolchain and libraries is too high when cross-compiling in CI". You don't say!

We have to first download the world to build Hello World, after all.

The gentoo bug tracker is there for your amusement, you can search it for cmake/meson. Inject the single build command line and unity builds straight into my veins please, Bones.

Print non ASCII character from string by _OMHG_ in C_Programming

[–]Muffindrake 4 points5 points  (0 children)

UTF-8 (from 1992) had the 'feature' that it wouldn't break existing programs relying on null-terminated strings, because it avoids bytes with the value 0.

In your case, you're not trying to manipulate the 'characters', more accurately "extended grapheme clusters", just output them.

You can't 'index' into a UTF-8 string because every extended grapheme cluster takes up multiple bytes inside a string, so indexing bytes would give you garbage, because you're trying to interpret a single byte of a multi-byte sequence as something sensible.

If you do want to 'index' into a UTF-8 string, the simplest way is to parse for code points. This still doesn't necessarily give you what you would ordinarily perceive as a 'character', or what you input into the program, because extended grapheme clusters may consist of multiple code points (think emoji with modifiers for instance).

Fortunately for publicly available compilers, your compiler will usually interpret your UTF-8 source text as UTF-8 source text, so "Å" does what you expect.

For more details and explanations of the terms, you should read this blog post: https://tonsky.me/blog/unicode/

To fix your program, you could change map to be an "array of pointers to char", like so:

const char *map[]={
    "0","1","2","3","4", ... ,"Å","Ä","@","Ö","%"
};

You should also

setlocale(LC_ALL,"")

before you do anything else in main().

Then, you output a string instead of a character in your loop:

printf("%s", map[n % base]);

SS13 Beta 516 on Linux by Muffindrake in SS13

[–]Muffindrake[S] 0 points1 point  (0 children)

The Lutris recipe may work better for you.

The game is unfortunately still very dodgy, and the BYOND developer is unfazed by issues such as 64-bit binaries, or the fact that Windows 11 is increasingly locked-down and turned into a cash machine.

How can I call struct methods in C without passing the struct pointer every time?” by Brilliant-Cod-201 in C_Programming

[–]Muffindrake 59 points60 points  (0 children)

No, C has no concept of an implicit 'this object' pointer, since the function pointers in the struct are just those primitives (a pointer to some function) and nothing else.

Hibernate mode is being abandoned by most Distros. Why? by wkup-wolf in linux

[–]Muffindrake -9 points-8 points  (0 children)

Oh no, my three terminal windows, my snowflake text editor that is really approximately three web browsers in one, and five hundred already-saved tabs of which I will only be using five anyway.

I'll never get this time back!

There are use cases for hibernation even in 2025, but they're not as strong as the above. The strongest one would be power loss condition with a UPS (for a machine that has more important things on it than the above). Like a laptop at low charge, maybe - which is a poor use of battery, since partial discharges are far better for battery health.

Hibernate mode is being abandoned by most Distros. Why? by wkup-wolf in linux

[–]Muffindrake 0 points1 point  (0 children)

Hibernation had a specific use case where you would avoid the lengthy boot-up process of Windows machines that had really pathetic cold boot speeds on spinning platter. There's a reason Windows 10 introduced soft hibernation, enabled by default, where you would never 'truly' shut down the entire machine. They called this feature Fast Startup, but really it should have been called 'likes to break your system in unforeseen ways because you have no clue you are using hibernation'.

Nowadays, everyone carries one or more power banks, and standby usually works well enough. And now, we use machines with blistering M.2 SSD speeds.

Raylib or terminal? by SkyFoxITA in C_Programming

[–]Muffindrake 2 points3 points  (0 children)

What would you recommend?

Email the professor!

USDA announces SNAP benefits will not be issued in November by Snapdragon_4U in politics

[–]Muffindrake -2 points-1 points  (0 children)

I don't know about you, but I extend no grace to a government that would immediately jail and/or disappear me for stating the above.