• 0 Posts
  • 95 Comments
Joined 2 years ago
cake
Cake day: July 13th, 2023

help-circle




  • Mines nothing amazing, really, but i find it handy.

    I 🏴‍☠️ movies. The downloads often come with excess files, images, text, sample videos, etc. The only files I want beside the movie file are subtitle files if they came with the download. And the video files often have obnoxiously long file names with coding info in it, the uploader’s name, etc. And sometimes they get nested weirdly.

    Most of the time, the file name and nesting is not really a big deal since I use plex and does good at ignoring nesting and it typically matches the title to imdb entries even if the file name is full of garbage. But sometimes it doesn’t match correctly and has to be manually fixed. And I just want my files to be clean, readable, and get rid of the bloat.

    So I made a script that walks through my movie libraries, deletes all unneeded files, generates a directory structure dependent on whether or not there are subtitles, and renames the files (and directories) by removing all of the junk words and coding and leaving only the title and release year. Like I said, it’s nothing amazing, but it’s the only utility I ever wrote in it’s entirety for myself that I actually use on the regular.





  • I don’t agree about the movie being better, mostly because I think getting Mark’s inner monologue made much of the humor land so much better than the vocalized stuff in the movie. And they had to handwave a bunch of the more technical sciences and engineering that I found genuinely interesting in the book. But it was very cinematic and a pretty solid adaptation.

    I expect PHM will have to do some more handwaving on the science, which will be unfortunate, but I also think Ryan can deliver on the humor a bit better than Matt did, so I am anticipating that to work quite well. I feel like Ryan’s personality will be a good foil for both the ultra series nature of the threat and the characters dealing with it and the more out there sci-fi elements in PHM (compared to The Martian).



  • Ah yeah, those eggs would be moist. They didn’t have cinnamon and vanilla in them, did they? 😝

    Also, I’ve never air fried sausage links before. I can see how that would probably get the whole sausage cooked through before much browning on the casing happens that way. When pan-searing, the casing gets much darker from direct contact with the pan, and it taken longer for that heat to conduct in the meat in the middle. I usually sear them and get them nice and brown, tossing them around to get even browning all over, and pull them at the first sign that casing is about to split.







  • Even if it weren’t fuck nuts suggesting it, this is surely a bad idea. We need direct sunlight to hit the earth. The problem is the dissipation of the heat generated by that light due to greenhouse gas saturation. Blocking the sunlight in the first place WILL cool the Earth, but with the cost of decreased capacity for plant and algae life to carry out photosynthesis and, thus, remove carbon dioxide from the air and produce oxygen at a minimum. Seems like that would contribute to the greenhouse gas problem, rather than address it, with the additional consequence of reduced yield for crops. I’m sure there would be other consequences too. They have the potential of being MASSIVE!




  • But anyway, I kind of like goto too much. I find it more intuitive to just jump around and re-use parts rather than think about how to do loops without too much nesting.

    Might I introduce you to functions?

    Need to write a prompt to the console and get an input? That could be a function. Need to check if a character matches some option(s)? That’s could be a function. Need to run a specific conditional subroutine? That could be a function. And function names, done correctly, are their own documentation too.

    You main function loop could look almost like pseudo code if you do it right.

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>
    
    char* prompt_for_input(const char* prompt_message) {
        char temp[100];
        printf(prompt_message);
        fgets(temp, 100, stdin);
        temp[strlen(temp)-1] = '\0';
        char* input = malloc(strlen(temp));
        strcpy(input,temp);
        return input;
    }
    
    int string_to_int(char* input) {
        return (int)strtol(input, NULL, 10);
    }
    
    int prompt_for_loop_count() {
        char *input = prompt_for_input("\nI'll loop over this many times: ");
        int loop_count = string_to_int(input);
        free(input);
        return loop_count;
    }
    
    bool prompt_to_do_again(){
        char *input = prompt_for_input("Let's do that again!\nShallow we? (y/n): ");
        bool do_again = (strcmp(input, "y") == 0 || strcmp(input, "Y") == 0);
        free(input);
        return do_again;
    }
    
    void print_and_decrement_counter(int loops_remaining) {
        do {
            printf("Current = %d\n", loops_remaining);
            loops_remaining--;
        } while (loops_remaining > 0);
    }
    
    int main() {
        bool need_to_get_loop_count = true;
        printf("Hello.");
        while(need_to_get_loop_count) {
            int loops_remaining = prompt_for_loop_count();
            print_and_decrement_counter(loops_remaining);
            need_to_get_loop_count = prompt_to_do_again();
        }
        printf("\nBye\n\n");
    }