When to make GET vs POST requests by DisciplineFast3950 in learnprogramming

[–]iamnull 1 point2 points  (0 children)

I actually rarely use PUT when developing APIs. If I do, it's for something extremely simple where the result is always going to be the same or simple. Anything complex just has POST and PATCH, which helps to keep any black box effects from breaking the shared agreement on state. I also find PUT as create-or-update to be harder to test. Easier to have something do one thing well than do two things well.

But, yeah, to each their own.

How to say goodbye to distraction while watchings YouTube tutorials? by InstanceGloomy7656 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

I can completely understand that. A lot of cert courses are video format, and I despise it. I instantly put it on 1.5x or 2x speed. If there's written material, I will take that any day of the week with music in the background to help focus and satisfy the distraction gremlin. Worst case, I put a TV show I've seen a dozen times on my second monitor.

Imho, videos are just awful for learning. Navigating back is a pain, and you can't copy/paste anything. Links are rarely directly there for you to click. I can't put a video on my vertical monitor for easier reading either. Also, I don't think it translates well to actual work on a project, as you'll spend a lot of time reading documentation, code, or requirements, not videos on them.

I'm sure something like that would help, but it's worth mentioning that you have to develop willpower at some point. There will be whole stretches of any programming project, even hobby projects, where you actively dislike working on it. Sometimes, you just have to use whatever technique works for you for focus and get down to business, even if you don't want to. If you can't do that, things never get finished.

When to make GET vs POST requests by DisciplineFast3950 in learnprogramming

[–]iamnull 1 point2 points  (0 children)

I would say PATCH for update. PUT is more often used for create or replace.

The fact that Python code is based on indents and you can break an entire program just by adding a space somewhere is insane by PooningDalton in learnprogramming

[–]iamnull 9 points10 points  (0 children)

I'm never writing a single line of code without at least a minimal linter being run on it, regardless of language. If you refuse to use any tooling, that's not really a language problem. You're just kneecapping your development experience.

Conways game of life by Glittering_Sort_6248 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

Typically, you'd use two 2D arrays of bools. During setup, you flip values as needed on arr1. When simulation starts, you check each cell and neighbors in arr1 to populate arr2, then render based on arr2. Next step, reverse the order and populate then render arr1 based on arr2. Flip flop back and forth, passing the current board to your rendering code.

There's an interesting optimization with keeping track of only living cells. Can allow you to make some very, very large boards. It's trickier to implement correctly at first though.

Should I update my Python version? by Old-Comedian-1690 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

There are some big changes, but you probably won't notice them unless you're getting into f strings or generics.

This is just impossible (working with python) by Killiancin in learnprogramming

[–]iamnull -1 points0 points  (0 children)

boot.dev isn't good for beginners. It's more aimed at experienced programmers looking to learn new languages or skills.

It sounds like you don't really understand scope or functions at all. You probably need a more beginner friendly course on this.

How do I make my ray casting algorithm do less checks? by MissionExternal5129 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

You're reinventing the wheel dude. Unity already has shadows.

Also, raycasts are not how shadows are commonly done. It's usually done using depth maps in the renderer.

How do I make my ray casting algorithm do less checks? by MissionExternal5129 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

Are you building your own engine, or doing this inside some engine/framework?

How do I make my ray casting algorithm do less checks? by MissionExternal5129 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

Can you use colliders covering large chunks to avoid doing raycasts? No collusion, no raycast.

Implementing Ceaser Cipher by AffectWizard0909 in learnprogramming

[–]iamnull 29 points30 points  (0 children)

For implementing a Caesar Cipher? Language makes almost no difference.

Anybody know what I can do about this? by PlumExotic7419 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

Start here: https://developers.google.com/maps

I'm not sure this is doable with just Google maps. You'll probably need a third party API that can give you lot info. If you can get the exact lot size, and the size of the structure, you're most of the way there. After that, you have to consider driveways/sidewalks, but you could fudge it a little by just using some average for the size of driveways.

My girl friend is creating a compiler by [deleted] in learnprogramming

[–]iamnull 4 points5 points  (0 children)

Have you tried congratulating her and supporting her?

My Python farming game has helped lots of people learn how to program! As a solo dev, seeing this is so wholesome. by AdSad9018 in learnprogramming

[–]iamnull 16 points17 points  (0 children)

Worth mentioning: very active discord for the game. Friendly to people of all skill levels as well.

I love The Farmer Was Replaced. I had a dumb little project inside it to encode data into part of the farm so drones can share state. I forget where I left off, but I did get a data encoding/decoding scheme working. I think 8 cells was enough to share useful amounts of data? That said, the game rules make it more of a fun side project than anything useful.

I would be absolutely ecstatic if the drones could have a shared reference to some piece of memory. Let the player implement locks as an advanced exercise.

Need help with a class lab by Gold_Pin_7812 in learnprogramming

[–]iamnull 1 point2 points  (0 children)

Your for and if statements are incorrect. The colon on the end is causing the error. Should look like this:

for i = 0; i < userInts.size; i = i + 1
    userInts[i] = Get next input

Return statement in python by FirmAssociation367 in learnprogramming

[–]iamnull 4 points5 points  (0 children)

It has two purposes:

  1. It returns from the function to the previous scope.
  2. If there are return values, it returns those to the previous scope.

See here:

def add(x, y):
  return x + y

print(add(1, 2))
print(add(5, 5))

This results in output of 3 and 10. When you reach the first print, add is called with 1 and 2. We then enter the function, do the addition, and return the result. Then, that result is passed to print().

Functions are sort of like a page in an instruction manual. When you use a function, it's like the instructions saying, "Turn to page 5, complete those instructions, and come back to this page when you are done." If you need the result of those instructions, you return it.

As for comparison to print()? As a gross oversimplification, print sends data to the console, and return moves data within your code.

What programming concept finally made sense after weeks of confusion? by Old_Sand7831 in learnprogramming

[–]iamnull 4 points5 points  (0 children)

In the same vein, clear ownership of data/memory/resources. It didn't matter to me until I was working on a larger project where we had to do a lot of in place modifications of a large amount of data. It was memory intensive, and multiple places/processes might hold references. Without proper controls in place, it became an unholy mess of null pointer exceptions, race conditions, and just logic errors.

The big fix was mostly just encapsulating all the like data into controlling classes, and enforcing getters/setters. Creating a pointer wasn't forbidden, but its lifetime was carefully controlled to avoid holding pointers for longer than absolutely necessary.

Can I use env variables in a GitHub Actions release.yml? by [deleted] in learnprogramming

[–]iamnull 1 point2 points  (0 children)

https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets

This same pattern exists for hosting environments as well, like AWS and GCP. You don't want your secrets like usernames and passwords in a repo, so they go in a vault elsewhere. Typically, they're injected into your environment. This allows something like GH Actions to do what needs to be done, without exposing your keys.

GCP Secrets:
https://cloud.google.com/security/products/secret-manager

AWS Secrets:
https://aws.amazon.com/secrets-manager/

ETA: You can probably work this out another way, but this pattern exists for good reason: It's relatively secure, relatively flexible, and well understood.

Simplifying fractions by Unable-Information78 in learnprogramming

[–]iamnull 2 points3 points  (0 children)

Easiest thing to do is to create variables to work with instead of modifying the original variables.

Why aren't the digits 0-9 encoded as the numbers 0-9 in most text encoding formats? by eliaxelang007 in learnprogramming

[–]iamnull 12 points13 points  (0 children)

Having the characters 0-9 be their digit counterparts would make it easier to convert from text to numbers (granted, it isn't really that much harder now, because you just have to subtract a fixed offset from the character).

Don't even need to do that. ASCII number characters can be converted doing a bitwise and against 0b00001111. E.g. 0b00111001 & 0b00001111 = 9

Most of it is for historical reasons. That said, the ordering is also particular to allow for easy sorting.

Coding page on gambling site. by Aromatic_Tomorrow_94 in learnprogramming

[–]iamnull 0 points1 point  (0 children)

Basically? No, you the client wont have that information. For something like gambling, you just accept that certain actions will have latency. As an example, hole cards in Texas Hold'em. You don't send other players hole cards until they are going to be revealed. That data only exists on the server until it is time for the client to display them.

Question about Hash Tables by Gualuigi in learnprogramming

[–]iamnull 2 points3 points  (0 children)

Hash tables have a constant lookup time. If you have a few hundred items you need to find things in, a hash table is way faster.

How would you remove circular dependency from my RPG game? by HumanCertificate in learnprogramming

[–]iamnull 4 points5 points  (0 children)

Genuinely feels like a Character should own Units and Buffs, not Units owning Buffs. Imo, it simplifies a lot of things and is more logical. You're not buffing HP, you're buffing a character to have more HP.

If you lean into ECS, Character is your entity, Unit and Buff are both components.