this post was submitted on 16 Jun 2025
247 points (94.6% liked)

linuxmemes

26110 readers
451 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • 6. (NEW!) Regarding public figuresWe all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     

    Has my motd gone too far? It loads a random ANSI catgirl from a folder. I use arch btw, server runs minimized Ubuntu Server.

    you are viewing a single comment's thread
    view the rest of the comments
    [–] Finadil@lemmy.world 19 points 3 weeks ago (8 children)

    Thanks for the suggestion, gonna look into this. I didn't want to use real images even though kitty supports them because I like the retro look and wanted it terminal agnostic for when I use termux on my phone.

    [–] TwilightKiddy@programming.dev 20 points 3 weeks ago* (last edited 3 weeks ago) (7 children)

    I gladly present you this jank.

    You might need these to compile:

    cargo add image
    cargo add clap --features derive
    

    And the jank itself:

    Some Rust code

    use std::path::PathBuf;
    
    use clap::Parser;
    use image::{ imageops::{self, FilterType}, ImageReader };
    
    #[derive(Parser)]
    struct Cli {
        path: PathBuf,
        #[arg(short = 'H', long, default_value_t = 30)]
        height: u32,
        #[arg(short, long, default_value_t = 0.4)]
        ratio: f32,
        #[arg(short, long, default_value_t, value_enum)]
        filter: Filter,
    }
    
    #[derive(clap::ValueEnum, Clone, Default)]
    enum Filter {
        Nearest,
        Triangle,
        Gaussian,
        CatmullRom,
        #[default]
        Lanczos3,
    }
    
    fn main() -> Result<(), Box<dyn std::error::Error>> {
        let args = Cli::parse();
        let filter = match args.filter {
            Filter::Nearest    => { FilterType::Nearest },
            Filter::Triangle   => { FilterType::Triangle },
            Filter::CatmullRom => { FilterType::CatmullRom },
            Filter::Gaussian   => { FilterType::Gaussian },
            Filter::Lanczos3   => { FilterType::Lanczos3 },
        };
        let img = ImageReader::open(args.path)?.decode()?;
        let original_ratio = img.width() as f32 / img.height() as f32;
        let width = ( args.height as f32 / args.ratio ) * original_ratio;
        let out = imageops::resize(&img, width as u32, args.height * 2, filter);
        let mut iter = out.enumerate_rows();
        while let Some((_, top)) = iter.next() {
            let (_, bottom) = iter.next().unwrap();
            top.zip(bottom)
                .for_each(|((_, _, t), (_, _, b))| {
                    print!("\x1B[38;2;{};{};{};48;2;{};{};{}m\u{2584}", b[0], b[1], b[2], t[0], t[1], t[2])
                });
            println!("\x1B[0m");
        }
        Ok(())
    }
    

    [–] rtxn@lemmy.world 5 points 3 weeks ago* (last edited 3 weeks ago) (4 children)

    I've been learning Rust by going through The Book... there's some wack-ass syntax in that language. I've mostly used C# and Python so most of it just looks weird... I can more or less understand what while let Some((_, top)) = iter.next() { ... } is doing, but .for_each(|((_, _, t), (_, _, b))| { ... } just looks like an abomination. And I mean the syntax in general, not this code in particular.

    [–] __dev@lemmy.world 7 points 3 weeks ago (1 children)

    but .for_each(|((_, , t), (, _, b))| { ... } just looks like an abomination

    It's not so different in python: for ((_, _, t), (_, _, b)) in zip(top, bottom):

    Or in C#: .ForEach(((_, _, t), (_, _, b)) => Console.Write(...));

    [–] rtxn@lemmy.world 4 points 3 weeks ago (1 children)

    Is | (...) | { ... } a lambda expression then?

    [–] ignotum@lemmy.world 2 points 3 weeks ago

    Yep, lambda or closure (it's an anonymous function but it can also capture state from the enclosing function, i think pure lambdas can't do that?)

    load more comments (2 replies)
    load more comments (4 replies)
    load more comments (4 replies)