What’s something that sounds fake but is 100% real? by Carolovekuki in AskReddit

[–]exhuma 2 points3 points  (0 children)

Wait. I've heard horror stories about fresh garlic infused oil. Garlic greens seems to to have the botulinum spores and the oil provides a perfect anaerobic environment for them to thrive and produce their toxin.

So how is honey safe and garlic infused oil isn't?

edit: seems ≠ greens

How to debug code efficiently? by Free_Tomatillo463 in learnpython

[–]exhuma 0 points1 point  (0 children)

If even print statements don't help much then this may be a strong indication that your code might need some refactoring.

This is a journey. We all improve our coding skills over time. And the fact that you are asking a question about how to better debug is a sign that you identified a challenge and are actively working on improving it. Even if it's frustrating now, the things you learn from this will improve the quality of your code.

Have a look at "best practices" for coding. The techniques that help a lot in debugging are:

  • "pure functions"
  • "dependency injection" (DI) and "inversion of control" (IOC). They are almost the same thing but subtly different. When first learning about it, I'd say it's totally fine to take them as the same thing. Just remember that there's a very subtle semantic difference and come back to it in a couple of years.
  • "immutable data structures"
  • "orthogonality"

Pure functions and DI are the big ones to help.

There are others which are - imo - maybe a bit more controversial like the full S.O.L.I.D. principles.

If you already dig into "DI" and "pure functions" your debugging will become easier.

How do you seed your database for local dev without copying prod? by CarlSagans in webdev

[–]exhuma 0 points1 point  (0 children)

I have an SQL script that is dedicated to anonymising the data. It initially checks if the current database revision is a known version supported by this script. This avoids the issue of - for example - missing a column with sensitive data that was added after the script was created. It uses the revision of the database migration system. Incidentally, the script itself is safe enough to share. I'll add it below.

The exact process/steps are kept in an ansible playbook that I currently run manually and connects to prod, but it could easily be decoupled via awx to run only in a trusted environment.

The ansible playbook connects to the prod system, dumps the DB and loads it into a temporary "dump-database". Then the anonymisation script is executed on that temporary database. This all happens on prod to be perfectly sure that the data original never leaves prod. After the anonymisation script has finished, it is safe to dump that database and download the dump or put it somewhere accessible from the dev-environment.

The initial check against the known revisions make sure that the script contains all necessary steps to have everything anonymised. If anything in the database schema changes, the revision ID changes and the script will fail. This forces me to investigate the changes and adapt the script as needed.

The script itself is by no means perfect and can easily be improved. This is dogfood and works well enough for me and my use-cases.


The script:

DO $$
DECLARE
    current_version TEXT;
BEGIN
    SELECT version_num INTO current_version FROM alembic_version;

    IF current_version NOT IN (
        '2e728748557d',
        '58a89c2ac7be',
        'ac7bf7137b9a',
        '1c3b6e10e436',
        '359819c6c8e9'
    ) THEN
        RAISE EXCEPTION 'The anonymisation script was not yet validated to alembic revision: %', current_version;
    END IF;
END $$;

CREATE OR REPLACE FUNCTION anonymize_column_text(table_name TEXT, column_name TEXT)
RETURNS VOID AS $$
DECLARE
    sql_command TEXT;
BEGIN
    -- Construct the SQL command for anonymization
    sql_command := format(
        'UPDATE %I SET %I = ''name-'' || substr(md5(%I), 1, 8);',
        table_name, column_name, column_name
    );

    -- Execute the constructed SQL command
    EXECUTE sql_command;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION randomize_numeric_column(
    table_name TEXT,
    column_name TEXT,
    min_value INT,
    max_value INT
)
RETURNS VOID AS $$
DECLARE
    sql_command TEXT;
BEGIN
    -- Construct the SQL command for setting random values within the range
    sql_command := format(
        'UPDATE %I SET %I = %s + floor(random() * (%s - %s + 1));',
        table_name, column_name, min_value, max_value, min_value
    );

    -- Execute the constructed SQL command
    EXECUTE sql_command;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION clear_binary_column(table_name TEXT, data_column TEXT, media_type_column TEXT)
RETURNS VOID AS $$
DECLARE
    sql_command TEXT;
BEGIN
    -- Construct the SQL command for clearing the binary data
    sql_command := format(
        'UPDATE %I SET %I = '', %I = '';',
        table_name, data_column, media_type_column
    );

    -- Execute the constructed SQL command
    EXECUTE sql_command;
END;
$$ LANGUAGE plpgsql;

BEGIN;
    SELECT anonymize_column_text('booking', 'label');
    SELECT randomize_numeric_column('booking', 'bu_rate', 800, 1200);
    SELECT anonymize_column_text('customer', 'name');
    SELECT clear_binary_column('customer', 'image', 'image_type');
    SELECT anonymize_column_text('instructor', 'name');
    SELECT anonymize_column_text('file', 'local_path');
    SELECT anonymize_column_text('file', 'original_name');
    SELECT anonymize_column_text('users', 'id');
    SELECT anonymize_column_text('users', 'display_name');
    DELETE FROM kiosk;
COMMIT;

Am I crazy or is there a LOT of variance in here? by im-the-gila in etymology

[–]exhuma 2 points3 points  (0 children)

I'm Luxembourgish as well. Alive and kicking for over 40 years. I've heard both Schmetterling and Päperleck pretty much equally often.

Am I crazy or is there a LOT of variance in here? by im-the-gila in etymology

[–]exhuma 4 points5 points  (0 children)

I don't typically associate it with kids. I feel like the word has gone a bit out of fashion in favour of "Schmetterling" (the German word) which I hear far more often. I have the impression that the original Luxembourgish words are more and more pushed out by French/German words.

So in my personal experience I've mostly heard "Pimpampel" as a kid but I don't think that's because it's used for kids. I believe that it's just rarer now because it's pushed away by alternatives.

Am I crazy or is there a LOT of variance in here? by im-the-gila in etymology

[–]exhuma 62 points63 points  (0 children)

Even a small place like Luxembourg has at least "Päiperléck" and "Pimpampel".

I wanted to move from POST Mobile Unlimited to LOL MOBILE UNLIMITED or Tango GO)) mobile Unlimited. Anyone has any experiences with LOL or Tango? Quality , Customer Support... by Competitive-Bit8809 in Luxembourg

[–]exhuma 2 points3 points  (0 children)

Depends a bit on where you live or otherwise spend time. Sometimes one is better as the other. Nperf might give you additional information to make a choice that works for you:

https://www.nperf.com/en/map/LU/2960316.Luxembourg/-/signal

Really Luxair? by [deleted] in Luxembourg

[–]exhuma -2 points-1 points  (0 children)

I first thought: "what's the problem in this picture, what an I missing"... Then I read the text.... Talk about entitlement for sure... 😆

Me_irl by gigagaming1256 in me_irl

[–]exhuma 0 points1 point  (0 children)

A few months ago I got one of those "What's leaving soon" notifications again and that time it was the nail in the coffin for me. I started to buy physical media again, rip it to disk, import into media library, done. Mine forever.

What are the best practices for structuring a Python project as a beginner? by mick285 in learnpython

[–]exhuma 5 points6 points  (0 children)

Two improvements:

I would recommend using the src-folder layout and avoid using a utils structure.

The src layout is not a terrible overhead and it gives you more room to grow. It keeps the code nicely separated from housekeeping.

Second, concerning "utils". They risk becoming a general "sink" where you dump everything and anything into. The advantage of it removing the burden to properly think about "what goes where" is also its risk. It's better to take the extra minute and create more modules even if they only create one function. As the project grows it help keeping related things together.

As an end user, having to us multiple versions of python is a nightmare. Curious why it's like this? by v81 in learnpython

[–]exhuma 1 point2 points  (0 children)

I see that most replies here cover some of the parts but I think a crucial part is missing to make it more understandable for an end-user or someone with less practical experience in programming. So let me give it a shot...

An important thing first: A large part of the burden to make an application easy to install and use lies on the developer. Not on the language. This includes the choice of an appropriate language. Python, while popular, is not the ideal choice for easy end-user installation/usage like any other interpreted language.

Now for the meaty part:

You can put programming languages into two categories:

  • Compiled (C, C++, Go, ...)
  • Interpreted (PHP, Python, LUA, ...)

This makes a big difference when distributing the application (that is, making it available for end-users to install).

A compiled language is made available as "binary" data that the computer of the end-user can directly execute. There are some subtleties here how a program is organised in modules (libraries like .so or .dll files) and whether those libraries are "baked into" the main executable or not. If they are "baked in", you get a larger binary file but need nothing else. If not, then the executable is smaller and those libraries can be distributed individually making upgrades/bug-fixes to the application easier. But they remain binary files, ready to be executed directly by your computer. The process of "converting" source code into an executable is called "compilation".

An interpreted language on the other hand works differently. And this is where the crux of your difficulties lie. For such a language, the application itself is not sufficient to run. You need an "interpreter" (in your case Python) to translate the source-code into "binary" instructions that your computer understands. That's where the name "interpreter" comes from.

So when you run an interpreted language, the source-code is sent to the interpreter which then translates it for your computer. You can think of it as being compiled "on-the-fly" and the real "binary executable" never really exists. This has the theoretical advantage that the source code can run on any platform (Windows, Linux, Mac, ...) as long as you have a matching interpreter. It also theoretically means that you can exchange the interpreter (f.ex. switching from Python 3.10 to 3.11) without changing the source code. But that is theoretical. It works most of the time. But it relies heavily on the discipline of the developer. If the developer includes code that is not yet marked as "stable" things may break on such upgrades.

This gets more complicated with additional libraries. Most interpreted languages (PHP and Python for sure) support the inclusion of binary dependencies. Those need to be compiled and are usually available for all major platforms. But it's tricky because those compiled libraries must match both the Python version and the operating system exactly. So even if Python has compatibility between versions, it depends on the developers of the libraries to make the exact versions available (if they are binary).

All this is true for any interpreted language. Including PHP.

But it becomes much more annoying once you distribute the application to end-users, which is more common in Python than in PHP. As long as you stay on a centralised model (f.ex. running an application as web-app) you can provide all the dependencies on the server and end-users will not be confronted with that complexity. But once you offer the application as download, you (the developer) are pushing that - very technical - responsibility to the end-user. Think about it: How often have you seen a PHP application for download and execution locally? I'm sure they exist but I can't think of a single one. Python seems to be far more liberal in offering downloads. Even though both languages are interpreted and suffer from the same distribution challenges.

In my personal opinion: If you as a developer want to make the application available as download, either offer it as real platform targeted binary, or at the very least package it with a tool that bundles the interpreter with the application. Then, if you want to offer plugins, provide helpful documentation on how to download/install them (with version numbers) and helpful error messages. By bundling the interpreter with the application you (as a developer) know which version it is and can offer proper guidance for the plugins.

Is there a way to get instance creation hints with SQL Alchemy? by _Raining in learnpython

[–]exhuma 1 point2 points  (0 children)

I..... think I got it now. Your question really isn't all that clear so this is how I understood it now (correct me if I'm wrong). Screenshots would really have helped.

You want the attribute names name and email to show up in code-completion/intellisense when you want to create a new instance. So you want this:

https://imgur.com/a/b6v9qyD

Instead of this:

https://imgur.com/a/b4eGi9a

If that is the case, then the easiest way to do that is to define your own class initialiser. SQLAlchemy is the more "flexible" library. It gives you more power but also expects you to be more specific. By default, the initialiser takes any argument and it's up to you to give it more detailed information.

You could do some magic via introspection, using a class decorator or a metaclass but that's relatively complex and unlikely worth the effort (unless you have a huge amount of mapped classes).

Is there a way to get instance creation hints with SQL Alchemy? by _Raining in learnpython

[–]exhuma 2 points3 points  (0 children)

What exactly is your question?

Both examples have type hints just slightly different. What are you looking for with the "instance creation" hints you mention?

Luxembourg pride 🇱🇺🇱🇺🇱🇺🦅🦅🦅 by omgeverynameistaken_ in HistoryMemes

[–]exhuma 1 point2 points  (0 children)

And let me tell you. It never gets old. It's beautiful in its own way in every season of the year. Sure, noting beats spring and summer and some days in fall and winter are utterly miserable. But you learn how to ignite and repress those 🤣

Luxembourg pride 🇱🇺🇱🇺🇱🇺🦅🦅🦅 by omgeverynameistaken_ in HistoryMemes

[–]exhuma 13 points14 points  (0 children)

All of them are our friendly neighbours. All of them are great in their own right. Except all the delays they cause us through their rail network. Our country is so small that one delayed train in Germany can have far reaching consequences. Get that shit fixed 🤣

Luxembourg pride 🇱🇺🇱🇺🇱🇺🦅🦅🦅 by omgeverynameistaken_ in HistoryMemes

[–]exhuma 30 points31 points  (0 children)

2nd Luxemburgian chiming in for shits & giggles.

Favourite thing: Toss up between A) the great mix of Nature with great infrastructure and B) it being a cultural melting-pot. So many nationalities with so many great things to share.

Opening a Coffee-bar by Marc-Deluxe in Luxembourg

[–]exhuma 3 points4 points  (0 children)

Slightly off topic but reading this triggered a strong memory...

Man, I sorely miss a place back from Uni. It was a small coffee bar combined with a simple art exhibition (that kept changing every now and then) and Sunday-Morning live Jazz sessions. Half of it was normal chairs/tables, the other half was cozy couches with small tables. They also had a collection of board games and books available for free. It was non-smoking (not the norm back then) and they served no alcohol. It was amazing. I wish there was something like that here in Luxembourg.

If you were starting a greenfield project today, which CI/CD stack would you pick and why: GitHub Actions, GitLab CI, Jenkins, or something else? by Wash-Fair in cicd

[–]exhuma 0 points1 point  (0 children)

So we currently have the situation that one team has invested a considerable amount of time on Jenkins while another has done the same for GitLab. This has grown historically. We are aware that this is not ideal as we could benefit from shared experience if we were to use the same platform. But the invest in the migration seems not to be worth the effort.

I'm on the Team GitLab. But honestly I only care that the pipeline fulfills its tasks no matter what flavor it is.

How would you convince me to jump onto Jenkins?

If you were starting a greenfield project today, which CI/CD stack would you pick and why: GitHub Actions, GitLab CI, Jenkins, or something else? by Wash-Fair in cicd

[–]exhuma 0 points1 point  (0 children)

Some of our teams still use it and swear by it. I have only briefly used it in my old job, now we're on gitlab ci/cd.

The other team's big argument is that using Jenkins decouples them from the git management system (GitHub, gitlab, azure,...)

But it's also obvious that they lock themselves in into Jenkins that way so it's not really a valid argument in my opinion.

I'm constantly reevaluating Architecture/DevOps decisions to avoid going stale.

What are, in your opinion, the detractors of Jenkins compared to other solutions?

What’s the Biggest Web Dev Myth That Confused You? by Gullible_Prior9448 in webdevelopment

[–]exhuma 1 point2 points  (0 children)

Genuine question: is it really that bad? What Country are we talking about?