• 1 Post
  • 19 Comments
Joined 1 year ago
cake
Cake day: June 9th, 2023

help-circle



  • Yeah it’s super dope.

    One way to think of it non-mathematically is like this: Water and air behave differently in this system in how they transport pressure. Water in a hose creates a certain pressure on what’s below it, where you can think of the pressure as measured by the depth of the water. So the weight of 8 vertical inches of water will create 8 inches worth of pressure on whatever’s below it. Air, however, will “teleport” the pressure it’s experiencing from one end to the other end, up or down, without contributing anything significant from its own weight.

    So in the outside loop of the hose, on the right side if you’re looking at the video thumbnail, you might have a little 8-inch column of water, which can’t go down any further because there’s air in the way. So it’s exerting 8 inches worth of pressure down on that air. Then the air takes that pressure and “teleports” it to the top of the next coil inwards, so that if there’s 8 more inches of water in the next coil, it’s exerting 16 inches worth of pressure on what’s below it, from the air plus the weight of that much more water. Then the air below it teleports 16 inches of pressure over to the next coil in, and so on for every coil, until the inner coils have as much pressure as they would from a ton of water sitting on top of them, way more than the actual total vertical size of the system.





  • Surely it is plausible that an organism that evolved vision under particular lighting conditions would develop vision adapated to those lighting conditions.

    I’m not telling you it’s not worthwhile to come up with ways to test the claim if you want to be rigorous (e.g. you could measure the wavelength sensitivities of the vision of nocturnal or underwater animals and see if there’s a pattern). But to me it’s pretty self-evident as a starting point at least.


  • Yes. This story about the Georgia Guidestones has all the hallmarks of being, not news, but pure propaganda. And, that’s why they had to kill Khashoggi. MBS was actually a secret agent for Bernie Sanders trying to stop all the propaganda the guy was creating for the Post and ultimately help the United States.

    Organizations are big and complex; they’re always made of people with their own individual motives, and a good enterprise with good journalistic intent can be owned by an evil man. I’ve seen maybe 2-3 stories in the Post which seemed to me like they had clear propagandistic intent, with all the rest pretty legit journalism which is rare for the US. I mean… I am actually paying money which is ultimately going to Bezos, so honestly maybe you’re right on that side that that’s worth worrying about. But it’s not a top-to-bottom evil enterprise like Amazon is.






  • For each object of such a composed type, there was already a way to mention the underlying object: index the array, call the function, use the indirection operator on the pointer. Analogical reasoning led to a declaration syntax for names mirroring that of the expression syntax in which the names typically appear. Thus,

    int i, *pi, **ppi;

    declare an integer, a pointer to an integer, a pointer to a pointer to an integer. The syntax of these declarations reflects the observation that i, *pi, and **ppi all yield an int type when used in an expression. Similarly,

    int f(), *f(), (*f)();

    declare a function returning an integer, a function returning a pointer to an integer, a pointer to a function returning an integer;

    After almost 30 years, I think I just understood function pointer declaration syntax for the first time.



  • Hmmm

    I worked on one project only which used what I guess is an ORM-like pattern, and I have to say it was actually really nice. The code was Javascript, and there was a mapping:

    • Class <-> DB table
    • Field <-> DB column
    • Row <-> Object

    For each class, there was a big mapping table which indicated which database-backed fields needed to exist in that class, and then there was automated code that (1) could create or update the database to match the specified schema (2) would create helper methods in each class for basic data functions – the options being “Create me a new non-database-backed object X” “I’ve set up the new object, insert it into the DB” “give me an iterator of all database-backed objects matching this arbitrary query”, “update the appropriate row with the changes I’ve made to this object”, “delete this object from the DB,” and “I’m doing something unusual, just run this SQL query”.

    I honestly really liked it, it made things smooth. Maybe it was the lack of hesitation about dropping back to SQL for stuff where you needed SQL, but I never had issues with it and it seemed to me like it made life pretty straightforward.


  • Yah, 100% agree. So in my case, Typescript is actually a better fit niche-wise… but I finally reached the point where I didn’t want to cope anymore with flawed things it was inheriting from Javascript, so it was especially ironic to me when I saw this and thought maybe I’m not the only one, only to discover that the message was “SIIIKE we love the flawed things! It’s the improvements we’re getting rid of.”

    I mean every project is different and they’ve got a right to do what they want. It was just a hilarious surprise for me.


  • I clicked, sorta interested in the topic because as it happens I just abandoned Typescript in favor of learning Go for a little nascent project I’m working on. (We do these things not because they are easy, but because they eventually will be good which Typescript+Node apparently never will for my particular project.) Then I saw it was Fireship and clicked back away.

    Now it sounds like you’re saying that what they’re claiming is the issue is the one good thing that happened with Javascript in the last however-many years. Yes, it’s a little tedious to have to straighten out all your types. You know what’s more tedious than that? Having to straighten out all your types, but not getting any feedback about it at compile time and having to figure it out based on mysterious failures, or if you’re lucky explicit exceptions, at runtime.

    Having worked for a while in Javascript, and now for a pretty short time in Typescript, I cannot imagine trying to make a decent-complexity project in pure Javascript. That I believe is why they tend to not really be all that object-oriented and pass strings around for lots of things and be sorta flaky.


  • In my opinion, C is a difficult starter language, but one that sets you up for very good abilities in the future, because a lot of other languages’ core concepts are built on C concepts. It’s all bytes, and if you’re comfortable with bytes then that’ll put you ahead of someone who only knows the general concepts. It’s similar to working construction before you go into architecture – your buildings will be better even if you’re thinking at a higher level than nails and shingles when you do most of your design.

    So, ChatGPT is tuned to sort of do things for you, but you can still have it do the troubleshooting with the right prompting instead of just rewriting:

    GPT-4 Prompt

    I’m trying to understand what’s going wrong with my code – can you point me to the line that’s causing the issue and quickly explain what might be wrong?

    import random
    word_list = ["aardvark", "baboon", "camel"]
    chosen_word = random.choice(word_list)
    
    #Testing code
    print(f'Pssst, the solution is {chosen_word}.')
    
    #Create an empty List called display.
    #For each letter in the chosen_word, add a "_" to 'display'.
    #So if the chosen_word was "apple", display should be ["_", "_", "_", "_", "_"] with 5 "_" representing each letter to guess.
    
    
    display = ["_"] * len(chosen_word)
    
    
    guess = input("Guess a letter: ").lower()
    
    #If the letter at that position matches 'guess' then reveal that letter in the display at that position.
    #e.g. If the user guessed "p" and the chosen word was "apple", then display should be ["_", "p", "p", "_", "_"].
    
    for letter in chosen_word:
        if guess == letter:
            for i in range(len(chosen_word)):
                display.insert(i, guess)
    
    print(display)
    

    GPT-4’s response

    The problem with your code is in this segment:

    for letter in chosen_word:
        if guess == letter:
            for i in range(len(chosen_word)):
                display.insert(i, guess)
    

    The logic you’re using here is:

    • For each letter in chosen_word,
    • If guess matches the letter,
    • Insert the guessed letter at every index of the chosen_word.

    This will make the display list longer than it should be, and the letters will not replace the underscores but instead will be added alongside them.

    Instead, you should check if the guessed letter matches a letter in the chosen word at a specific position, and if it does, replace the underscore at that position in the display list.

    Here’s the corrected segment of code:

    for i in range(len(chosen_word)):
        if chosen_word[i] == guess:
            display[i] = guess
    

    With this, the guessed letter will replace the corresponding underscore in the display list.


  • So - ChatGPT is great for breaking down concepts like this and answering questions about the basics until you get the hang of it. I would recommend crafting some programs while asking it for help on anything you get stuck with, until you can craft the programs without involving it (and still you can paste the programs into it and ask for pointers / fixes that it can see). I’m currently learning Go with assistance from ChatGPT and it’s hugely useful.

    One other angle you could come at it from – this might venture into unpopularopinion territory, but I would actually recommend learning C at a very early stage. It’ll be tedious to make nontrivial programs with it, so you may not want to stick with it for your real projects, but since everything is bytes and pointers it gives you a chance to get extremely solid with the fundamentals before you start mucking around with slices / hashes / etc. I would recommend to try to get this particular problem working using C, which will be more work, but then when you come back and learn the Python concepts I think they’ll make a lot of sense and you’ll feel capable with them. IDK if it’ll work that way for you, but that’s what I did and I feel like it was a good way to go.

    Best of luck + keep plugging