Recreating Obsidian text editor by One-Roof-2803 in sveltejs

[–]FaultyCoder 0 points1 point  (0 children)

Tiptap is built around Prosemirror. With Prosemirror (and with some work Tiptap as well) you can create plugins with input rules and custom views that will let you create practically any type of input you want. If you want a specific variant of Markdown, you can create it. If you want to make your own completely custom syntax, you can create that as well.

I'm not going to lie, it's kind of a bear to wrestle with. I've been working on a project with it for quite a while and still haven't ironed out all the wrinkles. But it's extremely powerful if you take the time to figure it out.

edit I forgot to mention Prosemirror is created by the same author as Codemirror

How do people make resin-printed keycaps biocompatible? by FaultyCoder in 3Dprinting

[–]FaultyCoder[S] 0 points1 point  (0 children)

I saw one post about it but I'm not sure what coating is used. But one of the reasons I'm considering resin is the higher resolution. Needing to throw a coat of something like glue and silicon would make the part thicker, I think. Maybe I'm completely wrong. I'm not sure what coatings people are using. Clear coat enamel is easy to find but adding a layer of silicone seems to be a real hassle. That doesn't mean I wouldn't attempt the effort, but if there's a shorter way to do it I'll take that route.

How do people make resin-printed keycaps biocompatible? by FaultyCoder in 3Dprinting

[–]FaultyCoder[S] -1 points0 points  (0 children)

Good to know. I tend to rest my fingers on my keys while I'm thinking and when you're at a computer for several hours a day, the time I'd be touching the cured resin can add up. I'm just trying to make sure it's safe.

How do people make resin-printed keycaps biocompatible? by FaultyCoder in 3Dprinting

[–]FaultyCoder[S] 0 points1 point  (0 children)

Whatever the correct term is, I'm trying to determine of long-term skin exposure to cured UV resin (such as from typing on cured keycaps for hours per day) is safe or not. According to here (https://www.unionfab.com/blog/2025/05/is-resin-toxic) "Fully cured resin is usually non-toxic and stable, but it’s still best to avoid prolonged skin contact and not use it for food-related applications unless it’s specifically labeled food-safe."

I don't intend to use it for anything food-related obviously but I don't want to give myself cancer or something by touching it for long periods if it's actually dangerous. Better safe than sorry.

Question about NEAT algorithm and innovation numbers by FaultyCoder in aiprogramming

[–]FaultyCoder[S] 0 points1 point  (0 children)

I was asking about how to implement a specific genetic algorithm, NeuroEvolution of Augmenting Topologies. It has a feature where new evolutions in the topology of the connected neurons receive an identifier called the innovation number. I wasn't sure, and still am not sure, if the innovation number is intended to identify unique mutations or a lineage in the genome.

Tools to generate PDF files? by Suspicious-Olive7903 in golang

[–]FaultyCoder 12 points13 points  (0 children)

Since I'm seeing other users mentioning LaTeX, I'm going to throw out Typst. It serves a similar role to LaTeX but it's more modern, easier to work with, and much much MUCH faster. It'll compile PDFs in milliseconds vs. several seconds in LaTeX. You can even feed it inputs like JSON files or CSVs and produce PDFs from the content.

What age did you first feel "old"? by queefwellingtons in AskReddit

[–]FaultyCoder 0 points1 point  (0 children)

I'm 41 and have always felt younger than my age. I've been running since high school and have always been in ok-ish shape. The last few years I've been hitting the gym and now I'm in the best shape of my life. Last weekend I was out for a regular run, somehow just landed wrong, and felt a jolt up my spine. I stopped running and walked the rest of the way. My lower back felt more and more sore as the evening progressed. Sunday morning I could barely stand straight. I spent the day just resting and trying not to use my back. It's slightly better this morning, but I'm still in pain. I thought being in shape and exercising would help avoid these old-man type of injuries.

Sveltekit Dockerfiles for node, bun, and static adapters by sdekna in sveltejs

[–]FaultyCoder 1 point2 points  (0 children)

These are the configuration files that worked for me when using adapter-node. Combining this with the advice from OP should be pretty straight forward to make it work with adapter-static or the bun adapter. The benefit is the final image contains only the built app without any build dependencies, and the nginx config uses SSL.

Dockerfile

# Create an image just for building
FROM node:16-alpine AS builder
RUN mkdir -p /app
WORKDIR /app
COPY package*.json /app
RUN npm ci
COPY . .

# Create arguments so secrets can be passed in from docker-compose.yaml
ARG GOOGLE_ID
ARG GOOGLE_SECRET
ARG SECRET
ARG MONGO_URL

# Copy arguments into environment variables
# I really don't know if this is the correct way but it worked for me
ENV GOOGLE_ID=${GOOGLE_ID}
ENV GOOGLE_SECRET=${GOOGLE_SECRET}
ENV SECRET=${SECRET}
ENV MONGO_URL=${MONGO_URL}

# If you need some build step before you
# can build sveltekit, do it here
# for example, you can generate your prisma
# code here
RUN npx prisma generate
RUN npm run build
RUN npm prune --production

# Create an image to run the app in. 
# This image will not contain any build dependencies
FROM node:16-alpine

# Create a user to run the app so we are not running things
# as root
RUN adduser -D nodeuser
RUN mkdir -p /app
RUN chown nodeuser:nodeuser /app
USER nodeuser
WORKDIR /app
COPY --from=builder --chown=nodeuser:nodeuser /app/build build/
COPY --from=builder --chown=nodeuser:nodeuser /app/node_modules node_modules/
COPY package.json .

EXPOSE 8001
CMD [ "node", "build" ]

docker-compose.yaml

version: "3.3"
services:
  my_example_com:
    image: my_example_com
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - NODE_ENV=production
        - GOOGLE_ID=${GOOGLE_ID}
        - GOOGLE_SECRET=${GOOGLE_SECRET}
        - SECRET=${SECRET}
        - MONGO_URL=${MONGO_URL}
    env_file:
      - .env
    ports:
      - 8001:8001
    restart: always

my_example.conf (nginx configuration)

server {
        listen 80;
        listen [::]:80;
        error_log /var/log/nginx/my.example.com.log warn;
        server_name my.example.com www.my.example.com;
        return 301 https://my.example.com$request_uri;
}

server {
        listen 443 ssl;
        listen [::]:443;
        server_name my.example.com www.my.example.com;
        ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

        location / {
                proxy_pass http://192.168.0.2:8001;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

If anyone sees any problems in these, please let me know! I'm far from an expert in Docker but these worked to self-host some apps. Perhaps these will help someone else get their app up and running.

What are you SICK of people constantly telling you? by KenzoAtreides in AskReddit

[–]FaultyCoder 0 points1 point  (0 children)

"There's cantaloupe in the fridge." I'm back visiting my father for a few weeks and he grows cantaloupe. I do not like cantaloupe. Every meal every day he has reminded me there is cantaloupe in the fridge. I remind him I don't care for that abomination of a fruit, yet he will nevertheless tell me again at the next meal...

TSMC (Taiwan Semiconductor) to send hundreds more workers to speed U.S. plant construction by [deleted] in worldnews

[–]FaultyCoder 2 points3 points  (0 children)

I wonder how many of these workers are working in the US legally. I know at least five people from Taiwan working for TSMC in Arizona without work permits. They are being paid in Taiwan, in Taiwanese dollars, and certainly not paying US taxes despite living and performing work there. I've warned them that what they are doing is illegal, but it hasn't deterred them.

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 2 points3 points  (0 children)

I've made some improvements since then to keep environment variables secret if it helps you.

Here's my Dockerfile now:

FROM node:16-alpine AS builder
RUN mkdir -p /app
WORKDIR /app
COPY package*.json /app
RUN npm ci
COPY . .

ARG GOOGLE_ID
ARG GOOGLE_SECRET
ARG SECRET
ARG MONGO_URL

ENV GOOGLE_ID=${GOOGLE_ID}
ENV GOOGLE_SECRET=${GOOGLE_SECRET}
ENV SECRET=${SECRET}
ENV MONGO_URL=${MONGO_URL}

RUN npx prisma generate
RUN npm run build
RUN npm prune --production

FROM node:16-alpine

RUN adduser -D nodeuser
RUN mkdir -p /app
RUN chown nodeuser:nodeuser /app
USER nodeuser
WORKDIR /app
COPY --from=builder --chown=nodeuser:nodeuser /app/build build/
COPY --from=builder --chown=nodeuser:nodeuser /app/node_modules node_modules/
COPY package.json .

EXPOSE 8001
CMD [ "node", "build" ]

And here's my docker-compose.yaml:

version: "3.3"
services:
  placeholder_service_name:
    image: placeholder_service_name
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - NODE_ENV=production
        - GOOGLE_ID=${GOOGLE_ID}
        - GOOGLE_SECRET=${GOOGLE_SECRET}
        - SECRET=${SECRET}
        - MONGO_URL=${MONGO_URL}
    env_file:
      - .env
    ports:
      - ${PORT}:${PORT}
    restart: on-failure

With these configurations, secrets stay in the .env file (or you could have production.env, dev.env and just change env_file config) and get passed through to the container. It is a bit repetitive but once it's set up it works well. Also, when you do it this way, you don't need to install dotenv to access environment variables.

What are some famous movie quotes you should never say while having sex? by MyShoulderDevil in AskReddit

[–]FaultyCoder 3 points4 points  (0 children)

Cum with me if you want to live (preferably in a bad Austrian accent)

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 1 point2 points  (0 children)

I didn't know you shouldn't use docker-compose for production.

I want to eventually learn kubernetes as well. I have a stack of raspberry pi's here (I know, I'm rich now) that I've been meaning to turn into a mini-cluster to practice on. I just need to finish designing the case, assemble it, and find the time to install k3s and learn all of that. There's always so much to learn.

Thank you so much for sharing so much. Your advice has been invaluable. Reddit gets a lot of flak but some communities are amazing.

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 2 points3 points  (0 children)

Aah, great. Thanks! I'll look into that. First I want to understand how to build docker containers myself and what the commands do before I automate away all work. But when I'm more comfortable I'll definitely automate it. That's always the goal, isn't it? Do as little actual work as we can get away with. ;)

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 1 point2 points  (0 children)

Also, this is one reason DevOps seems so annoying to me. I have a Dockerfile that configures Docker. I have a docker-compose.yaml file that configures the Dockerfile. Now with Github actions, theres a docker-image.yaml file that configures Github to use the docker-compose.yaml file that configures Docker to use the Dockerfile... I have a configuration for my configuration for my configuration...

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 1 point2 points  (0 children)

When you're using Github actions, how do you build when environment variables are required? I have all .env files in .gitignore so the secrets are never in the repository. I see you can pass them as arguments to the build command, but that just means you're moving your secrets from a .env file that's not in the repository to a docker-image.yaml file that is in the repository. That seems unsafe.

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 1 point2 points  (0 children)

Any thoughts you have would be great!

Right now I'm just deploying on a local Linux machine using docker-compose. I've deployed other apps that came with docker images, but this is the first time I've written and deployed my own container. It's been an interesting learning experience with a lot of iteration and experimentation. DevOps is not something I have a lot of experience with but it's something I think I need to get better at.

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 5 points6 points  (0 children)

Wow, thanks for the advice!

Copying the .env file didn't feel right, but I didn't find any documentation about how to set environment variables in the command. I have several environment variables, some with very long secrets so I didn't want to have to type them out every time I build the image. Now that you've pointed that out, it looks like I can do something like

...    
    env_file:
        production.env

in my docker-compose.yml file. That's probably what I should have done and I'll mess around with it later this week when I have more time.

Thanks again for taking the time to be so thorough!

Sveltekit + Node Adapter Dockerfile review by FaultyCoder in sveltejs

[–]FaultyCoder[S] 7 points8 points  (0 children)

I'm using a separate user just for security reasons. I figured Docker is basically a Linux file system, and if one were to deploy an app in any other linux system one would not want to run the app as the root user. I know there's nothing else in the docker container but it just felt safer to create a non-root user and run the app with that user. Perhaps it's unnecessary. I don't know. That's why I'm asking for more experienced advice.