21
submitted 3 months ago* (last edited 3 months ago) by orsetto@lemmy.dbzer0.com to c/programming@programming.dev

Soo I'm working on a database that needs to support multiple languages (two for now, but who knows). I stumbled across this blog post that explains how to develop what it calls a "translation subschema" (haven't seen it called like this anywhere else so I don't know if it's actually how you'd call it), which seems like a very nice way of dealing with things.

I'm not very experienced with DB stuff, so it took me a while to fully understand what it was doing, but now that (I think) I do, I'm wondering if I could just ignore the Languages table, and just use a language field in the tables TextContent and Translations, without loosing any functionality. (except of course having a table listing the available languages, which is not however something I'm interested in)

In my head everything would still work, I'd insert stuff with

INSERT INTO TextContent (OriginalText, OriginalLanguage)
VALUES ("Ciao", "it");

DECLARE TextContentId INT = SCOPE_IDENTITY();

INSERT INTO Translations (TextContentId, Language, Translation)
VALUES (@TextContentId, "it", "Ciao");
INSERT INTO Translations (TextContentId, Language, Translation)
VALUES (@TextContentId, "en", "Hello");

and given a TextContentId, i'd retrieve the correct translation with

SELECT Translation FROM Translations WHERE TextContentId = TCId AND Language = "en"

At this point, I'm thinking I could drop TextContent too, and just have a Translations table with TextContentId, Language, and Translation, with (TextContentId, Language) as primary key.

Am I missing something? I'm trying to simplify this solution but I don't want to risk making random errors.

Edit: translations on the DB are for user inserted text, which will also provide translations. The client then will only receive text it the correct language.

[-] orsetto@lemmy.dbzer0.com 20 points 4 months ago

The best part of that presentation was code thst looked like the this

if (day > 15 && month > 11 && year > 2010) {
    // Yes the date is random i don't remember the real one
}
[-] orsetto@lemmy.dbzer0.com 35 points 7 months ago

I'm almost sure the backstory to how you gained this knowledge is "i spent hours debugging something, and that 15 chars limit was the problem"

23
Help with sed commands (lemmy.dbzer0.com)
submitted 8 months ago* (last edited 8 months ago) by orsetto@lemmy.dbzer0.com to c/linux@lemmy.ml

Hi all! I have always only used sed with s///, becouse I've never been able to figure out how to properly make use of its full capabilities. Right now, I'm trying to filter the output of df -h --output=avail,source to only get the available space from /dev/dm-2 (let's ignore that I just realized df accepts a device as parameter, which clearly solves my problem).

This is the command I'm using, which works:

df -h --output=avail,source \
    | grep /dev/dm-2 \
    | sed -E 's/^[[:blank:]]*([0-9]+(G|M|K)).*$/\1/

However, it makes use of grep, and I'd like to get rid of it. So I've tried with a combiantion of t, T, //d and some other stuff, but onestly the output I get makes no sense to me, and I can't figure out what I should do instead.

In short, my question is: given the following output

$ df -h --output=avail,source 
Avail Filesystem
  87G /dev/dm-2
 1.6G tmpfs
  61K efivarfs
  10M dev
...

How do I only get 87G using only sed as a filter?

EDIT:

Nevermind, I've figured it out...

$ df -h --output=avail,source \
    | sed -E 's/^[[:blank:]]*([0-9]+(G|M|K))[[:blank:]]+(\/dev\/dm-2).*$/\1/; t; /.*/d'
85G
[-] orsetto@lemmy.dbzer0.com 17 points 11 months ago

If they keep raising my food subscription I'm gonna start pirating from supermarkets too

[-] orsetto@lemmy.dbzer0.com 34 points 1 year ago

This topic has been pinned, so it's probably important

66
Reject vim return to emacs (lemmy.dbzer0.com)

If you have typed an <ESC> by mistake, you can get rid of it with a C-g.

quoting the emacs tutorial. made me giggle

[-] orsetto@lemmy.dbzer0.com 27 points 1 year ago

Not an ad. No one is trying to sell you anything.

(If you get the notification) you're already using their product.

[-] orsetto@lemmy.dbzer0.com 137 points 2 years ago

I'd like to add this one:

Uhhuh. NMI received for unknown reason 31 on CPU 3.
Dazed and confused, but trying to continue

I get this one like once a week and it always makes me laugh. One day I'll investigate

[-] orsetto@lemmy.dbzer0.com 39 points 2 years ago

That's what a fed in your position would say.

[-] orsetto@lemmy.dbzer0.com 100 points 2 years ago

Happened to me too. Best thing is going to therapy.

This might be caused by bigger problems with your family or work. Or it might just be accumulated stress unrelated to anything in particular.

Therapy helps either way

9
submitted 2 years ago* (last edited 2 years ago) by orsetto@lemmy.dbzer0.com to c/programming@programming.dev

Hi. I'm working on a project that compiles Rust code to WASM, and uses WASI in Node.js to execute it. After some development, I encountered a segmentation fault happening in the wasi.start() function. Considering that I'm kinda new to Node I was only able to understand that it was happening after the call to the exported WASM method returned.

This happened almost two months ago, and while I thought about reporting this to the node devs (WASI's also experimental), I was going to move soon and a lot has gone on.

Yesterday I tried to reproduce the bug on my laptop (that is not my usual development environment, which I don't have access to right now) but I wasn't able to.

I had to start fresh and install all the necessary tools from zero, so my theory is that there was something wrong in the previous environment. I'm also on Gentoo now, while I was running Arch previously.

Unfortunately I don't have the means to check on other environments. I tried to reproduce the old environment, installing the same versions of node and rust, with no luck. I also tested this with the latest versions and everything works fine.

This situation is upsetting. I don't know what's changed that caused the problem to "disappear", so i feel uncomfortable considering this solved. What would be the best approach in this situation?

EDIT: I also just tested it on Debian live, and I still wasn't able to reproduce the segfault

48
[-] orsetto@lemmy.dbzer0.com 33 points 2 years ago

Why do you say it's from the police?

[-] orsetto@lemmy.dbzer0.com 45 points 2 years ago

✨michael jackson✨

[-] orsetto@lemmy.dbzer0.com 18 points 2 years ago* (last edited 2 years ago)

Just finished Stirner's book, it's interesting. (although I do not agree with even half of the things he says)

Marx and Engels wrote about him in "The German Ideology", criticizing him harshly, but the book was only published after their death.

view more: next ›

orsetto

joined 2 years ago