Hacker Newsnew | past | comments | ask | show | jobs | submit | tobyhinloopen's commentslogin

A great start is to have LLMs use special UNIX users that can’t do anything except that you allowed them to do, including accessing the database with a read only user.

The problem with their example is that you can display linear image data just fine, just not with JPEG. Mapping linear data to 255 RGB that expects the gamma-corrected values is just wrong. They could have used an image format that supports linear data, like JPEG-XL, AVIF or HEIC. No conversion to 0-255 required, just throw in the data as-is.


They did:

> Sensor data with the 14 bit ADC values mapped to 0-255 RGB.


> You're not going to try and extract a timestamp from a uuid.

I totally used uuidv7s as "inserted at" in a small project and I had methods to find records created between two timestamps that literally converted timestamps to uuidv7 values so I could do "WHERE id BETWEEN a AND b"


Absolutely. I bought a new Roomba after my old one died and was surpised to learn it's basically unchanged and still just as stupid as the old one. Returned it, got a Dreame X40. Much better, night and day difference.


> Take it from a massive TypeScript nerd: JSDoc is not an anti-TypeScript position to take. It is the same powerful static analysis without the build step.

Ahum https://nodejs.org/en/learn/typescript/run-natively


Technically there's still a build step happening under the hood! But another benefit of shifting TS into JSDoc comments is that it also works in browsers. That being said, while I understand the aversion to unnecessary complexity, I'm personally fine with a build step to remove TS. It's a much nicer syntax IMO. And with tools like `swc` for type stripping, it's pretty snappy too.


that's limited to node. won't work in a browser.


Oh right I forgot Javascript also runs in a browser


I have never known! On my web apps, I _try_ to give buttons that perform an irreversible action a different color, like saving, updating, creating, deleting etc


I use outline buttons for "link" buttons and colored-in ones for those that perform actions.


Link to live demo linked on the github -> https://bntre.github.io/reverse-perspective-threejs/

Well that is just the right amount of nauseating, trippy and interesting


For an extra dose of nausea, there's also a cross-eye stereo version: https://bntr.planet.ee/temp/rp/

(Alt + mouse wheel changes the eye distance)


That's so cool! I want more cross-eye content.


> City living means we don't know what the other person on the road is thinking.

Usually something like "I hope I'm not late for my job" or "The weather is shit today". Other people aren't that scary.


A lot of people do think that other people are scary.

The UK has got to the point where a lot of people think parents cannot be trusted with their kids (in an IRL discussion multiple people supported the Online Safety Act on the grounds most parents will let their kids watch porn) let along strangers.


To be fair, combine "I hope I'm not late for my job" with a 2.5 ton wheeled death machine, and it's pretty scary even without bad intent.


"I how I'm not late" is a bad mix when operating heavy machinery like a car around places where children are supposed to be able to walk safely.


We use it like this:

    CREATE TRIGGER notify_events_trg AFTER INSERT ON xxx.events FOR EACH ROW EXECUTE PROCEDURE public.notify_events();

    CREATE FUNCTION public.notify_events() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    BEGIN
      PERFORM pg_notify('events', row_to_json(NEW)::text);
      RETURN NEW;
    END;
    $$;

And then we have a bunch of triggers like this on many tables:

    CREATE TRIGGER create_category_event_trg AFTER INSERT OR DELETE OR UPDATE ON public.categories FOR EACH ROW EXECUTE PROCEDURE public.create_category_event();

    CREATE FUNCTION public.create_category_event() RETURNS trigger
        LANGUAGE plpgsql SECURITY DEFINER
        AS $$
    DECLARE
      category RECORD;
      payload JSONB;
    BEGIN
      category := COALESCE(NEW, OLD);
      payload := jsonb_build_object('id', category.id);
      IF NEW IS NULL OR NEW.deleted_at IS NOT NULL THEN
        payload := jsonb_set(payload, '{deleted}', 'true');
      END IF;
      INSERT INTO xxx.events (channel, inserted_at, payload)
        VALUES ('category', NOW() AT TIME ZONE 'utc', payload);
      RETURN NULL;
    END;
    $$;
We found no notable performance issues. We have a single LISTEN in another application. We did some stress testing and found that it performs way better than we would ever need


Thanks for the report. For that use-case (if you have a single application using a single connection with a LISTEN) then it's expected that is should perform well, since then there is only a single backend which will be context-switched to when each NOTIFY signals it.


Just out of curiosity, could you try to frame in what context this would or would not work? If you have multiple backends with multiple connections for instance? And then if we start with such a "simple" solution and we later need to scale with distributed backends, how should we do this?


In the linked "Optimize LISTEN/NOTIFY" pgsql-hackers, I've shared a lot of benchmark results for different workloads, which also include results on how PostgreSQL currently works (this is "master" in the benchmark results), that can help you better understand the expectations for different workloads.

The work-around solution we used at Trustly (a company I co-founded), is a component named `allas` that a colleague of mine at that time, Marko Tikkaja, created to solve our problems, that massively reduced the load on our servers. Marko has open sourced and published this work here: https://github.com/johto/allas

Basically, `allas` opens up a single connection to PostgreSQL, on which it LISTEN on all the channels it needs to listen on. Then clients connect to `allas` over the PostgreSQL protocol, so it's basically faking a PostgreSQL server, and when clients do LISTEN on a channel with allas, allas will then LISTEN on that channel on the real PostgreSQL server on the single connection it needs. Thanks to `allas` being implemented in Go, using Go's efficient goroutines for concurrency, it efficiently scales with lots and lots of connections. I'm not a Go-expert myself, but I've understood Go is quite well suited for this type of application.

This component is still being used at Trustly, and is battle-tested and production grade.

That said, it would of course be much better to avoid the need for a separate component, and fix the scalability issues in core PostgreSQL, so that's what I'm currently working on.


For folks like myself, who don't know much about DB internals but know a bit about Kubernetes, this sounds very akin to the K8s API watch cache.

https://danielmangum.com/posts/k8s-asa-watching-and-caching/


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: