9 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?

13 comments

  1. [2]
    dblohm7
    Link
    I'm mentoring a junior engineer at work, and I'm wondering whether anybody has any suggestions for C++ books/training that are more specialized toward an audience who is already familiar with...

    I'm mentoring a junior engineer at work, and I'm wondering whether anybody has any suggestions for C++ books/training that are more specialized toward an audience who is already familiar with C-style syntax but has less experience with native code and C++ footguns.

    7 votes
    1. streblo
      Link Parent
      I am looking for the same thing. We have a few embedded engineers who are transitioning from writing C programs for 8-bit microcontrollers and have never called malloc in their career to writing...

      I am looking for the same thing. We have a few embedded engineers who are transitioning from writing C programs for 8-bit microcontrollers and have never called malloc in their career to writing C++ for quadcore SoMs with 1GB of RAM.

      So far I just have been pointing them to specific blogs/well-written stack overflow posts as topics have come up in code reviews or what have you but it would be nice for them to have something a little more meaty to dive into. I'm considering the abbreviated Stroustrup book but from reading the ToC I'm not sure if a brief tour of the language would cover some of the design philosophies of C++ like RAII or const correctness.

      3 votes
  2. [3]
    acdw
    Link
    I'm working through Practical Common Lisp, which is quite good -- but the practical chapters kind of give it all away, as it were. If anyone has further resources to learn CL more deeply,...

    I'm working through Practical Common Lisp, which is quite good -- but the practical chapters kind of give it all away, as it were. If anyone has further resources to learn CL more deeply, preferably with problems, I'd appreciate it.

    Of course, I'm planning on doing the Lisp Game Jam starting Friday, so I guess that'll throw me right in to the language, feet-first.

    5 votes
    1. [2]
      prairir001
      Link Parent
      How do you find common lisp as a language to get stuff done? I have some experience in ELisp so I was wondering how you find it.

      How do you find common lisp as a language to get stuff done? I have some experience in ELisp so I was wondering how you find it.

      2 votes
      1. acdw
        Link Parent
        Pretty much the only thing I've actually done in lisp has been my Emacs config .. haha. Once I do this game jam I'll report back! I also just realized I can use it to rewrite some bash scripts. So...

        Pretty much the only thing I've actually done in lisp has been my Emacs config .. haha. Once I do this game jam I'll report back! I also just realized I can use it to rewrite some bash scripts. So I'll try that as well :)

        EDIT: just remembered this blog post by Steve Losh. Gonna read this and start hacking.

        2 votes
  3. [5]
    hedy
    Link
    (Go beginner here) Currently working on a small line-mode driven program in Go. From the Python world there's the cmd package which provides a simple framework for doing things similar to what I'm...

    (Go beginner here) Currently working on a small line-mode driven program in Go. From the Python world there's the cmd package which provides a simple framework for doing things similar to what I'm working on. Is there a similar package in Go? I found one that literally says "python cmd package in go" but it was update ~9 years ago or something. Other programs that does line-oriented command parsing I've seen, they use their own framework for building the commands. So maybe I also have to do it myself

    4 votes
    1. unknown user
      Link Parent
      As a senior Go developer, I don't think there is a module like that. Frameworks are just not how we do things in the Go world, and Go modules tend to have a much more coarse granularity, so to...

      As a senior Go developer, I don't think there is a module like that. Frameworks are just not how we do things in the Go world, and Go modules tend to have a much more coarse granularity, so to say, leaving details of implementations to the programmer. For a simple case like the one that the docs of that Python package show you can simply use a bufio.Scanner instance and a map of handlers for each command.

      5 votes
    2. [3]
      csos95
      Link Parent
      It's been years since I wrote any Go, but I used to use spf13/cobra back when I did. I also found urfave/cli which looks a lot more ergonomic to me.

      It's been years since I wrote any Go, but I used to use spf13/cobra back when I did.
      I also found urfave/cli which looks a lot more ergonomic to me.

      2 votes
      1. [2]
        unknown user
        Link Parent
        Judging by the content of the link they provided, I think that hedy meant a library for building interpreters as opposed to flag parsing. For flag parsing there is stdlib's package flag. It's...

        Judging by the content of the link they provided, I think that hedy meant a library for building interpreters as opposed to flag parsing. For flag parsing there is stdlib's package flag. It's simple and is enough for 95 % of use cases, imo.

        3 votes
        1. hedy
          Link Parent
          yeah, I think I forgot to make what I wanted clear, sorry. So not for building a CLI, but more like a sort of "integrated?" parsing and using line-oriented commands and args in a repeated loop or...

          yeah, I think I forgot to make what I wanted clear, sorry. So not for building a CLI, but more like a sort of "integrated?" parsing and using line-oriented commands and args in a repeated loop or a TUI. Thanks for the pointers @ainar-g

          1 vote
  4. [3]
    prairir001
    Link
    Lately I've been working on a few things. The first major thing that I'm working on is a fairly basic mass emailer in elixir. I want to learn elixir and I want to know how basic mass emailers work...

    Lately I've been working on a few things.

    The first major thing that I'm working on is a fairly basic mass emailer in elixir. I want to learn elixir and I want to know how basic mass emailers work and so I decided to make my own. It is going ok. The first big hurdle was sending emails through smtp. I eventually found a library that can send them locally rather than spawning my own.

    The second is for my university. I work as a role to create stuff for my universities computer science society. Lately I have decided that students don't have good resources on what courses to take, how to get involved, and general question help. To fix that Issue I've been making a Wiki for my university using docusaurus v2. It is going fine so far, the tech is almost complete but there is still a large amount of writing to go.

    The next major task for the Wiki is a react component to generate tables of what courses are offered, their prerequisites, and if they are required by different degrees. I am very excited bout this.

    The third project I am currently working on is with a few friends at different universities. We are making a browser extension to easily apply to jobs on university job boards. We have basics working for one university in our region. We are planning on making our server in go with gin gonic and svelte for our frontend.

    On all these projects, there is alot of work that needs to be done but I am enjoying myself so far.

    3 votes
    1. [2]
      edoceo
      Link Parent
      When doing mass email I find its always better to leverage an existing MTA like Postfix rather than build all that. But you still SMTP to your Postfix.

      When doing mass email I find its always better to leverage an existing MTA like Postfix rather than build all that. But you still SMTP to your Postfix.

      2 votes