6 votes

Fortnightly Programming Q&A Thread

General Programming Q&A thread! Ask any questions about programming, answer the questions of other users, or post suggestions for future threads.

Don't forget to format your code using the triple backticks or tildes:

Here is my schema:

```sql
CREATE TABLE article_to_warehouse (
  article_id   INTEGER
, warehouse_id INTEGER
)
;
```

How do I add a `UNIQUE` constraint?

4 comments

  1. Deimos
    Link
    Does anyone have any experience working with row-level security in databases, especially PostgreSQL? I don't really have any particular questions about it, just wondering if anyone's used it...

    Does anyone have any experience working with row-level security in databases, especially PostgreSQL?

    I don't really have any particular questions about it, just wondering if anyone's used it before and has any thoughts on it. I've been reading about it on and off over the last few days and am getting pretty interested in trying to implement it. The idea that you can make it impossible for users to even select data out of the database that they shouldn't have access to is really compelling.

    5 votes
  2. unknown user
    Link
    Are there any programming languages that support symmetric and stackless coroutines? Most languages I've seen so far support asymmetric coroutines, which can only yield back to parent. And most...

    Are there any programming languages that support symmetric and stackless coroutines? Most languages I've seen so far support asymmetric coroutines, which can only yield back to parent. And most dynamically-typed languages prefer stackfull coroutines.

    4 votes
  3. [2]
    unknown user
    Link
    I'm looking into a couple of things I would eventually want to see implemented for my website. (I know, most of those aren't technically programming questions – they're tech requests – but I have...

    I'm looking into a couple of things I would eventually want to see implemented for my website. (I know, most of those aren't technically programming questions – they're tech requests – but I have no better place to ask.)

    One is a no-bullshit static site generator. Writing HTML by hand is fun up to a point where you have to support a hundred pages over years of development. This point is not yet here, so I have time to prepare.

    Many of the options present on the market either have some good features but lack others, or require too much manual setup to get right, or have way too much overhead. Ideally, my work process would look like this:

    1. I write down the contents of the page I want to see.
    2. I put the resulting file – just content, no HTML necessary (but may still be added should I choose an unconventional thing) – into the folder of the website on my computer.
    3. If I access the folder of the website online (e.g. tfgscool.website/writing/), I see a page from the properly-formatted HTML file, with all the content I put into the folder as well as all the static parts (header, footer, navigation menu etc.).

    Content → Structure → Ready for Use

    Ideally, I'd have to do zero setup. Content format could be plain text, Markdown, or something similarly simple. All of this should also require zero setup from the visitor, and should result in a readable HTML/CSS/JS source code as if it were written by hand.

    Another is a public project tracker that automatically generates a table or a Gantt chart (or plain text that could be formatted into those) from the list of available projects. Said projects would be within a set structure (i.e. Category [→ Subcategory] → Project: Writing → Short Stories → Cybil, or Writing → Frontiers), determined via folder structure.

    I'm okay with having the tracker require a set of files to be maintained, like project status per each project. For example, I would be okay with having a single plain-text file .status within each project's folder, which I can update manually or via GUI to reflect the project's status. I think I would also be okay with a centralized project data file, e.g. at the root of the folder structure.

    This project tracker should be accessible from both a central page (i.e. status of all projects) and from each project's page (i.e. status of this particular project). Client-side processing is undesirable, so server-side rendering is prioritized.

    The third thing I'm looking for is a text diffing engine one step ahead of what Git does. Per-line tracking is too macro: I want to be able to get all instances of change within the text in a simple format (Markdown, JSON...) that I can then transform to my own liking (most likely to a HTML file that displays the changes via native markup).

    I also want the engine to track separate committed versions for each unique page and be able to fetch them (and display the differences between each historic page and the current version) at user's request. Again, no client-side processing would be strongly preferable.

    If any of this is a thing that exists, please give me the link. If I can build any of this myself, please let me know how.

    2 votes
    1. Deimos
      (edited )
      Link Parent
      Diffing is complex, and there are a lot of libraries with different approaches and capabilities. As an example of something that might be helpful and probably available in other languages too,...

      Diffing is complex, and there are a lot of libraries with different approaches and capabilities. As an example of something that might be helpful and probably available in other languages too, Python's standard library has this "get opcodes" capability in its standard library.

      That gives a list of "operations" you have to perform to turn one string into another, like "replace these characters", "insert these characters here", and so on. You'd be able to convert something like that to whatever formatting you want.

      3 votes