HNHacker News
TopNewBestAskShowJobs

habibur

2,635 karma · joined August 26, 2008

habib@habibur.com
submissionscomments
habibur··on CGI programs have an attractive one step deployment model
It's mostly all nice and fine with CGI until you deploy it on real world and then find that on load spike it's not 500 request / second that you can serve from a given box, rather it falls down to 50 request / second. The numbers are given as example only that will depend on your hardware, but the proportion is the point.

Sure you can find a single-copy-deployment solution with FCGI too like how PHP does it, but one has to feel a need first.

habibur··on Why isn't Bluesky a peer-to-peer network?
> Then you could just say "I'm https://gnod.bsky.social on bluesky"

or simply gnod.bsky.social as https is the default protocol on browsers.

habibur··on Unique 3-word identifiers for every 3 meter square on Earth
A gov agency or a known non-profit org coming up with it would have been better.
habibur··on Boehm-Demers-Weiser conservative C/C++ Garbage Collector
in CPP you don't need GC. Use RAII. Objects only need a constructor, destructor and a copy-constructor for a very efficient reference counting GC that's almost impossible to leak.

In C you can construct your hackish tracing GC yourself. For root objects save the stack address at the beginning of main() by saving the address of a dummy stack variable.

    int dummy=0;
    void* stack_head=&dummy;
and later during GC get the current stack address again and trace from old one to new. You also need to save the registers and can do it in a semi portable way using unix setjmp() longjmp() functions which save the register values into a structure that you can then later trace. There's also the issues of split stack that you need to keep into mind. But the positive thing is memory alignment ensures pointers are all 8 byte aligned, you only need to read address%8 values in between. It's a bit hackish regardless.

I built a few apps using the above technique but now am more comfortable with old styled manual memory management. Valgrind will tell you exactly which line you allocated memory that leaked.

habibur··on Pixar to undergo 20% layoffs in 2024
Everyone waited for end of Christmas/New Year before laying off their own people.
habibur··on Web CGI programs aren't particularly slow these days
CGI as in a command line program lying on the disk, executed on every request and the output sent to browser is dog slow.

Convert this one to fcgi, and it will get as fast as any other solution. In fcgi mode it runs as a service listening to a socket and reads and sends response over it while never terminating.

Even php running on fcgi mode is far faster than the old styled mod_php.

habibur··on Benchmarking 20 programming languages on N-queens and matrix multiplication
I put the pure math codes in C extension of PHP. Building C extension for PHP is easier than most of the other high level languages. And then things get blazingly fast.
habibur··on LLMs and Programming in the first days of 2024
How many of us remember that at the beginning of last year the fear was that programming by programmers will get obsolete by 2024 and LLMs will be doing all the job?

How much has changed?

habibur··on BCHS software stack: BSD, C, httpd, SQLite
In DOM you can add content gradually and asynchronously, which gets harder using HTML template.

Further you can read back previously added contents and make additional chagnes based on those. Like summing up table columns, or adding links to the first column values, or removing or fixing links based on authorization, to name a few.

habibur··on BCHS software stack: BSD, C, httpd, SQLite
Wrote a code parser. Not regexp.

Found the old code on disk, snapshot here. The DOM parser, manipulator and free was 240 LOC.

https://codeshare.io/X8RQxl

habibur··on BCHS software stack: BSD, C, httpd, SQLite
Did something similar. But instead of adding plain-text to HTML output, wrote a DOM parser in C that loads a HTML template and then adds the response into proper place of the DOM tree.
habibur··on X will go to court after failing to pay staff millions in annual bonuses
"verbal" promise and totaling only around $5 million -- in case you were wondering how large the wrongdoing here was.
habibur··on So you want custom allocator support in your C library
The hint in OP's last line, when you are passing around function pointers to allocators, you just need only one standard function interface.

    allocate(void\* ptr, size_t size);

    ptr == NULL : alloc()
    size == 0 : free()
    both ptr and size sent : realloc()
That way it's simpler on the API stage. I prefer to keep it like that in my code.
habibur··on Canadian internet bill S-210 is a step closer to becoming law
I had been following C-18 closely. Wanted it to fail. Facebook/Meta bailed out of the market, deciding to not paying anything. The other one was Google which finally settled for paying $100m per year to a single institution which will divide the money among others.

That's still far less than what Canada was asking. 2% of their yearly revenue which was bumped up to 4% after Meta left. But Google's $100m is more like 0.5% of their yearly gross revenue in Canada.

habibur··on Writing a Compiler is Surprisingly Easy (part 1)
Don't write a compiler for C. Write compilers that convert your sources to C.

You create the header files.

habibur··on Fedora 39 Released
worst two that I found are

- the audio jack doesn't work. Maybe it's because I installed the server installer instead of the client.

- GPIO ports doesn't stay on unless you lock it and keep your program running.

habibur··on Fedora 39 Released
Thanks to the team. Had been waiting for it. Release was delayed several times to fix bugs related to RaspberryPi.
habibur··on Interactive intro to shaders
Unlikely. This is what gets installed and activated by default on Fedora.
habibur··on I2P: End-to-end encrypted and anonymous internet
Microsoft at that time said they are moving Skype to centralized server from distributed to reduce code complexity.
habibur··on Interactive intro to shaders
Chrome / Fedora 38 64 bit / Wayland / Radeon Vega 3 graphics.
habibur··on Interactive intro to shaders
In case anyone else was seeing the images as flickering noise, my fix was to copy the image from the browser and paste those somewhere else. You can view the images correctly.

Link to imgur. The first image is screenshot of what I see in the browser. The rest are actual images after pasting to imgur.

https://imgur.com/a/F4203rz

habibur··on Ask HN: Do tools like Copilot or ChatGPT4 help you code?
I tried to use GPT 3.5 for things I occasionally need

- A vim script.

- CMake configuration file.

- An awk script.

And it had a critical error in every 10 LOC, that I had to fix googling.

Finally not much of the generated code was in the final version.

habibur··on Why is text of sumissions in low-contrast grey on HN?
This was done by Paul Graham himself in this forum's early days.

At that time reddit was rising. PG didn't want to turn this forum one into another Reddit. To discourage posts with body he grayed out the body text. And then within the next few weeks he grayed out the texts gradually even more. Until it reached the point that you see now.

Encouragement was to post interesting links and blogs. But not turn this one into a general discussion forum.

That was may be in the late 2000s. As far as I can recall.

habibur··on Getaddrinfo() on glibc calls getenv(), oh boy
You don't need all the options. Search google. Parsing resolve.conf is an old technique and the file was written assuming individual apps will be parsing it. You will find instructions on how to do it in say 4 lines. Explicitly for this file. Not any random conf file from the system.
habibur··on Getaddrinfo() on glibc calls getenv(), oh boy
Those redirections happen further in the stack. You are ok reading settings from /etc/resolve.conf, which frequently points to a localhost daemon that redirects your calls to whatever DNS setting you have in your connection.

But parsing /etc/resolve.conf and using it is all that you need in your code.

habibur··on Getaddrinfo() on glibc calls getenv(), oh boy
Which is why I have gotten rid of getaddrinfo() calls in my server code, and rather resolve DNS directly reading the DNS server setting from the system.

Other issues I faced :

- Not epoll() friendly. Always forks a process while resolving domain name.

- Valgrind complains of uninitialized memory touches when the function is called and I can't get rid of it.

habibur··on "Hacker News" for retro computing and gaming
The secret to Hacker News is that someone is paying for a full time admin years after years, without displaying 3rd party ads.

Check if you can do that too.

habibur··on Blue Frontier and its energy-efficient AC
Wondering how they plan to dry the salt mixture that's continuously getting wet while the AC runs.
habibur··on My personal C coding style as of late 2023
you can run valgrind and it will just point to you "you freed the memory on this line and then tried to reused it 10 lines bellow here, fix it." -- every time.

And once you fix it, you have built a light weight library that you can use from any other language.

Also these pointer manipulation is what gives C its power.

habibur··on My personal C coding style as of late 2023
In my case :

- I prefer functions over classes.

- no mangling of exported names, the binary is re-usable as API.

- in the long term, the C source code is more re-usable in other projects than C++ ones.

and more like this.

← PreviousPage 3 of 23Next →