orsetto

joined 2 years ago
[–] orsetto@lemmy.dbzer0.com 1 points 2 weeks ago

I mean for now it's not being requested to add other languages beside italian and english, and i'm pretty sure my employer will never care about languages he doesn't speak, so chances of languages that require some work other than translations are basically null.

[–] orsetto@lemmy.dbzer0.com 6 points 2 weeks ago (2 children)

Sorry, I didn't think to add in the post that the translations are in fact of user generated content, and are themselves provided by users.

Project Fluent is still a good resource tho, thank you.

And also yeah, I'll use a better schema for language tags, that's a clear fault

Using an ID instead of the text content itself as part of the PK should be a no-brainer. Languages evolve over time, and translations change. PKs should not.

~~I still don't get why having a separate table for languages is useful. I mean, even if the translation changes, the language itself will remain the same, right?~~

Oh, right. Taking into account language variants makes VERY obvious why I'd want to use a table to store them.

people tend to believe that translating is enough to localize. It is not.

Onestly, I just hope that won't be something i should have to worry about. The rest of the codebase is as shitty as it gets, and I don't want to be the one to refactor it for proper localization. I'm implementing a new feature that allows me some degree of movement to think about a good design for that, and new, features, but this is as far as I'll go (Yes I know I probably sound like an ass but it really is that bad)

[–] orsetto@lemmy.dbzer0.com 2 points 2 weeks ago (3 children)

But why would I need that? (Onest question, I hope I don't sound rude)

I mean, I could easily retrieve the list of available languages, and it makes it faster to delete them using an ON DELETE CASCADE (right?), but it also complicates stuff a bit for general use

[–] orsetto@lemmy.dbzer0.com 2 points 2 weeks ago

That's probably a good call, thanks :)

[–] orsetto@lemmy.dbzer0.com 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Shouldn't that be TextContent(TextContentId, OriginalText)? Something like

(then you should make the id a primary key, index originaltext and make the id in the other table a foreign key)

Yup, TextContentId is PK, and I'd set to auto_increment so that i wouldn't have to worrya bout it.

Sure, but the you would have to reference the text via TextContentId in your code, which would be very annoying

Not really, the translations I keep in the database are for entity that would be retrueved from the client with already the translated values instead of ID (should have specified this in the post maybe)

BTW1/2: the translations on the database are for entities on the db (stuff like user generated content, which will also input the translations). For general text on the page I'm using a specific framework, which would be difficult to use for the user generated content, at least how it's set up now (it's angular's ngx-translate)

 

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 10 points 1 month ago

How would you get small cylinder unstuck from the prize at the carnival

[–] orsetto@lemmy.dbzer0.com 7 points 1 month ago

Forgot to clarify, that was reverse engeneered code from the train firmware (i don't remember what it was trying to do)

[–] orsetto@lemmy.dbzer0.com 20 points 1 month ago (2 children)

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 2 points 1 month ago (1 children)

Encrypting home is good (although full disk encryption is better and with mint it's still easy enough)

Mint uses some helper scripts to mount/unmount your encfs, so maybe while trying to delete the files you deleted those too, and this would explain the login failing. It's been a while tho so I'm not sure, better to wait for someone else.

 

The following is something I wrote earlier. I don't know the validity of it, and I'm not sure I correctly expressed the concepts of "power" and "rights" after translating them from italian.

--

Lately I had in mind the concept of right. Specifically, the idea Stirner had about it.

When I read The Ego and It's Own, that passage stuck with me.

[omitted unrelated stuff, because I started thinking about other things before writing what follows]

I'm thinking how the whole action of Giorgio Rosa [1] was anarchist in it's essence. He created that island just because he could do it: he had the power to do it.

I'm thinking about how many times I did something just because I could, and because I felt like it. I'm sure that more than once me and that-one-friend answered the question "why?" with "because we can". And I'm thinking how "because I can" is one of the fundamental hackers' "ideology" - mostly.

I'm thinking about how "because I can" is one of the most genuine motive that people have to justify their actions.

And, in fact, what I'm saying is somewhat tied to the concept of right. Right now, the first to decide if I have the power to do something is exactly my right to do it. And my rights, at the same time, are decided by people who have power over me! And so I say that the concept of "right" has no meaning, because I won't allow those people to hold power over me.

[1] (but not in its execution) https://en.wikipedia.org/wiki/Republic_of_Rose_Island

[–] orsetto@lemmy.dbzer0.com 2 points 3 months ago

Oh yeah i figured there were some tools able to do that, i meant to say that you can't substitute one with the other in place without doing some sort of conversion.

[–] orsetto@lemmy.dbzer0.com 2 points 3 months ago

sorry for the late reply. I honestly do not remember what the procedure is. The best thing you can do is look on the internet for a easy to follow guide, or wait for someone else's response

22
Help with sed commands (lemmy.dbzer0.com)
submitted 5 months ago* (last edited 5 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
view more: next ›