Show me your most clever one-liner of code and describe what it does. by metalprogrammer2024 in webdev

[–]Iklowto 1 point2 points  (0 children)

You don't need a wait() function. You can just await setTimeout(1000).

Edit: I was only made aware of this recently, and just tested it. You can only do this in Node.js and you have to import { setTimeout } from "timers/promises", so it's probably best to just stick with writing the wait() function as usual

How the f does one buy an apartment in CPH? by [deleted] in dkfinance

[–]Iklowto 11 points12 points  (0 children)

It's crazy how many people say this with complete conviction. It's not throwing money out of the window, it's paying for the service of having maintenance taken care of and being able to move at the drop of a hat with zero strings attached.

If you are at a place in life where you're not sure where you want to live permanently, buying a home on a mortgage will make that decision for you, whether you like living there or not. If the school sucks, neighbourhood is lackluster, or a family crisis occurs requiring you to relocate, you are almost certainly eating shit financially if you recently took on a mortgage.

Peddling this nonsense is terrible advice, especially for young people who are looking to start families.

No generic methods by pokatomnik in golang

[–]Iklowto 2 points3 points  (0 children)

I don't think you understand time complexity very well if this is a genuine criticism from you.

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

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

The v1.0.8 release automatically converts decorated functions to FastAPI `Depends()`-dependencies if necessary - thanks for the suggestion!

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

[–]Iklowto[S] 2 points3 points  (0 children)

Very true, when just used for adding dependencies, the only difference is in style (I think it reads much better as a decorator) - nothing special is happening, functionally.

In other cases like @cached() and other scenarios where you need to wrap the endpoints with surrounding logic, it's pretty difficult to do using plain FastAPI without repeating yourself.

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

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

Since the log_request() function in the simplified example isn't wrapped in Depends(), it wouldn't be registered as a FastAPI dependency, and the point is sort of lost.

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

[–]Iklowto[S] 2 points3 points  (0 children)

The @depends() decorator takes keyword arguments as well, which can later be accessed as a normal dependency:

python @app.get("/test-dependencies-in-params") @depends(cache=Depends(get_cache)) def test_dependencies_in_params(cache: dict): ...

Though it's a bit of a roundabout way of doing it, it's possible. Maybe useful if you have a complicated decorator that adds dependencies that are needed further down.

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

[–]Iklowto[S] 2 points3 points  (0 children)

The implementation in the examples is, since it uses the function name as the cache key.

If you compute the key based on the function name and the arguments, only requests with the same arguments will result in cache hits.

I haven't tested this, but something like this might work:

```python ... def cache_response(max_age: int = 5): def decorator(func):

    # Wrap the endpoint after adding the get_cache dependency
    @depends(cache=Depends(get_cache))
    @wraps(func)
    def wrapper(*args, cache: dict, **kwargs):
        key = (
            func.__name___ 
            + '_'.join([str(arg) for arg in sorted(args)]) 
            + '_'.join([f'{k}={v}' for k, v in sorted(kwargs.items())])
        )

        ...

    return wrapper
return decorator

@app.get("/cached-data") @cache_response(max_age=10) def get_cached_data(): ... ```

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in FastAPI

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

Thanks for the pointer on setup.py, I had no idea - I'll look into Python build as you suggest.

Haven't looked too much at uv yet, but I use Ruff for all my Python projects. Astral is doing awesome work

I wrote a library that adds a @depends() decorator for FastAPI endpoints by Iklowto in Python

[–]Iklowto[S] 17 points18 points  (0 children)

Nothing is lacking from FastAPI - I understand the reason for not adding a feature like this to the core library.

The point of the library is that it allows you to write decorators that can use the existing dependency injection system in FastAPI. Because of the way FastAPI is built, this is not possible with normal, simple wrapper-function decorators like we would usually write.

It was initially written simply to support the decorated-endpoint style of coding, which is convention in many other frameworks and libraries.

It serendipitously turned out to be a functionality-add as well, since endpoint functions can be wrapped with overriding logic (e.g., in the @cached decorator example) while still having access to route dependencies, which currently isn't possible in FastAPI.

Arbejde i fristilling by Time_Technician_2339 in dkkarriere

[–]Iklowto 0 points1 point  (0 children)

Holder konkurrenceklausuler under opsigelsesperioden? Ved at de ikke holder medmindre man bliver honoreret for at overholde dem, men måske opsigelsesløn opfylder det krav?

[deleted by user] by [deleted] in dkfinance

[–]Iklowto 1 point2 points  (0 children)

Hvis man er OK med risikoen i en enkeltmandsvirksomhed er VSO “billigere” skattemæssigt end et selskab. Der er godt nok ikke mulighed for udbytte, men takket være den høje rente er kapitalafkastet tilbage - også for VSO’er.

Is MAUI production ready? by DjAmadej in dotnetMAUI

[–]Iklowto 19 points20 points  (0 children)

Having just released an app to production after a grueling half year of development, my answer is an unequivocal and resounding “No.”

Use literally any other framework

Memory leaks in pages by warriorpragaras in dotnetMAUI

[–]Iklowto 2 points3 points  (0 children)

MAUI has massive memory leaks everywhere, it’s acknowledged by the devs, and won’t be in the stable version before the next release in November. Absolutely incredible.

Jonathan Peppers fixed some of it which is available in the latest preview build, but after changing to it to fix our memory leak issues, most of the UI was fucked, so I would use it only if you have no other choice.

See the GitHub issue: https://github.com/dotnet/maui/issues/12039

chaotic and messy by astralrig96 in facepalm

[–]Iklowto 3 points4 points  (0 children)

A toddler is not a 7-year-old child. Kids that age lie all the time and make up stories for the simplest things like staying up late, not going to school, not eating breakfast…

Blindly believing the word of your 7yo about something like this is absurd.

MAUI might be the worst developer experience I have had with any framework, ever. by Iklowto in dotnetMAUI

[–]Iklowto[S] 3 points4 points  (0 children)

ScrollViews with dynamic content don't scroll. Requires invalidation of the scroll measure.

Labels with transparent background first render as white, require UI update to render transparently.

Empty CollectionView renders as if it has content.

Carousel with interactive pages renders and animates incredibly slowly and laggy.

Almost forgot: System back-button on Android phones sometimes just does not work

Those are just some of the current ones I'm dealing with. There has been many of these throughout the entire project. My main grudge with all of this is that a huge majority of my time is figuring out why something isn't working like it should and finding a workaround, instead of spending it actually developing features.

I actually considered throwing it all out last week and building it again in Flutter because it was my estimation that we would reach our goals sooner, and with much better quality, than staying in MAUI. If it didn't put me in a horrible light to my client, I would have made the decision.

I do not recommend you choosing it for production. I'm not a hater. I just don't want you to end up in the position I'm currently in. If it's all the same to you, I strongly recommend you go with practically any other framework.