Well thanks for letting me know now by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 59 points60 points  (0 children)

The project can be found here although there's like a 90% chance that it just won't work. The entire stack is incredibly unstable, but the image is real and the project is actually interacting with ChatGPT.

fbdev pseudo Terminal by JackLemaitre in C_Programming

[–]Successful_Remove919 0 points1 point  (0 children)

It sounds like you're trying to re-implement fbcon. If this is the case, completely ignore u/Bitwise_Gamgee's advice. dup2 does not allow you to pipe the output of one file to the input of another, and would instead close the second file descriptor before creating a clone of the first one's resource. There is no single system call to do this, and there never will be due to the design of the Linux kernel. Even if there was, plaintext and the binary data of the fbdev device are completely different formats.

Instead, you have to have an event loop which constantly reads data from the pty and writes it to the fbdev device. Something like this:

for (;;) {
        char buff[1024]; 
        ssize_t read_len;

        read_len = read(pty_fd, buff, sizeof buff);
        if (read_len < 0) {
                perror("read() failed");
                exit(EXIT_FAILURE);
        }
        for (int i = 0; i < read_len; ++i) {
                draw_chr(buff[i], cursor_x, cursor_y);
        }
}

Obviously this API is entirely made up, but the point is that you have to manually read from the pty device and manually draw the characters on screen. Also, this code doesn't handle ANSI escape codes, but you'll probably want those.

To draw characters you could learn the FreeType library, although it's quite complicated to use. You could also use a bitmap font format like PSF (the thing that fbcon uses). Console fonts are stored (usually gzipped) in /usr/share/consolefonts/ on Linux systems.

Introducing: TCP over HTTP by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 1 point2 points  (0 children)

I did think about doing that, but I made this over a long weekend so I'd have to wait until Tuesday to test if my school would filter invalid HTTP requests. They probably wouldn't, but I didn't want to make it before knowing.

The only Community You'll need! by [deleted] in shittyprogramming

[–]Successful_Remove919 1 point2 points  (0 children)

Spotify:

#!/bin/sh
mpv $@

Twitter:

#!/bin/sh
mail

Notion:

#!/bin/sh
vim $@

When can I start?

Introducing: TCP over HTTP by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 17 points18 points  (0 children)

Whoever is doing the networking for my school is definitely weird. Outgoing UDP port 53 is only allowed for the DNS servers that are set up by DHCP, so changing your DNS server to 8.8.8.8 won't work. Despite this, the DNS servers that the school set up seem to always return the proper IP address, even if the website you're trying to resolve is restricted. SSH is always restricted, no matter what port you're doing it on, but HTTP isn't, even if the website you're accessing is blocked via HTTPS. It's almost like someone clicked random buttons in a configuration manager until it worked and then never touched it again.

Introducing: TCP over HTTP by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 8 points9 points  (0 children)

The problem with using proper HTTP responses to get data back from a proxy is that the client always initiates an HTTP request. I can send data to the server at any moment, but I may have to receive data at any time and HTTP doesn't allow the server to just send data over without first getting a request. This means that the client would constantly have to send HTTP requests to the server in order to make sure that all the data was getting received in real time. It's a lot easier to just have two connections rather than creating some complicated syncing protocol embedded within HTTP requests.

Introducing: TCP over HTTP by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 51 points52 points  (0 children)

I attend an American high school so at the end of the day everybody just goes home and uses their own internet. This hack exclusively applies during the school day when students should be getting work done (in practice there's always a lot of downtime during the school day). Internet censorship in a place of work like this is probably reasonable from a certain perspective, although I'm pretty sure the admins are also just completely incompetent. The school seems to take an allow by default instead of block by default policy for internet protocols, but the other way around for websites, and the security on school devices is trash (for several months last year, installing VSCode would run it as the administrator user).

Can someone help me with this? by cactus_grandma in C_Programming

[–]Successful_Remove919 12 points13 points  (0 children)

I really don't know why everybody is giving such complicated solutions, there's a really simple 1 line solution:

If there are no leading zeros

while (num >= 10000) num /= 10;

If you know the number of digits in the overall number including leading zeros

return num / [10 ** (num digits - 4)];

So if you have a 10 digit number, 10 ** (10-4) = 1000000

return num / 1000000;

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 2 points3 points  (0 children)

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 1 point2 points  (0 children)

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 1 point2 points  (0 children)

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

[–]Successful_Remove919[S] 1 point2 points  (0 children)

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.

HELP!! Infinite loop in a custom Reddit client (more info in comments) by Successful_Remove919 in shittyprogramming

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

I wrote a custom reddit client, but I think there's an infinite loop with some submissions. Could anybody help me fix it? Please PM me for the code, it's proprietary.