/tech/ - Technology

Technology & Computing


New Reply
Name
×
Sage
Subject
Message
Files Max 5 files32MB total
Tegaki
Password
[New Reply]


Putin's given us the boot! Read about it here: https://zzzchan.xyz/news.html#66208b6a8fca3aefee4bf211


1504024316530.png
[Hide] (137.5KB, 478x365)
Nobody wants to make the thread edition

See also /agdg/ at >>>/v/ for videogames.

What are you working on?
1_out36.webm
[Hide] (1.1MB, 1000x650, 00:43)
I learned that FFmpeg can record your screen, so I immediately decided to make a screen recorder to replace ShareX. It's so much more convenient to have everything I need pop up and configurable immediately, than going to some settings screen in a menu within a menu within a menu and still not getting the settings I really want, all while various other hotkeys are hijacked by the program.

It records a lossless mp4 at the moment. I wanted to add a way to compress the video after recording, but I'm not sure how to add it into the UI since I'll probably want to configure the format and bitrate anyway. I'll just use a batch script to compress videos for now.

The audio is also very awkward, I have to type the name of the audio device somewhere manually since FFmpeg can't select it on it's own, and I have to enable some recorder device in my audio settings. I'm pretty sure other programs like OBS can just record whatever comes out of the speakers, but I don't know how to do that.
I could just query audio devices with FFmpeg and then pick a random one or give a dropdown selector with all the options, but it would still require you to have a recording device enabled in your audio settings.
Replies: >>8956 >>8967
>>8955
Here's also the ffmpeg command in case anyone is curious:
ffmpeg -y   -f dshow -i audio="Stereo Mix (ASUS Essence STX II"   -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 600x400 -i desktop   -c:v libx264rgb -preset ultrafast -qp 0   -c:a libopus -b:a 320k   "output.mp4"
The audio="" is where you need to put your audio device, which you can query with this command:
ffmpeg   -hide_banner   -f dshow -list_devices true   -i dummy

On Linux you need to use something other than "dshow".
Replies: >>8957
>>8956
Oh and the recording is stopped by typing "q" into the ffmpeg command line.
Just learning C for now, and I'm getting much farther than I ever have previously in my life trying to do this. I'll learn Vulkan immediately after so I can try my hand at a "game engine" (Which might also be useful for 3D animation, who knows?).
Replies: >>8974
>>8955
Finished it for the most part and uploaded it here:
https://sundee.neocities.org/regioncap/index.html
You'll have to manually compress recorded videos afterwards.
>>8958
>'ll learn Vulkan immediately after so I can try my hand at a "game engine"
It's going to take years of programming and math study before you can write a game engine.
Replies: >>8976
>>8974
A game engine, no.
A good game engine, yes.
Replies: >>8977
>>8976
1) I have all the time in the world to study (I tried starting out in the morning about a week ago and was able to study for about 10 hours that day)
2) I mainly want to do it because its fun

If I can get moneys on some decently reliable donation platform or something for FOSSing my code that's just a cherry on top.
Replies: >>8988
thumbscat.jpg
[Hide] (14.2KB, 180x192)
>>8977
Good luck with your programming and programming studies anon. I'm also a NEET programmer.
>do subpixel font rendering
>can barely tell a difference
>it's 9-30x slower
Well that was disappointing. 4 different size comparisons, subpixel renderer on top, cached glyph sprites on bottom.
Replies: >>9011 >>9015
fonts.png
[Hide] (103.4KB, 878x568)
>>9010
Forgot image.
Replies: >>9012 >>9013
subpixel_font_rendering.png
[Hide] (11.1KB, 2012x120)
>>9011
You'd see some rainbow colors in the zoomed in versions if that was subpixel font rendering.
Replies: >>9013
>>9011
Realized that I forgot to do proper alpha blending (which is why one of them seemed brighter), that made it slightly faster (the difference doesn't go above 20x anymore). I guess it's because my blending function has a much faster branch for fully transparent and fully opaque pixels.

>>9012
I mean subpixel positioning, so the glyph starting point isn't aligned to pixels.
>>9010
How is the initial rendering done? I just thought of this quickly, but if this isn't being done already would it potentially be faster and better looking?
>Assess screen size, scale, window dimensions, etc.
>Select closest size of the chosen font available to the rendered size ("A" of font X has (clean) sizes 1, 2, 4, 8, etc... A scale approximately 6.5 times larger than size 1 would select size 8 and scale it downwards)
>Cache the font approximation for speed (You could have 1000+ extremely high quality sizes of font Xs character set due to how cheap storage is nowadays...)
>Insert characters according to the arrangement of the text
>Combine characters together into one massive, static texture that only needs to be translated whenever a page is moved rather than rendered frame-by-frame game-engine style (Think of my entire posts body as being one single image with interactivity imposed on top of it like buttons (cursor "collision"? (If that's the right term to use here)), text "highlighting", etc.)
As far as I know, browsers render game engine style with each frame independent of one another, right?
table.png
[Hide] (8.5KB, 609x145)
Any better ideas for formatting tables? This looks super ugly and clumsy.

I was going to separate cells with simply ||| or something, but the problem is that you need to be able to turn some cells into header cells.
Replies: >>9231 >>9233
>>9230
Markdown already solved that problem. Use markdown syntax.
Replies: >>9232
>>9231
Markdown is shit and gay and also retarded.
Replies: >>9306
table2.png
[Hide] (10.3KB, 604x242)
>>9230
I realized that the closing tag is unnecessary since you can't put cells or rows inside cells anyway. This makes it a bit more streamlined. Not sure which one of these is better though.
>>9232
Even if it was it's still a million times better than HTML.
What do I do when someone has assert() braindamage?
Replies: >>9319
>>9314
>assert() braindamage
What do you mean?
Replies: >>9320
>>9319
Nigger is out there writing functions that take an int and it has to be >= 0 so he calls assert(n >= 0), or he writes a function that takes a pointer and puts in assert(p != NULL), or he writes a struct and a set of functions to operate on it and asserts all the members.
 
He doesn't understand that either his checks either do nothing and shouldn't be there or the check should be in the release build, and that he's polluting the source code with a billion redundant checks in every callee instead of checking for bad values once where they are acquired. We already had a bug where someone else who also has assert() brain damage was not checking the return value of malloc() and assert()ing it instead.
Replies: >>9321
>>9320
assert() your dominance by slapping that bitch until he gets the message.
vs.png
[Hide] (14.8KB, 210x613)
I'm not sure if this counts as software but I made an ebin prompt generator. Probably the smallest program I've ever made not counting tests.
Replies: >>9590
>>9586
It outputs "<word> vs <word>"?
Replies: >>9625
Screenshot_2023-04-26_02-57-54.png
[Hide] (2.2KB, 579x611)
oh yeah check this scrub
int l=24;for(int i=l;i>0;i--){for(int j=0;j<i+l;j++)putchar(' ');for(int j=i;j<l*2-1-i;j++)putchar('=');putchar('\n');}for(int i=l;i>0;i--){for(int j=0;j<i;j++)putchar(' ');for(int j=i;j<l*2-1-i;j++)putchar('=');for(int j=0;j<i;j++)putchar(' ');for(int j=0;j<i;j++)putchar(' ');for(int j=i;j<l*2-1-i;j++)putchar('=');putchar('\n');}
Replies: >>9592
triforce.png
[Hide] (10.9KB, 942x1058)
>>9591
Impressive.
.jpg
[Hide] (67KB, 474x598)
>>9590
Yes.
ClipboardImage.png
[Hide] (59.2KB, 512x524)
Thoughts on Janet? Nice syntax and easy to deploy into a C/C++ project (only a pair of .c/.h files). It's been getting some traction on HN but I'm yet to try it.
https://janet-lang.org/
Replies: >>9678
>>9671
Post your program fag.
Is there any way to make Windows tell me why it's fucking closing my program? There's clearly a crash but it won't tell me why it crashes. GDB tells me jack shit either. Would SOMEBODY FUCKING TELL ME WHY IT'S BEING CLOSED? It's so fucking simple.

I'm setting SetUnhandledExceptionFilter but it's fucking doing nothing. I tested dereferencing an invalid pointer and that shit works, but the crash I'm trying to debug does not. Literally nobody is willing to tell me why my program is crashing and being closed.
Replies: >>9716 >>9726
>>9710
What sort of program are you trying to run?
Replies: >>9718
/tech/, you're invited to our C++ class open to everyone starting this coming Saturday. It's aimed at beginners, but we'll be digging into the more advanced stuff eventually as well. Cheers.
https://alogs.space/robowaifu/res/19777.html#19777
Replies: >>9723
>>9716
Why don't you think about it.
Screenshot_2023-05-01_19-17-37.png
[Hide] (30.8KB, 174x206)
>>9717
>cblawsblaws
crime of the century, c literally takes 15m to learn its only difficult for people whove filled their tiny heads with abstract junk like blawsblaws
Replies: >>9725
>>9723
C++ niggas don't even know what 1+1 is because + could be overloaded
Replies: >>9728
>>9710
Are you accessing the Windows system over a remote shell?
You get a graphical window showing the error when Windows kills your program, or the loader throws an error, and so on. There won't be anything in the command line.
Replies: >>9731
>>9725
>C++ niggas don't even know what 1+1 is because + could be overloaded
No, you cannot overload an operator where the only arguments are built-in types. 1 is a built-in type (int).
Replies: >>9729
>>9728
iostream uses the bitshift for overloading with builtin types, 
(char)'#' << (int)1 (which is fucking (char)'F') is for some retarded reason (char[2])"#1"
Replies: >>9730
>>9729
That's perfectly fine, since it's part of the standard, and up to each compiler implementor how they want to do the standard. The point is that you, a user, can't overload operators using only built-in types.
>>9726
I don't care about the command line, I want LITERALLY ANYTHING. The only difference between pressing the X to close the window, and my problem, is that any code after the crash won't execute. Nothing else happens, it just closes. It also crashes at random inconsistent locations so there's nothing that it crashes on.

>Are you accessing the Windows system over a remote shell?
No.

I solved the problem yesterday though, one of my libraries had a bug so a buffer didn't resize properly. I don't understand why the operating system doesn't tell me that it closed my program because of an invalid memory access, it can't close my program without knowing why it's doing it so why won't it just tell me? Fuck I'm so done with programming.

And GDB has never helped me solve this kind of problem because the call stack gets corrupted as soon as someone sneezes, so I don't know why I even still have it installed.
Replies: >>9738 >>9749
>>9731
it obviously does if its killed it, i think with winshit10 all error messages are disabled by default you have to disable 'Prevent display of the user interface for critical errors' in policies
>>9731
Well, if you have a corruption in the stack, the stack gets corrupted. That's normal.
Run the program under valgrind or OpenBSD (OpenBSD has strong memory protections, makes programs crash more often) and see if helps.
img.png
[Hide] (162.8KB, 723x486)
What features would you want in an image viewer?
When I started thinking about it, I immediately came up with some very basic things that I've never seen before, like a timeline for gif animations and the ability to quickly adjust the background color brightness for transparent images.

Viewer, not an editor.
>>10692
>What features would you want in an image viewer?
<Zoom in and out
<Move the view while zoomed in
<Toggle between fullscreen and windowed
<Rotation
<Doesn't take 30 minutes to load because you are creating thumbnails for every image in the same directory on startup
Replies: >>10698 >>10738
>>10694
>Toggle between fullscreen and windowed
By fullscreen do you mean like a presentation mode without UI?

>Doesn't take 30 minutes to load because ...
I wouldn't want the program to wait for anything at all. Even the current image loading should happen in background so I can skip to the next image without having to wait for it to finish first.
>>10692
Multiple windows spawning from a single process. Eye of MATE and LXImage both do this automatically. Cuts down on RAM use if you open more than one image, and also speeds it up once you have one instance already running. I consider this essential, but nothing else has it. Nothing else does this, but I wouldn't mind running it as a daemon, just like you'd do with a file manager, because opening images is such a common thing that there would be no downside to that. Also, zooming to fit the image to the screen/window, has to have that, but that's a common feature. I guess have other basic features. Copying the image to the clipboard, copying the path, opening the directory, opening it in another program. That kind of thing.
Replies: >>10721
>>10712
>Cuts down on RAM use
>speeds it up
>I consider this essential
I don't understand either one of these. Sharing memory between 2 windows will probably save you less RAM than what one image will take in memory, and I'd keep at least ~5 previous/adjacent images in memory to make it easier to switch back and forth between them. The program will also open instantly so I'm not sure what can be sped up from using an existing process. The only way to get meaningful RAM savings and speedups would be from viewing the same image(s) on 2 different windows, since then they could use the same image memory without loading or processing the same image twice. Technically it's useful but doesn't seem very meaningful in practice.

Having only 1 process open for the program would be cleaner for autistic reasons, but seems like a matter of opinion. I suppose the main reason you wouldn't want that is if the program is shit and freezes so you have to kill the process, but if the program isn't shit then maybe there's no reason.

All that said, I can probably(?) do that and I don't see why not.

>Copying the image to the clipboard, copying the path, opening the directory, opening it in another program
I was entirely focused on the viewing/browsing experience so I didn't consider any of these.
>>10692
>>10694
these, and support for stepping through an animated gif frame by frame.  I would also like to have customizable keyboard shortcuts, also do not invent your own keyboard shortcut scheme (use arrow keys or vim-like keybindings). Take inspiration from imv. It's pretty good.
If I have a mixture of I/O bound and compute bound tasks, is there a way to make these tasks share a thread pool without polling (doesn't scale, needs to be event based) or blocking (thread should go work on compute instead of blocking)? I don't care about latency, the program doesn't have any sort of realtime requirements.
Replies: >>10798 >>10799
>>10692
Could you share your code? Is it cross-platform?
>>10793
Just use libev or libevent. Or write your own with epoll and eventfd, which scales. Or a thread-safe queue + poll.
Replies: >>10801 >>10804
>>10793
pipe2( fd, O_NONBLOCK )
>>10798
Hmm, that sent me down an interesting rabbit hole: http://www.kegel.com/c10k.html
It seems others already long realized what I just realized, and now I have some reading to do. But I don't know which of libev or libevent is better...

It would be interesting if I/O readiness events came in as signals and I could add the I/O operation to the work queue from inside the signal handler, if signal handlers weren't scary. That way, I could have 8 CPU cores and a work queue being serviced by 8 threads, the 8 threads can be servicing compute jobs, then an interrupt comes in and hijacks a compute thread to add some I/O work to the work queue, the current job resumes, and when a compute job is over, the I/O job is serviced. The threads work nonstop and never block waiting on I/O, they're always either computing or servicing nonblocking I/O, there's no polling so it scales, and the program doesn't spawn any more threads than there are CPU cores to execute them in parallel so it doesn't cause excessive task switching. I wonder if such a design (or equivalent) is possible.
Replies: >>10804
>>10798
>>10801
I'm checking out libev, and I see some scary shit. They have their own syscall wrappers.

And http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#TIME_REPRESENTATION says:
>Libev represents time as a single floating point number
Fuck's sake.

On the other hand, libevent has 8 times the lines of code of libev. And libevent uses struct timeval throughout which is better but not perfect, it has several instances of code to convert timeval to timespec because all the OS APIs use timespec, and nobody thought to migrate it to timespec apparently.
I thought libevent had a chance to be good because an OpenBSD developer worked on it and it's in the OpenBSD base system, it's not. Turns out the version in the OpenBSD base is an unmaintained leftover nobody bothered to remove, it's not actually used by programs either, they use a version from the ports tree because the version in the base has fallen behind the standalone one and is missing functions. libevent is not even threaded because it uses global variables internally, libev has you pass a context to it so there's no such issue.

libev also uses relative times instead of absolute times for timeouts and the like, and then it documents what those times are relative to because it caches the time and doesn't update it every time so your 60 second timer might still be 60 seconds in the future in 120 seconds. It's absolute insanity. Dunno what libevent does here because I already don't want to use either library, no point in reading more shitcode.

Both libraries are extremely bad. Is there a good one?
cap_0.jpg
[Hide] (30.5KB, 240x240)
cap_1.jpg
[Hide] (30.9KB, 240x240)
cap_2.jpg
[Hide] (32.5KB, 240x240)
cap_3.jpg
[Hide] (24.1KB, 240x240)
cap_4.jpg
[Hide] (31.6KB, 240x240)
Tried to make a new captcha solution. I don't know how effective it is, and it's probably been done before. It splits an image into 9 cells, and then swaps one of the cells with a different image and randomizes the brightnesses.
It works pretty well for drawings, but often becomes very confusing with photographs.
Replies: >>10853 >>10854
>>10852
Forgot to mention that the goal is to select the one cell that was swapped.
sensors-16-01443-g001.png
[Hide] (562.3KB, 2833x1426)
>>10852
The randomization is good, but I think it might still be susceptible to frequency analysis. Pic 3 for example has a very obvious distribution in frequencies. Lots of hard edges and flat fills in the picture of the girl, but gradients and noisey speckling in the center left tile. Even after randomizing intensity that won't change. Is some spammer really going to write a custom FFT analysis script to bypass the captcha? Probably not. Maybe you could fuck with the frequency domain representation of the images in a way that's similar to what you're doing with intensity though?
Replies: >>10855
11.jpg
[Hide] (30.6KB, 240x240)
>>10854
I don't know much about frequency analysis, but it would be trivial to add varying amounts of noise or blurriness or gradients on each cell. May make it even harder to complete though. I don't think I'd use this captcha if I made a real website, it's cool because it can integrate the website's content into the captcha and gets new possibilities when people post stuff, but there's several flaws with it, for one there's a 1/9 chance to get it correct by selecting a random cell.
Replies: >>10858
>>10855
Could just try adding random noise to every pixel and look at the fourier transform. Might want to do it in linear color.

But yes, the algorithm here is not good, you have a much, much larger amount of possible combinations with e.g. the jschan captcha.
>>10692
I probably won't use your program, but a function I had come up with is a keybind to copy file location. I got this idea only because I was looking through my Steam screenshots which steam is abyssmal about its organization.
my_fleshlight.png
[Hide] (1MB, 926x1280)
SDL replaces the program's main() with SDL_main(). Christ, why can't people write libraries without pulling shit like this?
And don't give me "we need to init stuff" as an excuse because that's easy to do, just define an internal function that does the equivalent of pthread_once and use it on whatever subsystems need initialization. Also has the benefit that what isn't used isn't initialized.
Replies: >>10911 >>10927
>>10910
>SDL replaces the program's main() with SDL_main()
At least it's not Allegro:
<Thirdly, you must [in Allegro 4 and WIPs] write END_OF_MAIN() after the closing brace of your main function. If you don't do this, your program will not link properly with the Allegro library.
I'm guessing all windowing/multimedia libraries need to pull some tricks to work cross-platform, and those are not always elegant.
You could try one of these:
https://github.com/raysan5/raylib
https://github.com/emoon/minifb
>>10910
Put
#define SDL_MAIN_HANDLED
before the include.
slider.gif
[Hide] (185.1KB, 240x80)
How would you create a non-linear slider input?

Pic related uses a cubic scale so it's easier to select small numbers, but the white bar moves in linear scale and I'm not sure how to reverse the cubic value. I need to be able to change the size externally and move the bar based on from just the final value, so I can't use the mouse position to move it.
>>10928
You reverse the cubic value by taking its cubic root, my fellow high school dropout.
Replies: >>10930 >>10932
>>10929
That doesn't work with all easing functions.
Replies: >>10931 >>10933
>>10930
If accuracy is not important, lookup table.
Otherwise, polynomial approximation.
That_Fluoride_Stare.jpg
[Hide] (135.9KB, 680x974)
>>10929
>School is le good
>Dropping out from school is le bad
>>10928
Why cubic and not exponential since you don't need zero?
>>10930
Why wouldn't it work? It works for all monotonous functions for which you can compute an inverse. You can use bisection method or Newton's method if your inverse function doesn't have a formula.
Replies: >>10938
>>10928
use percentages and an inverse function { y=1-\frac{25}{x^{2}+25} }, 50-x is the value 100-(y*100) is the percentage the bar should be moved
>>10933
Cubic is just the first thing I threw in and then immediately realized that the bar is in the wrong position. The curve it makes is too steep though.
Is there any simple way to detect whether a string is a gibberish file name like "218023089aa48cbb59173d0e54ea24d87c118f2906ea0e44b4b566974411479e.jpg" ?
It doesn't need to be super reliable, I just want to detect a pointless gibberish file name and replace it with something else, but leave other file names in tact.

I guess I'd need to detect if there's a bunch of random segments of numbers and letters? Like: read a continuous string of numbers, then continuous string of letters, and repeat. If it alters between those ~6 times and the string is longer than 20 characters without any spaces, then it can be considered to be gibberish. Anything smarter I could be doing?
>>10963
Well, maybe you could do a dictionary check or something.
Replies: >>10965
>>10964
I think it's infinitely harder to detect if it's legit than if it's not, it could contain some short codes or weird technical keywords or names or foreign languages or whatever, and it's not guaranteed to be in any kind of correct format either.
Replies: >>10966
>>10965
You can train an AI to do it. Or try something smart like portion of string that are words.
>>10963
Maybe dumber is better than smarter:
Total number of characters if fixed length.
Range of number of characters if variable length.
Excluding characters if files you want to avoid detecting use characters the gibberish never does (e.g. spaces or underscores or CamelCase).
>>10963
names like that are easy, like you said you just count the times it switches from number to letters ie. grep -o  '[0-9]\{1,99\}[a-Z]\{1,99\}' | grep -c '.', if its higher than 5 its obviously a random name, same with caps like rDoiwTdERf
Replies: >>10971
renaming.webm
[Hide] (1.4MB, 990x690, 00:30)
>>10963
Seems to work ok with just this. I'm also checking for numbers longer than 10 characters to detect unix timestamps. I'm not entirely sure what I want to do though, maybe just delete the filename and prevent submitting unless it's changed manually.

>>10968
>same with caps like rDoiwTdERf
Good point, I'll see if I can include that.
Replies: >>10986
bonzi_it's_pretty_dead.webm
[Hide] (1.1MB, 150x214, 00:56)
>>10971
Oh my science! He's making the new chan that will revolutionize the "chan" industry!
>>10986
I've posted a lot of things I've worked on here but this is the first time someone randomly started crying about it. I wonder why.
Replies: >>10996
>>10994
Just a joke, friend. Chill.
Replies: >>10997
>>10996
Not me, I meant >>10986 to shit on you It not joke.
Replies: >>10998
>>10997
Not me either, I did actually meant >>10986 as joke and want to be filled with your seed.
>>10963
Is 1.mp4 a gibberish name? Filenames on most imageboards aren't random, they're either UNIX timestamps or hashes of the file contents. Filter by length and composition of the name. Other websites do the same a lot of the time.
Replies: >>11019 >>11022
>>11010
"1" could imply that it's first in a sequence, like page 1 of a comic.

I don't want to be too strict about it, I just want to detect names that obviously don't have any meaning, I'm specifically thinking about the hashes and unix time stamps that come from imageboards.
>>10963
>I guess I'd need to detect if there's a bunch of random segments of numbers and letters?
Hashes are a fixed length (e.g. 32 characters for MD5) and are only use 0-9 a-f (because a hash is just a big number and what you're seeing is the hexadecimal representation (a=10, b=11, c=12 etc.)

>pointless gibberish
The reason they use hashes is because the same file will always have the same hash. So you can upload the same file with different names in multiple posts and the server only needs to store one version of the file. It can also help you detect duplicates on your end to avoid wasting disk space.
Replies: >>11021 >>11022
>>11020
The source file name isn't useful for any purpose except tracking people as far as I'm concerned. To give an example, sometimes I edit an image and overwrite the original without changing the filename.
Replies: >>11022
>>11021
>The source file name isn't useful for any purpose except tracking people as far as I'm concerned
>>11010 and >>11020 explained to you exactly what the purpose is. If you're too stupid to understand then maybe we're wasting our time trying to help you.
Replies: >>11023
123.png
[Hide] (6KB, 676x227)
123.png
[Hide] (5.5KB, 620x259)
>>11022
>too stupid to understand
I think you're projecting. Tell me how you can use these filenames to identify which image is which.
freetard_security_theater.png
[Hide] (57.7KB, 808x391)
JJJ.mp4
[Hide] (885.9KB, 854x348, 00:10)
Replies: >>11161 >>11276
>>11137
>3dpd
>>11137
>freetard_security_theater.png
glad wiggers are figuring out their shits retarded 15 years after i noticed after hitting age of consent
now please remove all that PAM and such bullshit from the stock gentoo install
CSS nojs question
Is there any way, without javascript, to modify a value that is more complex than a true/false, and then read it from CSS?

For example, if I want to change a value between 1 and 100 and read it from CSS, is there any clever way to accomplish that? The closest I can think of is having 100 radio buttons each with their own CSS.
Scrollbar will let you adjust position linearly, but it's hard to make it do anything other than moving sideways.
Also a <textarea> can be dragged/resized in 2 dimensions, but that's very unreliable and kinda different on each browser.
Is there any networking library that uses io_uring?
I just want a fast networking library but it's impossible to find, but I assume that something that uses io_uring is fast by default.

I just don't understand why all these networking APIs are so fucking convoluted or why any of the decisions in them were made, so it's impossible for me to learn them, so I want someone to abstract it into a library for me.
>>11352
Ignore this question because I know that any answer is going to be shit that I hate.
>>11352
You can write one with liburing.
Or a simple search gets you https://github.com/scylladb/seastar
You also need to write your application around the "completion" concept instead of readiness.
>>11352
POSIX sockets goes back to BSD sockets.
BSD sockets was meant to be protocol agnostic in a time of rapidly changing network protocols and disjoint networks across the globe, when individuals had no access to networks and only members of organizations had access to that organization's network for that organization's purposes so there wasn't much point to encryption, the reliability features of TCP were nice but not always available or even necessary, and so on.

The idea was that at least your program worked in any of the world's many networks and hopefully the system defaulted to a sane, good protocol which would hopefully evolve over time.

Fast forward a few decades of experience and networking theory advancements and it turns out you can't abstract away the protocol from the programmer because it matters a lot, the protocols have been the same (with some retrofitted tweaks) for 40 years, you can assume IP over TCP or UDP, the incompetence of the corporations running the internet created something called ossification, reliabity is almost always a requirement but TCP's reliability features are antiquated and not always a good fit, and so on.

Maybe QUIC will make it better.
Replies: >>11372
Epoll looks like the best networking API to me. As far as I understand, it's the fastest API that uses regular file descriptors, and the API is very simple and straightforward.

I compiled all the relevant components into this example, I haven't tested it though:
static void epoll_add_socket (int epollfd, int socketfd, uint32_t events_to_watch_for) {
	struct epoll_event event = {
		.events = events_to_watch_for,
		.data.fd = socketfd, // The entire .data union is for user data, epoll doesn't interact with it.
	};
	// Note: If epoll's max socket cap is hit, then this returns -1 and errno will be ENOSPC.
	// The cap is something like 4% of RAM though, 90 bytes per element (444,444 sockets per 1 GB).
	epoll_ctl(epollfd, EPOLL_CTL_ADD, socketfd, &event);
}
static void epoll_remove_socket (int epollfd, int socketfd) {
	epoll_ctl(epollfd, EPOLL_CTL_DEL, socketfd, NULL);
}
static void make_socket_nonblocking (int socketfd) {
	fcntl(socketfd, F_SETFD, fcntl(socketfd, F_GETFD, 0) | O_NONBLOCK);
}

int main (int argc, char *argv[]) {
	// Initialize listening socket
	int listen_socket = socket(AF_INET, SOCK_STREAM, 0);
	struct sockaddr_in server_addr = {
		.sin_family = AF_INET,
		.sin_addr.s_addr = INADDR_ANY,
		.sin_port = htons(8080), // Port
	};
	bind(listen_socket, (struct sockaddr*)&server_addr, sizeof(server_addr));
	make_socket_nonblocking(listen_socket);
	listen(listen_socket, 32);
	
	int epollfd = epoll_create1(0);
	epoll_add_socket(epollfd, listen_socket, EPOLLIN);
	
	#define MAX_EVENTS 64
	struct epoll_event events [MAX_EVENTS];
	while (1) {
		int eventcount = epoll_wait(epollfd, events, MAX_EVENTS, -1); // -1 = no timeout, wait forever
		for (int i=0; i<eventcount; i++) {
			// New connection, listen socket shouldn't have any other events than EPOLLIN.
			if (events[i].data.fd == listen_socket) {
				struct sockaddr_in client_addr;
				int socket_len = sizeof(client_addr);
				accept(listen_socket, (struct sockaddr *)&client_addr, &socket_len);
				make_socket_nonblocking(client_socket);
				
				// Add EPOLLET for "edge-triggered" mode.
				// Without EPOLLET, an event keeps occurring as long as the condition for it is true.
				// With EPOLLET, an event only occurs once when the condition for it changes.
				epoll_add_socket(epollfd, client_socket, EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLHUP);
				
				continue;
			}
			
			// Handle events
			if (events[i].events & (EPOLLRDHUP | EPOLLHUP)) { // Hang-up: socket closed.
				epoll_remove_socket(epollfd, events[i].data.fd);
			}
			else if (events[i].events & EPOLLIN) {
				// Socket has data in it, read(events[i].data.fd)
			}
			else if (events[i].events & EPOLLOUT) {
				// Socket is ready to receive data, write(events[i].data.fd)
			}
		}
	}
	return 0;
}
Replies: >>11370
>>11369
io_uring can be faster than epoll by reducing system calls
Replies: >>11373 >>11377
>>11361
>but TCP's reliability features are antiquated and not always a good fit, and so on.
In what way? I don't think TCP will ever be replaced.
Replies: >>11377
>>11370
I thought io_uring doesn't use file descriptors in a normal way somehow. I haven't looked into it enough to know though.
>>11372
1. checksum is too weak
2. packet ordering isn't necessarily important (e.g. a filesharing protocol only needs to care about where the data goes, not the order it came in, and online games would rather have the data soon than in order)
3. networking has become so fast a 32-bit sequence number is too little
4. flow control has proven to be a mistake, all modern network stacks only use dropped packets to moderate speed, some systems like Linux additionally have a way to intelligently manage queues to avoid bufferbloat, although none have it on by default

>>11370
Epoll is also severely broken and it's best not to use it in general.

If you watch an fd with epoll, fork, close it in the parent, and an event comes in on the child's fd, the parent is the one who receives the notification.
Replies: >>11378
>>11377
>If you watch an fd with epoll, fork, close it in the parent, and an event comes in on the child's fd, the parent is the one who receives the notification
So you're complaining that it's giving events to the fd that you gave it? How about just updating epoll about the fd that you want it to notify you about? Sounds like a (You) problem to me.
Replies: >>11379
>>11378
Classic Linux madness. Should've learned from Windows which does not suffer from this issue.
What's the fastest algorithm that can insert and remove data elements and scales linearly with threads? It doesn't matter what element is removed, it just has to return any.
Replies: >>11425 >>11442
>>11429
sharded datastore, assume uniform access. Not sure if fastest though.
>>11419
For C++, I'd just recommend the std::remove_if() against a basic std::vector. It's linear as-is. You can also specify the par_unseq execution poilicy (but probably shouldn't until you scale to a big enough dataset... as always, test).

https://en.cppreference.com/w/cpp/algorithm/remove
https://en.cppreference.com/w/cpp/algorithm/execution_policy_tag_t
Replies: >>11426 >>11437
>>11425
Also BTW, there's the syntax helper functions std::erase_if(), though I'm unclear whether you can specify an execution policy with them yet.

https://en.cppreference.com/w/cpp/container/vector/erase2
Replies: >>11437
>>11426
>>11425
No, I don't use C++, thankfully.

I'm running into the issue that a deque that scales doesn't exist, all deque algorithms top out at O(2) scaling. This is because a deque returns elements in order and there is inherent serialization in returning elements in-order, but I don't care about order.
BTW, most people using deques in threaded programs don't care either, just because an element was fetched from the deque by a thread first, it doesn't mean that thread won't get preempted as soon as it does that until any number of later elements were processed by other threads, so threads break the ordering anyway.

I found this paper: https://link.springer.com/chapter/10.1007/978-3-642-39958-9_18
>We introduce fast and scalable algorithms that implement bounded- and unbounded-size lock-free k-FIFO queues on parallel, shared memory hardware. Logically, a k-FIFO queue can be understood as queue where elements may be dequeued out-of-order up to k − 1, or as pool where the oldest element is dequeued within at most k dequeue operations. The presented algorithms enable up to k enqueue and k dequeue operations to be performed in parallel. Unlike previous designs, however, the algorithms also implement linearizable emptiness (and full) checks without impairing scalability.

Unbounded (I actually need this), checking emptiness without destroying performance (forgot to mention I needed this too), loosely ordered, seems perfect. Now I have to figure out how to pirate it or find an implementation I can read.
Replies: >>11439
>>11437
How about this https://arxiv.org/abs/1312.2501 ?
Replies: >>11451
>>11419
Get an array with an index pointing to the last element. You fetch-and-add (https://en.wikipedia.org/wiki/Fetch-and-add) -1 to the index when you access it, and use the copy of the old value as that thread's index into the array. Fetch-and-add is atomic so the threads are guaranteed to have different elements each time. You always fetch from nearby elements in an array so it has good cache coherency. No locks.
No grantee that this is the theoretic fastest, but it should be pretty darned fast.
Replies: >>11445
Another captcha idea: generate nonsense words that, when spoken out, sound like real words. Objective is to type out the real word.
For example: widiohblahtphoom -> video platform

Just had that idea, haven't even begun to try making it at all. I don't know if there's any good way to make that conversion or how easy it would be to break or solve legitimately. It would probably also filter out people who can't speak English well which may be good or bad.
>>11442
It's extremely slow. Atomics have locks, just inside the hardware. Now imagine the lock contention. All the threads compete for the same resource, so scaling is O(1): the operation performs the same no matter how many threads you throw at it.
Replies: >>11449
>>11445
>just inside the hardware.
The point of the exercise is that contention is limited to a single clock cycle (ie, billionths of a second), since Fetch-n-X operations are such.
Replies: >>11450
>>11449
If there is contention, i.e. more than one thread access the same atomic, only one goes through. The others will fail the operation and it takes additional cycles for retries. For a large number of threads, it will lead to a cascade of retries.
How about something like this: https://www.osti.gov/biblio/1531271 ?
Replies: >>11451
>>11439
>>11450
Can't read them yet, working, but thanks anon.
What's a library for making a HTTP request that doesn't suck?
Eh, fuck it, curl may be an abomination, but I don't know of a library that can handle compression, reusing connections, coping with stalled connections, running everywhere, all the http standards, etc. I was writing a program that checks the hash sum of a GOG game but it turns out the GOG API is only for GOG Galaxy installers, not the ones you download through the web interface. Someone wrote a python script that parses the web pages to do something similar but it requires logging in and this was meant for piracy.
Replies: >>12387
>>12385
>I was writing a program that checks the hash sum of a GOG game
A central repository for those would be really useful, hope you can figure something out anon.
Replies: >>12389
>>12387
All that's necessary is a list of hash sums of all the installers and goodies on GOG. Then you can use plain old sha256sum or whatever from the command line.

Because of the lack of such a list and the issue of having to pirate the games to hash then (and then risking having incorrect hashes), I thought I might aswell use the undocumented public API which provides md5 hashes, even if md5 is broken. However, it turns out that's only for GOG Galaxy installers, which means only Windows and macOS games (no Linux), and it's useless for piracy because pirates use the installers from the GOG web interface which are different.
>>12389
>md5 is broken
Only if you deliberately work towards breaking it, like literally any other hash algorithm... For verifying the integrity of files, md5 is more than good enough.
Replies: >>12995
03daxuxcE5t7NHYGJwO1AyQ-2.jpg
[Hide] (426.7KB, 1920x1080)
>>12389
>All that's necessary is a list of hash sums of all the installers and goodies on GOG.
Which they will never do because they just want everyone to get on their not-steam nowadays. Remember when they displayed the web downloads front and center rather than hiding them under a small, misleading "backup downloads" button? 
Making a github with the md5 of all games seems simpler than changing the mentality of a greedy corporation.
>>12390
Yes, for verifying the integrity of your 'own' files.
Since there are people who deliberately work towards breaking it you want to use sha256.
Replies: >>12996
>>12995
Don't misunderstand, I meant to make own bold.
>>12389
The Windows GoG .exe installers come with an embedded certificate. Maybe there is some way to check that on Linux.
I'd be interested too.
[New Reply]
129 replies | 31 files
Connecting...
Show Post Actions

Actions:

Captcha:

Select the solid/filled icons
- news - rules - faq -
jschan 1.4.1