• 3 Posts
  • 267 Comments
Joined 3 years ago
cake
Cake day: May 26th, 2021

help-circle










  • Germany closed down all their nuclear plants

    That’s wrong: 3 plants are still running (probably) until the end of this year.

    the end result was that they just started using more fossil fuels.

    This is true, but the reason isn’t the lack of alternatives but incompetent and corrupt state and federal government. They sabotaged the domestic solar sector, they made running private (roof-) solar plants unnecessarily complicated, they made building new (on-shore) wind parks basically impossible and they blocked the extension of the electrical grid. (And thats just the stuff I remember from the top of my head)


  • You need to figure out the variant before you can access any fields.

    let x = match p1 {
      Coordinates::Point1 { x, .. } => x, // .. means "I don't care about the other fields"
      Coordinates::Point2 { x, .. } => x,
    };
    

    or if you only need to do stuff on one type of point

    if let Coordinates::Point1 { x, _y } = p1 {
      // Do stuff with x or y here
      // _y (prefixed / replaced with _) means "I won't use that variable"
    }
    

    However it looks like what you want is a struct that contains an enum and the coordinates.

    enum CoordinateKind {
      Point1,
      Point2,
    }
    
    struct Point {
      kind: CoordinateKind,
      x: i32,
      y: i32,
    }
    
    fn main() {
      let p = Point {
        kind: CoordinateKind::Point1,
        x: 0,
        y: 45,
      };
    
      let x = p.x;
    }
    







  • Find should already be installed but depending on how the files are named ls should do.

    You probably want to do something similiar to this snippet:

    # Create a temporary directory and save it's path
    TMPD=$(mktemp -d)
    
    # Extract the archive to that directory
    7z x -o$TMPD $1
    
    # Convert the images to PDF
    img2pdf $(ls -vd $TMPD/**) -o $2
    
    # Delete the temporary directory
    rm $TMPD
    

  • doing this on Python or whatever language?

    If you’re on Linux, MacOS or some BSD doing this with a bash script would be the easiest imo, since there already exists ready-made software for all the steps.

    • Unpacking: unzip, unrar, 7z (the latter can handle many different formats)
    • Sorting the images: find
    • Converting them to pdf: img2pdf, imagemagick

    You can even automate the downloading with e.g. wget.

    Should be straight forward (just a series of commands and some command substitution for the find part) as long as you don’t have too many images.

    On windows you could (probably) do the same with a python script (or maybe powershell idk)

    Are email requirement the default for lemmy instances or it is something an operator has to choose?

    That can be configured.