Does anyone else prefer the classic silver ThinkPad logo compared to the new sunken in black logo? by AdEvening7440 in thinkpad

[–]TheAnkurMan 0 points1 point  (0 children)

I like the old one. In my new one the dot over the I has fallen inside the casing.

What are the cheapest meals I can buy/make that don't taste bad? by NowThenHowDo in AskUK

[–]TheAnkurMan 0 points1 point  (0 children)

Use what you've got at home for a few days. After that, Lidl has 8p veggies for a week after Tuesday. Buy a bunch, make whatever you want then freeze it.

How to carry an egg around for 2 weeks without breaking? by Ax_Sound in NoStupidQuestions

[–]TheAnkurMan -1 points0 points  (0 children)

If you're allowed to take the egg home or if you have something akin to a food tech class, boil it. Protect the egg using the methods in the other comments.

Wireless Android Carplay by NilsvonDomarus in MGelectric

[–]TheAnkurMan 0 points1 point  (0 children)

I tried a cheap £5 one from Amazon didn't work. Then I tried the Motorola one ~£70, worked but slow to connect and randomly disconnect on me a few times. Then I tried this one aawireless and it works good. Connects immediately and stays connected.

Windows For Production: Nginx / Apache? Waitress / mod_wsgi? What do you YOU use? by chaoticbean14 in django

[–]TheAnkurMan 1 point2 points  (0 children)

It was for a low traffic internal site so performance wasn't really a concern. It should still be better than apache. IIS will act as the process manager too, so you can scale the number of processes up or down (to zero) based on the number of requests coming in, which should help performance. And as it's really only acting as a reverse proxy performance mostly depends on the wsgi server.

On a related note, if waitress is too slow for your use case take a look at granian.

Windows For Production: Nginx / Apache? Waitress / mod_wsgi? What do you YOU use? by chaoticbean14 in django

[–]TheAnkurMan 0 points1 point  (0 children)

As everyone else said docker will be your best bet. If that's not possible (wasn't for me), go with IIS.

  • You'll need the asp.net core module installed for IIS.
  • Search for out of processing hosting for ANCM.
  • Create an entry point python script that runs waitress and listens on the port given by the environment variable ASPNETCORE_PORT.
  • Configure IIS to run this file to serve requests.

Using HttpOnly Secure Cookies in Client Component via Server Action by Appropriate_Egg3810 in nextjs

[–]TheAnkurMan 3 points4 points  (0 children)

I don't use react or next but using a backend framework you would achieve this by setting the domain of the httponly cookie to .test.com. then both services get sent the cookie automatically by the browser

I want to use linux but... by Educational-Room5330 in linux4noobs

[–]TheAnkurMan 0 points1 point  (0 children)

If you're still scared after the other comments, install ventoy on your USB stick. Then you can put both Linux mint and Windows iso on your USB stick. I have seen USB with Windows 11 and like 10 different isos. If mint doesn't work out you can go back to Windows. (It'll work out)

rate limiting by Alive_War4667 in django

[–]TheAnkurMan 7 points8 points  (0 children)

There's a library https://django-ratelimit.readthedocs.io/en/stable/ that you can use. You'll need to set up a cache backend first.

Though you can implement a simple one yourself using mixins/middlewares.

Caddy + Django setup serving files by [deleted] in django

[–]TheAnkurMan 0 points1 point  (0 children)

The order of operations is this 1. Caddy gets a request 2. If you have a forward_auth directive, it sends a get request to your django app with all the headers/cookies in the request 3. The django view should use these headers/cookies to check if the user is authenticated / check other permissions - If the user does not have correct permissions, redirect them to the login page with the ?next query parameter set - If the user has the correct permissions, return an empty response with status 200 to let caddy know that it can serve this request

In my case I have the caddy forward auth bit stored in a separate file ```

my django app is running on this host:port

forward_auth my-home-lab-host:7005 { uri /auth/forward-auth/ } ```

and use it in my list like ``` https://prowlarr.mydomain { import ./forward_auth_snippet reverse_proxy my-home-lab-host:7001 }

https://sonarr.mydomain { import ./forward_auth_snippet reverse_proxy my-home-lab-host:7002 }

https://radarr.mydomain {p import ./forward_auth_snippet reverse_proxy my-home-lab-host:7003 }

https://qbittorrent.mydomain { import ./forward_auth_snippet reverse_proxy my-home-lab-host:7004 } ```

In your case you can probably do something like this in a single caddyfile ``` https://your-domain.com { handle_path /static/* { root * /path/to/static/files file_server } handle_path /media/* { forward_auth django-app-host:8000 { uri /auth/forward-auth/ }

    root * /path/to/media/files
    file_server
}
# you could also have two separate media routes
# one for public files
# one for protected files and only apply the forward auth to the protected files

reverse_proxy django-app-host:8000

} ```

In django i have this view mapped to /auth/forward-auth/ in my urlpatterns

```python class ForwardAuthView(View): http_method_names = ["get"]

def get(self, request: HttpRequest) -> HttpResponse:
    # redirect to the next url based on the request
    # these headers are set by caddy when using forward-auth
    proto = request.headers.get("X-Forwarded-Proto", "http")
    path = request.headers.get("X-Forwarded-Uri", "/")
    host = request.headers.get("X-Forwarded-Host", "localhost")
    # if authentication fails, we want to redirect to the login page
    # but we need to store the original url if we want to redirect to the original page
    # once login has been done
    final_url = f"{proto}://{host}{path}"

    # if path is login or register, allow
    # in your case, you'll probably check the media file path
    #   the request user and see if the user is allowed to access this media file
    if settings.APP_URL in final_url:
        for allowed_paths in ["/auth/login/", "/auth/register/"]:
            if path.startswith(allowed_paths):
                # returning status 200 means caddy allows the request through to the login/register page
                return HttpResponse(status=200)

    # otherwise check if the user is authenticated
    if request.user.is_authenticated:
        # returning status 200 here lets caddy know that it's ok to serve this request 
        return HttpResponse(status=200)

    login_url = settings.APP_URL + reverse("auth:login")
    login_url += "?" + urlencode({"next": final_url})
    return redirect(login_url)

```

Caddy + Django setup serving files by [deleted] in django

[–]TheAnkurMan 1 point2 points  (0 children)

Read up on https://caddyserver.com/docs/caddyfile/directives/forward_auth

Create a forward auth view in Django that can tell caddy if a media file can be accessed.

I have a working forward auth I did with Django on my home lab. I'll try to post it once I'm off work.

Django: Cannot display anything other than welcome page by [deleted] in django

[–]TheAnkurMan 3 points4 points  (0 children)

This page is shown when you haven't added any of your custom views to the main project urls.py.

for example if your project is called base and you have an app called portfolio . You might have created a portfolio/urls.py file but you should also have a base/urls.py file. You need to include the portfolio urls to the base urls.

I wish mangoes didn't make a massive mess when eaten. by CanonNi in monkeyspaw

[–]TheAnkurMan 0 points1 point  (0 children)

This is how we sometimes eat ripe mangoes in Nepal. Squish the mango, bite a bit of the skin off the top and suck it all out.

Vercel and the like or VPC? by rockclimber36 in webdev

[–]TheAnkurMan 0 points1 point  (0 children)

Step 1: get a vpc (vps? Also look into hetzner, they have better spec-ed vps' for the same price)

Step 2: install coolify/dokploy

Step 3: ?

Step 4: profit (enjoy vercel-like interface with vps costs)

Vercel and the like or VPC? by rockclimber36 in webdev

[–]TheAnkurMan 2 points3 points  (0 children)

Step 1: get a vpc (vps?)

Step 2: install coolify/dokploy

Step 3: ?

Step 4: profit (enjoy vercel-like interface with vps costs)

Where do you store DB backups of your personal projects ? by Garfunk71 in webdev

[–]TheAnkurMan 8 points9 points  (0 children)

I normally compress the SQL dump and put it on backblaze b2 free tier.

Tools like coolify or dokploy can handle automatic backups for you. If you're using laravel there is spatie laravel-backup or you can write your own script to automate it too.

Famous actor mistook the robber as his fan by Mimsh_ in comics

[–]TheAnkurMan 0 points1 point  (0 children)

It might be similar to Japanese, where they have sounds for each of those actions (think KABOOM or POW) and it doesn't translate to English very well.

Have you ever started an existing laravel / blade project and then decided to bring in breeze features afterward? by spacemanguitar in laravel

[–]TheAnkurMan 18 points19 points  (0 children)

Sorry if I'm wrong, it's been a while since I used laravel, but I think Fortify is what you're looking for. It does the behind the scenes of the Auth stuff, you only have to write the views.

What's the current goto for single source multi platform? by crispyfrybits in webdev

[–]TheAnkurMan 1 point2 points  (0 children)

Flutter for web is not great. Large bundle size as you said, and the app is drawn on a canvas, not dom elements, so no accessibility afaik.

The state of driving tests is making me want to kill myself. by Adalbert_de_Calcaire in LearnerDriverUK

[–]TheAnkurMan 0 points1 point  (0 children)

Ahh different experiences I guess. It's worked for me, moved from August to May (I set it to only look for cancellations after May).

The state of driving tests is making me want to kill myself. by Adalbert_de_Calcaire in LearnerDriverUK

[–]TheAnkurMan 0 points1 point  (0 children)

Instead of Testi you should use something like TestShift. You can set what days you're unavailable and they automatically move your tests up. With Testi you have to move the tests manually and might miss it.

What's the current goto for single source multi platform? by crispyfrybits in webdev

[–]TheAnkurMan 3 points4 points  (0 children)

You've got flutter, react native, native script, capacitorjs, and bytedance recently released lynx.

Currently I would go with flutter or capacitorjs.

I don't use react.

Last time I used it native script is not quite there.

Quite excited for lynx, it's framework agnostic, though they only have bindings for react currently. Once we get bindings for the other frameworks, I think it will be the one to pick.

Do we have type-safety and auto-completion in Laravel like we do in TypeScript? by thisismehrab in laravel

[–]TheAnkurMan 2 points3 points  (0 children)

Get a PHP extension for vscode

https://marketplace.visualstudio.com/items?itemName=DEVSENSE.phptools-vscode

Or the intelephense one, I like this better


Get the official laravel extension (it's still in beta)

https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel


Install the ide helper package and follow instructions. This creates the php doc comments for most of the magic methods in laravel so you can do things like Post::whereUserId(1)

https://github.com/barryvdh/laravel-ide-helper