Pastadome - A place for friends who are being too friendly in other threads.

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
C++:
#include <array>
#include <vector>
#include <string>
#include <string_view>
#include <random>
#include <iostream>

std::string generate_insult(std::mt19937& rgen){
    std::vector<std::string_view> insults = {
        "manlet",
        "incel",
        "virgin",
        "loser",
        "basement dweller",
        "jabroni"
    };

    const unsigned insult_count = (rgen() % insults.size()) + 1;

    std::string insult;
    for(unsigned i = 0; i < insult_count; ++i){
        unsigned idx = rgen() % insults.size();
        insult += " " + std::string(insults[idx]);
        insults.erase(insults.begin() + idx, insults.begin() + idx + 1);
    }
    insult += 's';
    return insult;
}

std::string generate_HHH_post(std::mt19937& rgen){

    std::array<std::string_view, 5> excuses = {
        "you're all hypocrites!",
        "if Trump did this you'd love it!",
        "I only respond because you keep tagging me!",
        "I'm not obsessed, you're obsessed!",
        "neg rating me proves I'm right!"
    };

    std::string_view excuse = excuses[rgen() % excuses.size()];
    return "A&H posters are just a bunch of" + ::generate_insult(rgen) + " and " + std::string(excuse);
}

int main(){
    std::random_device rdev;
    //use random device noise to seed PRNG
    std::mt19937 rgen(rdev());

    std::cout << ::generate_HHH_post(rgen) << '\n';
    return 0;
}
Fixed and streamlined just for you, friend.
This is nice, but this should be written in C. Low level languages are more in line with what Hulkamania is all about
 
I didn't feel like dealing with malloc and realloc just for a shitpost, but since I have nothing better to do, I might just give it a go.
I am kind of honored that @FreeYourDoodies is so mad at me for not liking Trump that they wrote a whole program just to imitate me.
 
I didn't feel like dealing with malloc and realloc just for a shitpost, but since I have nothing better to do, I might just give it a go.
Hogan needs no fancy dynamic allocation:

C:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define EXCS_LEN 5
const char* const EXCS[] = {
    "you're all hypocrites!",
    "if Trump did this you'd love it!",
    "I only respond because you keep tagging me!",
    "I'm not obsessed, you're obsessed!",
    "neg rating me proves I'm right!"
};

#define INSLTS_LEN 5
const char* INSLTS[] = {
    "manlet",
    "incel",
    "virgin",
    "loser",
    "basement dweller"
};

int main() {
    srand(time(NULL));
    printf("A&H posters are just a bunch of");
    int r;
    for (int i=0; i <= rand() % INSLTS_LEN; i++) {
        do {
            r = rand() % INSLTS_LEN;
        } while(INSLTS[r] == 0);
        printf(" %s", INSLTS[r]);
        INSLTS[r] = 0;
    }
    printf("s and %s\n", EXCS[rand() % EXCS_LEN]);
   
    return 0;
}
 
Hogan needs no fancy dynamic allocation:

C:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define EXCS_LEN 5
const char* const EXCS[] = {
    "you're all hypocrites!",
    "if Trump did this you'd love it!",
    "I only respond because you keep tagging me!",
    "I'm not obsessed, you're obsessed!",
    "neg rating me proves I'm right!"
};

#define INSLTS_LEN 5
const char* INSLTS[] = {
    "manlet",
    "incel",
    "virgin",
    "loser",
    "basement dweller"
};

int main() {
    srand(time(NULL));
    printf("A&H posters are just a bunch of");
    int r;
    for (int i=0; i <= rand() % INSLTS_LEN; i++) {
        do {
            r = rand() % INSLTS_LEN;
        } while(INSLTS[r] == 0);
        printf(" %s", INSLTS[r]);
        INSLTS[r] = 0;
    }
    printf("s and %s\n", EXCS[rand() % EXCS_LEN]);
  
    return 0;
}
That's cool, but you can't pass the post around as a char* if you just send it directly to standard output. Get a load of this autism:
C:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>

static char* generate_insult(void){
#define NUM_INSULTS 6
        const char *insults[] = {
                "manlet",
                "incel",
                "virgin",
                "loser",
                "basement dweller",
                "jabroni"
        };
        const unsigned insult_len = (rand() % NUM_INSULTS) + 1;

        /* average length (including null terminator) of string literals in array is 8.5 characters */
        size_t bytes_allocated = 10 * insult_len + 1;
        char *insult_str = malloc(bytes_allocated + 1);
        if(!insult_str)
                return NULL;
        /* make sure first byte is a null terminator */
        insult_str[0] = '\0';

        for(unsigned i = 0; i < insult_len; ++i){
                unsigned idx;
                do{
                        idx = rand() % NUM_INSULTS;
                } while(insults[idx] == NULL);
                /* expand the allocated memory block if necessary */
                if(strlen(insult_str) + strlen(insults[idx]) + 2 > bytes_allocated){
                        char *ptr = realloc(insult_str, bytes_allocated + strlen(insults[idx]));
                        if(ptr){
                                bytes_allocated = bytes_allocated + strlen(insults[idx]);
                                insult_str = ptr;
                        } else{
                                free(insult_str);
                                return NULL;
                        }
                }

                char *offset = insult_str + strlen(insult_str);
                sprintf(offset, " %s", insults[idx]);
                insults[idx] = NULL;
        }
        if(strlen(insult_str) + 2 > bytes_allocated){
                char *ptr = realloc(insult_str, bytes_allocated + 1);
                if(ptr){
                        ++bytes_allocated;
                        insult_str = ptr;
                } else{
                        free(insult_str);
                        return NULL;
                }
        }
        size_t offset = strlen(insult_str);
        insult_str[offset] = 's';
        insult_str[offset + 1] = '\0';
        return insult_str;
}

char* generate_HHH_post(void){
#define NUM_EXCUSES 5
        char *excuses[NUM_EXCUSES] = {
                "you're all hypocrites",
                "if Trump did this you'd love it",
                "I only respond because you keep tagging me",
                "I'm not obsessed, you're obsessed",
                "neg rating me proves I'm right"
        };

        //seed PRNG with current time
        srand(time(NULL));
        char *insult = generate_insult();
        if(!insult)
                return NULL;
        const size_t insult_len = strlen(insult);

        const char *excuse = excuses[rand() % NUM_EXCUSES];
        const size_t excuse_len = strlen(excuse);
        const size_t post_len = sizeof("A&H posters are just a bunch of") - 1 + insult_len + sizeof(" and ") - 1 + excuse_len + sizeof("!");

        char *post_str = malloc(post_len);
        if(!post_str){
                free(insult);
                return NULL;
        }
        sprintf(post_str, "A&H posters are just a bunch of%s and %s!", insult, excuse);
        free(insult);
        return post_str;

}

int main(void){
        char *HHH_post = generate_HHH_post();
        if(!HHH_post){
                fprintf(stderr, "Unable to allocate memory!\n");
                return -1;
        }
        printf("%s\n", HHH_post);
        free(HHH_post);
        return 0;
}
 
What's your opinion on zoodles?
zucchini-noodles-946898470-5ae249aeff1b7800363048f2.jpg
 
What's your opinion on zoodles?
View attachment 1705829
Obviously it doesn't count as pasta, but if people are using it to replace pasta for low-carb diets then I'll begrudgingly give it a pass. It's not bad when served in a tomato-based sauce with some red or orange peppers and diced chicken.

Fun fact, you call them zucchinis, hence zoodles, but here they're called courgettes so we call it courgetti.
 
Obviously it doesn't count as pasta, but if people are using it to replace pasta for low-carb diets then I'll begrudgingly give it a pass. It's not bad when served in a tomato-based sauce with some red or orange peppers and diced chicken.

Fun fact, you call them zucchinis, hence zoodles, but here they're called courgettes so we call it courgetti.
Courgetti sounds better.
 
Back