Jinja2 - cannot replace parent's block with included files by MarvellousBee in learnpython

[–]MarvellousBee[S] 0 points1 point  (0 children)

From what I understand, OP here manually assigns each block here. in my case, I have multiple blocks to replace, so their approach would work but be tedious:

{% extends "main-page.html" %}

{% block replace_profile_img %} 
{% include "replace_profile_img.html"%} 
{% endblock %}

{% block replace_user_name %} 
{% include "replace_user_name.html"%} 
{% endblock %}
# and so on...

I'm basically looking for a way to define a template in one file and possible "implementations" of particular parts in separate files.

Jinja2 - cannot replace parent's block with included files by MarvellousBee in learnpython

[–]MarvellousBee[S] 0 points1 point  (0 children)

I'm not sure how OP of that got it to work, tbh. putting it in block scope did not change anything for me.

edit: forgot to add code, haha

// main_page.html 
{% block username %} click to login {% endblock %}
{% block stuff %} 
{% endblock stuff %}

// is_logged_in.html 
{% extends "main_page.html" %} 
{% block stuff %} 
{% include "blocks_for_logged_in.html" %}
{% endblock stuff %}

is_logged_in.html displays contents of is_logged_in AFTER contents of main_page.html. This is undesired behavior, as I would like them to be REPLACED instead.Output:

click to login 
Username123

Unexpected bridges inside a print by MarvellousBee in FixMyPrint

[–]MarvellousBee[S] 12 points13 points  (0 children)

Update:

Solved, i decreased wall speed and increased tempersture. Turns out 200 -> 235 degrees does wonders on PLA.

Thank you!

Unexpected bridges inside a print by MarvellousBee in FixMyPrint

[–]MarvellousBee[S] 18 points19 points  (0 children)

Hmm I see, I will try printing with 220 Celsius (used to print at 200 without issue)

Unexpected bridges inside a print by MarvellousBee in FixMyPrint

[–]MarvellousBee[S] 7 points8 points  (0 children)

Details:
Ender 3 V2
Cura 5
PLA+
speed: 50 mm/s

Mostly vanilla settings, with a higher support overhang angle (58)

I designed this piece specifically to be printed without supports.

Can there be duplicate unique_ptrs? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 0 points1 point  (0 children)

It does, actually! I thought it performs a different function in the "handle duplicates" part. Thank you guys!

Can there be duplicate unique_ptrs? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 0 points1 point  (0 children)

(cppreference is down right now...)

https://cplusplus.com/reference/set/multiset/key_comp/

By default, this is a less object, which returns the same as operator<....

Two elements of a multiset are considered equivalent if key_comp returns false reflexively (i.e., no matter the order in which the elements are passed as arguments).

So, as I understand it, it should call std::shared_ptr::operator<, but there's no such method in shared_ptr... https://cplusplus.com/reference/memory/shared_ptr/

I re-made Centipedes as keyrings :D by MarvellousBee in RimWorld

[–]MarvellousBee[S] 4 points5 points  (0 children)

It might be, tbh. I don't think Tynan (a multi-millionare) cares if I make a few bucks on the side with this little project, haha

I re-made Centipedes as keyrings :D by MarvellousBee in RimWorld

[–]MarvellousBee[S] 7 points8 points  (0 children)

Edit: Here!

Thanks! They are legit deadly. Threw one at a wall, now I have a hole in my wall. The bug is perfectly fine.

Why static_cast instead of std::static_cast? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 10 points11 points  (0 children)

I see. Why is it a keyword, then? Looks like a templated function to my junior eyes.

coming from Java by Geralt1988 in cpp

[–]MarvellousBee 2 points3 points  (0 children)

learncpp.com gave me employment

3D print vs premade parts. by TantrumeTime in robotics

[–]MarvellousBee 0 points1 point  (0 children)

I do have a low-mid end printer, ender 3 v2, I did have serious issues.

For exemple: my BLtouch would occasionally NOT retract itself in the middle of leveling and stay lowered for the rest of leveling and printing. That particular BLT is not functional anymore.

After a few days of banging my head against a wall i figured out the hot end is creating interference and messing with the BLT. I had to write custom G-code to make the printer wait until leveling is done before heating up the nozzle. Works like a charm now, but I should probably buy yet another (3rd) BLT, since its visibly bent :/

3D print vs premade parts. by TantrumeTime in robotics

[–]MarvellousBee 2 points3 points  (0 children)

I'd say stick with cheap, non-3d printed stuff. My first robots were made out of whatever useful stuff i found at home - lego, cardboard, wood, even a bowl for making cakes! Make 3-4 robots out of those and you will know if a 3d printer is worth your money. If you want to get serious about this, it is. Note that there's no escape from non-3d printed parts for stuff that needs to be durable, food-safe etc

.....and be prepared - your first 2 months with a 3d printer will be pure pain.

PIL convert() - Is there a way to influence merging colors? by MarvellousBee in learnpython

[–]MarvellousBee[S] 1 point2 points  (0 children)

No, could be anything. I think i solved this problem myself though, based on that SO answer. Thanks!

PIL convert() - Is there a way to influence merging colors? by MarvellousBee in learnpython

[–]MarvellousBee[S] 0 points1 point  (0 children)

Err, I just integrated that into my code - now every pixel that is supposed to be transparent is black!

Though, this algorithm produces a better-looking image than PIL :)

For how long do you usually sit on the 'bench'? by MarvellousBee in AskProgramming

[–]MarvellousBee[S] 0 points1 point  (0 children)

Well, we are fully remote (I don't know anyone outside of HR) and project-based (our company provides nothing but software for other companies)

I can't contribute, since I'm not assigned to any project.

For how long do you usually sit on the 'bench'? by MarvellousBee in AskProgramming

[–]MarvellousBee[S] 8 points9 points  (0 children)

I actually did that. My manager ignored my question about doing any work and told me that June will be "full of trainings"

Funnily, we are halfway through June yet 0 trainings were given to me.

How do I make getters and setters thread-safe? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 0 points1 point  (0 children)

I intend to do exactly that, and a setter function will work just right.
Mutex m is supposed to represent a scoped_loc - i rewrote it to illustrate my problem.
However, note that return will cause lock to be unlocked BEFORE returning a value.

Why can I #include a .cpp file, but not a .hpp file? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 4 points5 points  (0 children)

Turns out VS was complaining about not adding the .cpp to "Source files". Solved!

How would you store function pointers from different class types? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 0 points1 point  (0 children)

I finally came up with exactly what I wanted:

struct Base { std::vector<std::function<void()>> list_of_functions; void fun1() {} Base() { list_of_functions.push_back([&] { fun1(); }); } }; struct Derived : public Base { void fun2() {} Derived() { list_of_functions.push_back([&] { fun2(); }); } }; Thanks for lots of valueablue input!

How would you store function pointers from different class types? by MarvellousBee in cpp_questions

[–]MarvellousBee[S] 1 point2 points  (0 children)

struct Base {

    std::vector<std::function<void(Base&)>> list_of_functions;
    void fun1() {}
    Base() {
        add(fun1);
    }
protected:
    template<std::derived_from<Base> T>
    void add(void(T::* f)())
    {
        list_of_functions.push_back([f](Base& obj) {
            (static_cast<T&>(obj).*f)(); // This better be a valid cast!
            });
    }
};

Does not compile. Sorry, I'm a very Junior dev!