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?

3 comments

  1. [2]
    pocketry
    Link
    I'm trying to create a github.io page and would like some initial guidance. I know I could fumble through and eventually get something working, but I really would like some direction from someone...

    I'm trying to create a github.io page and would like some initial guidance. I know I could fumble through and eventually get something working, but I really would like some direction from someone that knows a little more about front end libraries than me.

    I have a json (https://github.com/dialogueovertime/dialogueovertime.github.io/blob/master/episodes.json) that I would like to display as a table on page (dialogueovertime.github.io). I'm using github pages so I don't have to worry about deployments and security at all.

    I'm familiar with using html/css to build some very basic pages, but want to know how to get started with some good js libraries for taking data from the json into a table. I'm a beginner at js, but am decent at python, so programming concepts at this level don't scare me.

    I'm also looking for a nice way to keep the styling consistent across the page and any future pages I may build out around this. Would tailwind css be good for this?

    As for general page layout, I've played with flex and grid a few years ago and liked it enough to use them again if it makes sense.

    Any general input or direction would be much appreciated. Thanks!

    2 votes
    1. Apos
      Link Parent
      If you want to do a quick static site, you could use eleventy. You can have the JSON be imported as global data and do a nunjucks page that loops over it. nunjucks Here is a good tutorial to get...

      If you want to do a quick static site, you could use eleventy. You can have the JSON be imported as global data and do a nunjucks page that loops over it. nunjucks

      Here is a good tutorial to get started: Making a Simple Web Site with the Simplest Static Site Generator, Level 1.

      A bit closer to what you want to do: Generate Page Content From a Global Data File Using Eleventy. There's a part where you can see how you can put the JSON data right inside the HTML.

      1 vote
  2. archevel
    Link
    Started to learn Rust over the holidays and I'm planning to use it for a code gen project to quickly create a front-end for a webapp based on a spec. So starting out I want to make a parser for...

    Started to learn Rust over the holidays and I'm planning to use it for a code gen project to quickly create a front-end for a webapp based on a spec. So starting out I want to make a parser for the spec and found nom. To start out I want to make a function that accepts ASCII character inputs where the first character is capitalized; i.e Abc and Xyz is fine, but abc and xyz should be rejected.

    This seems to do the trick, but I'm curious if there is a more elegant approach:

    nom::combinators::verify(alpha1, |s| match s.chars().next() { Ok(c) => 'A' <= c && c <= 'Z', _ => false })
    

    Note that alpha1 guarantees that s is at least 1 characters long and consist of ASCII encoded letters. Knowing this I know it would be safe to index directly into the &str with something like s[0], but the compiler doesn't allow it as far as I understand. Anyway, is there a way to write such a parser function in a better way?

    1 vote