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?
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!
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.
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
andXyz
is fine, butabc
andxyz
should be rejected.This seems to do the trick, but I'm curious if there is a more elegant approach:
Note that
alpha1
guarantees thats
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 likes[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?