Daily Programming Thread

lolipop™

34444
Low rep power
Joined
Mar 1, 2024
Posts
11
Rep Power
11
What is the best way to learn programming? Im planning on learning Python since I heard that is the most useful language.
 

bemis

33334
Low rep power
Joined
Mar 7, 2024
Posts
77
Rep Power
135
What is the best way to learn programming? Im planning on learning Python since I heard that is the most useful language.
Python is a lot of fun, has some good tools for working with it, and has libraries for just about anything you might want to do. A lot of the more intensive AI stuff has Python wrappers around it, so you can still do those things if you want. My only advice is pick something you have fun writing, the rest isn't that important.

I started out thinking I needed to pick an industry language with a huge community and a ton of libraries, and my favorite language ended up being a niche one with a tiny community and only small libraries that get stitched together. I ended up learning all the boring stuff along the way anyhow.
 

bemis

33334
Low rep power
Joined
Mar 7, 2024
Posts
77
Rep Power
135
@lolipop™ I thought of a great example of the sort of thing Python is great for. Like most forums, users can have a custom signature that shows up on their posts. If you take a look at the signature editor you'll see that you can select an image by a link to have show up as your signature:
signature.png

a valid image type you could link to is an SVG image (Scalable Vector Graphics). SVG images are interesting because they're really just a markup language like XML or HTML. Even if it's rendered as a .svg file, you can open it up with a text editor and see how it's made. They're usually intended to be used as lightweight assets and pallets for a website or graphical environment, but we can get really creative with them. Here is a rough little python flask server that will generate a signature image that has some random text in it:
Python:
import cairo
import random
import string
from flask import Flask

app = Flask(__name__)

def random_string():
    return "".join(random.choice(string.ascii_letters) for _ in range(20))

def render_svg(text: str):
    # 600x100 is considered a "typical" modern signature size
    with cairo.SVGSurface("tmp.svg", 600, 100) as signature:
        context = cairo.Context(signature)
        context.set_font_size(12)
        context.move_to(50,50)
        context.show_text(text)
        context.stroke()

@app.route("/signature.svg")
def signature():
    render_svg(random_string())
    with open("tmp.svg", "r") as f:
        img = f.read()
        return img
if you put this into a file called main.py you can run it with: flask --app main run (assuming have python and pip installed, and have installed flask and pycairo with pip). I can try it out:
Peek 2024-03-20 12-19.gif

this one is a really basic example, but you could change it to be way cooler. you could take an image you like, and overlay text over it, create geometric shapes, etc. In this example you could easily add in a library like `fortune` to replace the random text with actual quotes, or just serve quotes you like out of a file.

an interesting aside, a lot of websites will try to inspect media files when they're uploaded, to figure out what to do with them. There are certain systems out there (like old versions of ImageMagick) that would accidentally run code that had been embedded into SVG files. You could write a reverse shell, embed it in an svg file, upload it to a website, and then viola you are logged in as the system httpd/nginx/etc user!
 

Andrew

33344
Low rep power
Joined
Mar 4, 2024
Posts
53
Rep Power
55
What is the best way to learn programming? Im planning on learning Python since I heard that is the most useful language.
Depends on what application. What are you trying to make?

I highly recommend learning C. You get to understand programming on a fundamental level. It's the White man's language. It might be daunting at first but become a master and you realize it's the simplest language to program with.
 

Andrew

33344
Low rep power
Joined
Mar 4, 2024
Posts
53
Rep Power
55
I built a 3D game engine using SDL, OpenGL and C in high school. Sucks because I lost the code and it's been kind of a motivation killer. I've always been fascinated with the math behind it but when it comes to video games (or software development in general) I think the industry is dead because you're competing with pajeets who are willing to work for cents on the dollar and AI is taking over. John Carmack is a huge inspiration to me. Is there some other industry where these skills apply?

Speaking of Carmack, I found this post interesting.

Might make the game engine again just for fun.
 

PoopEater3million

34444
Low rep power
Joined
Mar 9, 2024
Posts
60
Rep Power
19
I built a bunch of stuff for cozy in the last few months - https://cozy.nationalism.tv/

View attachment 1492

it's like a social blade equivalent for cozy. It also logs every chat message ever sent and makes it searchable. AND it archives every video replay it can find and uploads it to archive.org for posterity. THOUSANDS of videos archived so far.

Had similar idea to make all cozy videos "searchable" by running some speech to text software through each of those videos, but it's unbelievably expensive whether you use something like AWS transcribe, or try to do it yourself and realize how computationally expensive the whole process is …. no good solution there
Bro wtf I can see what I’ve typed in chat I’m so fucked
 

bemis

33334
Low rep power
Joined
Mar 7, 2024
Posts
77
Rep Power
135
I built a 3D game engine using SDL, OpenGL and C in high school. Sucks because I lost the code and it's been kind of a motivation killer. I've always been fascinated with the math behind it but when it comes to video games (or software development in general) I think the industry is dead because you're competing with pajeets who are willing to work for cents on the dollar and AI is taking over. John Carmack is a huge inspiration to me. Is there some other industry where these skills apply?

Speaking of Carmack, I found this post interesting.

Might make the game engine again just for fun.
I definitely think it's still worth trying to make a game/engine. I'm helping a friend make one and it's been really interesting learning about concepts used in game design that I don't really get to see in my line of work. I look up to Carmack and Romero a lot. Their principles of design have held true for a long time now. They represent a kind of excellence that is worth aspiring after.
 

bemis

33334
Low rep power
Joined
Mar 7, 2024
Posts
77
Rep Power
135
It turns out I don't really need to use Telegram at all to get any files, which is great. What I have now is a really simple approach but it's not any hassle so I think it's alright. The Internet Archive has some nice ways with the advanced search to set up bulk downloads. If anybody is ever interested in trying to archive their own copies of all of Nick's shows, this is all you need to get started (on linux):
Bash:
wget -r -H -nc -np -nH --cut-dirs=1 -A .mp4 -e robots=off -l1 -i ./aflist.txt -B 'http://archive.org/download/'
this will look in the file `aflist.txt` (attached if you want a copy). That file is a combination of the `america_first`, `america_first_2`, `america_first_3`, and @nationalism_tv 's IA sources. wget will try to download all .mp4 files in those collections. The nice thing too, is if you don't mess with any of the file names, you can stop and start it as many times as you want, and wget will skip over what you already have. After I have everything, or at least a good chunk, I'll probably need to deduplicate a few files but that is a much better problem than not having a file altogether.
 

Attachments

  • aflist.txt
    4.2 KB · Views: 21

lolipop™

34444
Low rep power
Joined
Mar 1, 2024
Posts
11
Rep Power
11
Depends on what application. What are you trying to make?

I highly recommend learning C. You get to understand programming on a fundamental level. It's the White man's language. It might be daunting at first but become a master and you realize it's the simplest language to program with.
I started learning about Python just yesterday and Im at the part where I am learning about "Nesting". Im not far into it. Im using Replit and reading a book about it. I dont really know what I want to make but sometimes I find things very annoying on the internet and think that I can make something to fix it.
 

bemis

33334
Low rep power
Joined
Mar 7, 2024
Posts
77
Rep Power
135
I started learning about Python just yesterday and Im at the part where I am learning about "Nesting". Im not far into it. Im using Replit and reading a book about it. I dont really know what I want to make but sometimes I find things very annoying on the internet and think that I can make something to fix it.
If you're using a REPL while you learn about code, you've already developed one great habit. Not every language can be toyed about with in a REPL without a lot of work, which is too bad because it's a great way to incrementally develop an idea. If you end up downloading one, I've always used bpython. it might lack features in more fancy options, but it stays out of my way for the most part.

Sometimes trying to come up with a project can lead to writers block, if you ever find yourself there just keep challenging yourself with stuff like code katas, or learning about frameworks. Even code puzzles that seem trivial end up being something you mentally put away that you'll be thankful for later.
 
Top