birding birding Some brief thoughts on composite wood in regard to bird house construction
Jump
  • vole vole 1 week ago 100%

    retains heat longer, and also loses heat faster

    These two points are contradictory. Something either holds heat longer or loses it faster.

    I read your second link and it seems that color matters way more than composite vs real wood. Though in any case they were measuring the upward-facing surface temperature of the decking material, not the inside temperature of a structure made from the material.

    I'm no bird building engineer, but here is what I'd consider if I was worried about bird house temperatures:

    • ventilation: helps bring the temperature down/up to the ambient air temperature
    • solar absorption: lighter colors tend to absorb less warmth from sunlight
    • insulation: more insulation means less heat/cold will transfer from the outside surface in, and will make the temperature inside more stable throughout the day/night

    And addressing each point in terms of composite vs real wood:

    • ventilation: same for both composite and real wood
    • solar absorption: unpainted light-colored wood appears to be fairly cool, but if it's painted/stained then it doesn't matter
    • insulation: I can't find a good source, but it seems like real wood is a better insulator than composite. You can use thicker boards to increase insulation.

    So, if you make a bird house with unstained unpainted untreated wood and the exact same bird house design with composite wood, I think it's reasonable to assume that the composite one will get a little warmer on a hot day. If the bird house has some ventilation, I don't think there will be much of a difference.

    3
  • linux Linux [Question] Setting up a bridged network for HomeAssistant in KVM Fedora
    Jump
  • vole vole 1 month ago 100%

    I haven't made a bridge to a VM before today, or made a bridge with Network Manager. That being said, I was able to persuade Network Manger to get a bridge working, and there are a few things I can note:

    • When you setup the bridge, the host network interface should become a slave to the bridge. This means that the physical network interface should not have an IP Address, and your bridge should now be where you configure the host's IP address.

      • After you start the VM, you should be able to run ip link | grep 'master br0' on the host, and it should display 2 interfaces which are slaves to br0. One for the physical ethernet interface, one for the VM (vnet). And it should only list your ethernet interface when the VM is off.
    • The RedHat tutorial does not show the bridge and the host having different IP addresses, the RedHat tutorial shows the bridge and the guest having different IP addresses. Actually, no, the RedHat tutorial shows the libvirt NAT bridge, not even the bridge that the tutorial describes creating... If you set the IP address of virbr0, I don't know what happens.

    • If your VM's network adapter is connected to the host's bridge, then you should be able to log into your VM and set a static IP address.

    I had a lot of problems getting Network Manager to actually use my ethernet interface as a slave for the bridge. Here's what worked for me, though:

    nmcli con show
    nmcli con down 'Wired Connection 1'
    nmcli con modify 'Wired Connection 1' connection.autoconnect no
    nmcli con add type bridge con-name br0 ifname br0
    nmcli connection add type bridge-slave ifname enp7s0 master br0
    nmcli con modify br0 connection.autoconnect yes
    nmcli con modify bridge-slave-enp7s0 connection.autoconnect yes
    nmcli con modify br0 ipv4.method manual ipv4.addresses 172.16.0.231/24 bridge.stp no
    sudo systemctl restart NetworkManager.service
    nmcli con show
    ip addr
    
    • Instead of enp7s0, you'd use enp1s0 I guess.
    • Above, I manually set my bridge IP address to a static address because my ethernet interface is wired directly to another computer, so no DHCP for me. If you have DHCP on your ethernet network, you probably don't need to set "ipv4.method" or "ipv4.addresses".
    • I set "bridge.stp" to "no" because my network doesn't have any redundant paths, and the stp process seems to take like 25 seconds before I can use the bridge network.

    After that, I can go into "Virtual Machine Manger", set my VM's NIC's Network Source to "Bridge device...", Device name to"br0", boot my VM, login to my VM, configure my VM's ip address. And then I can connect to the VM's IP address from the physical ethernet network.

    2
  • anime Anime Discussion Looking for more anime in the vein of Bocchi the rock
    Jump
  • vole vole 2 months ago 100%
    1
  • linux Linux NixOS is better because...
    Jump
  • vole vole 8 months ago 100%

    This is a text post, so the OP wrote text corresponding to the title. You should be able to see it at the top of the post. (Spoiler, OP is basically asking the community why NixOS is better, because they don't quite understand the advantages of using NixOS.)

    1
  • linux Linux Looking to make the switch
    Jump
  • vole vole 8 months ago 100%

    POP!_OS apparently uses systemd-boot (not to be confused with systemd). It apparently adds a Windows entry automatically if Windows is installed on the same disk. When Windows is installed on a different disk, it looks like booting the windows boot manager EFI program is still possible with systemd-boot. The instructions given in that link are a bit vague, though.

    This page has a different, simpler approach and more specific steps. Apparently you can just copy the Microsoft EFI folder to a specific directory in your Linux drive's ESP partition. I'd be a little bit concerned about Windows not being able to update its EFI bootloader, but I also don't know if Windows ever updates that. The page also has instructions on how to interact with the systemd-boot menu during boot.

    You could also install grub yourself, but I can't guarantee that'll be easy. Mashing F2 might be the sanest solution, unless you plan on booting into Windows every day.

    3
  • linux Linux Wayland running GUI program as another user
    Jump
  • vole vole 8 months ago 100%

    I got interested, so I spent some time looking into what's going on here. I'm not intimately familiar with X11 or Wayland, but I figured out some stuff.

    Why sudo ip netns exec protected sudo -u user -i doesn't work for X11 apps

    Short answer: file permissions and abstract unix sockets (which I didn't know were a thing before now).

    File permissions: when I start an X11 login session, the DISPLAY is :0 and /tmp/.X11-unix/ has only 1 file X0. This file has 777 access. When I start my wayland session with Xwayland, the DISPLAY is :1 and /tmp/.X11-unix/ has 2 files X0 (777) and X1 (755). I can't figure out how to connect to display :0, so I guess I'm stuck with :1. When you change to a different (non-root) user, the user no longer has access to /tmp/.X11-unix/X1.

    Abstract unix sockets: When I start my wayland/xwayland session, it creates abstract unix sockets with ids @/tmp/.X11-unix/X0 and @/tmp/.X11-unix/X1. See ss -lnp | grep Xwayland. The network namespace also sandboxes these abstract unix sockets. Compare socat ABSTRACT-CONNECT:/tmp/.X11-unix/X1 STDIN and sudo ip netns exec private socat ABSTRACT-CONNECT:/tmp/.X11-unix/X1 STDIN.

    When you do sudo ip netns exec protected su - user, you loose access to both the filesystem unix socket /tmp/.X11-unix/X1 and the abstract unix socket @/tmp/.X11-unix/X1. You need access to one or the other for X11 applications to work.

    I tried using socat to forward X1 such that it works in the network namespace... and it kinda works. sudo ip netns exec protected socat ABSTRACT-LISTEN:/tmp/.X11-unix/X1,fork UNIX-CONNECT:/tmp/.X11-unix/X1. It appears having ABSTRACT-LISTEN before UNIX-CONNECT is important, I guess it would be worth it to properly learn socat. With this sudo ip netns exec protected su - testuser -c 'env DISPLAY=:1 xmessage hi' works, but sudo ip netns exec protected su - testuser -c 'env DISPLAY=:1 QT_QPA_PLATFORM=xcb kcalc' does not work. 😞

    Changing the file permissions on /tmp/.X11-unix/X1 to give the user access seems to work better.

    Wayland waypipe

    Waypipe works as advertised. But it's still a little bit tricky because you need to have two separate processes for the waypipe client and server, wait for the waypipe socket to be created, adjust file permissions for the waypipe socket file, and set (and probably mkdir) XDG_RUNTIME_DIR.

    waypipe -s /tmp/mywaypipe client &
    sleep 0.1
    chgrp shared-display /tmp/mywaypipe
    chmod g+w /tmp/mywaypipe
    sudo ip netns exec protected su - testuser -c 'mkdir -p -m 0700 /tmp/runtime-testuser && env XDG_RUNTIME_DIR=/tmp/runtime-testuser waypipe -s /tmp/mywaypipe server -- env QT_QPA_PLATFORM=wayland kcalc'
    kill -SIGINT %1
    

    Combined

    into this script https://github.com/vole-dev/grabbag/blob/main/run-netns-user-wayland.bash

    7
  • linux Linux Linux video editing and Kdenlive tips and tricks for a returning user?
    Jump
  • vole vole 9 months ago 100%

    thanks, I'll try out the libx264 encoder next time

    2
  • linux Linux Linux video editing and Kdenlive tips and tricks for a returning user?
    Jump
  • vole vole 9 months ago 100%

    Oh wow, I didn't know (free) Davinci didn't support using H.264 as source media, that feels rather limited.

    2
  • linux Linux Linux video editing and Kdenlive tips and tricks for a returning user?
    Jump
  • vole vole 9 months ago 100%

    Completely tangential tip, but in the very-limited video editing I've done recently: I've used Davinci Resolve, rendered as .mov, and then used ffmpeg to render to my actual desired format. e.g. h264 w/ aac audio so I can upload to Youtube:

    ffmpeg -i input.mov -c:v libopenh264 -profile:v high -c:a aac -pix_fmt yuv420p output.mp4

    I do think that finding the right flags to pass to ffmpeg is a cursed art. Do I need to specify the video profile and the pix_fmt? I don't know; I thought I did when I adventured to collect these flags. Though maybe it's just a reflection of the video-codec horrors lurking within all video rendering pipelines.

    edit: there may also be nvidia-accelerated encoders, like h264_nvenc, see ffmpeg -codecs 2>/dev/null | grep -i 'h\.264'. I'm not sure if the profile:v and pix_fmt options apply to other encoders or just libopenh264.

    4
  • anime Anime Recommend me romance anime
    Jump
  • vole vole 9 months ago 100%

    Flipping through my watched list, here are some romance anime I liked, varying levels of drama and comedy:

    And maybe some that might not quite be what you were expecting:

    Edit: also looking forward to A Sign of Affection, which is airing this season

    7
  • anime Anime Discussion What anime are you looking forward to watching in the Winter 2024 season?
    Jump
  • vole vole 9 months ago 100%

    Shows for Winter 2024 on my radar, that I am interested in watching:

    • Classroom of the Elite: first two seasons were fun, looking forward to season 3
    • Bottom-tier Character Tomozaki: first season was OK, I'm interested in where the story will go
    • Mato Seihei no Slave: I vaguely recall someone saying there was something good about the source material
    • MASHLE: first season was OK, I'm not very interested in S2, I might binge it when the season is complete
    • Blue Exorcist: oh, another season. It's been a while. I remember liking the first season and being confused at the start of the second season (it's about 6 years between each season, so maybe I just forgot some important details. From a S2 MAL review: "the season does not follow the end of season 1. Episodes 18-25 were not canon and accordingly, they do not exist in season 2", I didn't know this, so maybe that was my problem)
    • The Dangers in My Heart: first season was fantastic, excited for the second season
    • A Sign of Affection: the source material is rated highly on MAL, I'll give it a shot
    • Banished from the Hero's Party: First season was OK
    • TSUKIMICHI: I liked the first season, looking forward to the second season
    • The Foolish Angel Dances with the Devil: I saw the PV, I'll give it a shot
    • Cherry Magic!: The source material is rated well on MAL, I'll give it a shot
    • The Witch and the Beast: The source material is rated well on MAL, I'll give a shot
    • The Weakest Tamer Began a Journey to Pick Up Trash: WILDCARD, I dunno, it sounds like absolute trash from the title, but I think I'll give it a shot anyways
    8
  • anime
    Anime Discussion vole 9 months ago 90%
    What anime are you looking forward to watching in the Winter 2024 season?

    What anime are you looking forward to watching in the Winter 2024 season? Winter 2024 anime: https://myanimelist.net/anime/season/2024/winter

    9
    3
    anime Anime Winter 2024 anime calendar
    Jump
  • vole vole 9 months ago 100%

    Shows for Winter 2024 on my radar, that I am interested in watching:

    • Classroom of the Elite: first two seasons were fun, looking forward to season 3
    • Bottom-tier Character Tomozaki: first season was OK, I'm interested in where the story will go
    • Mato Seihei no Slave: I vaguely recall someone saying there was something good about the source material
    • MASHLE: first season was OK, I'm not very interested in S2, I might binge it when the season is complete
    • Blue Exorcist: oh, another season. It's been a while. I remember liking the first season and being confused at the start of the second season (it's about 6 years between each season, so maybe I just forgot some important details. From a S2 MAL review: "the season does not follow the end of season 1. Episodes 18-25 were not canon and accordingly, they do not exist in season 2", I didn't know this, so maybe that was my problem)
    • The Dangers in My Heart: first season was fantastic, excited for the second season
    • A Sign of Affection: the source material is rated highly on MAL, I'll give it a shot
    • Banished from the Hero's Party: First season was OK
    • TSUKIMICHI: I liked the first season, looking forward to the second season
    • The Foolish Angel Dances with the Devil: I saw the PV, I'll give it a shot
    • Cherry Magic!: The source material is rated well on MAL, I'll give it a shot
    • The Witch and the Beast: The source material is rated well on MAL, I'll give a shot
    • The Weakest Tamer Began a Journey to Pick Up Trash: WILDCARD, I dunno, it sounds like absolute trash from the title, but I think I'll give it a shot anyways
    1
  • anime Anime Boushoku no Berserk • Berserk of Gluttony - Episode 12 discussion - FINAL
    Jump
  • vole vole 9 months ago 100%

    Boushoku no Berserk was fairly enjoyable! It is kinda trash, but it's good trash: there's an actual plot, the main characters are fairly likeable and fairly believable (even if the villians are like "hahaha, watch me be evil!") and have a touch of depth. The struggles that the MC has to deal with are actually interesting. The animation and sound design is of acceptable quality throughout. The voice acting was pretty good!

    7/10: guilty pleasure for those of us who like these kinds of shows. I generally know what I'm getting into when I see the promotional art and description for these kinds of shows; Boushoku no Berserk meets or exceeds those expections.

    Also Eris: "whoops, I guess I shouldn't have gone along with Envy's scheme." A change of heart... but why? Because Fate won? lol. I guess just leave it up to the viewers imagination because the actual explanation would probably not be worth watching.

    2
  • linux Linux Filesystem Hierarchy Standard - Reference Poster / Cheatsheet [Dark mode in details]
    Jump
  • vole vole 9 months ago 100%

    /home is not deprecated, it's optional but common. Here is the section from FHS: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s08.html

    14
  • advent_of_code Advent Of Code ☃️ - 2023 DAY 11 SOLUTIONS - ☃️
    Jump
  • vole vole 9 months ago 100%

    Raku

    Today I'm thankful that I have the combinations() method available. It's not hard to implement combinations(), but it's not particularly interesting. This code is a bit anachronistic because I solved part 1 by expanding the universe instead of contracting it, but this way makes the calculations for part 1 and part 2 symmetric. I was worried for a bit there that I'd have to do some "here are all the places where expansion happens, check this list when calculating distances" bookkeeping, and I was quite relieved when I realized that I could just use arithmetic.

    edit: Also, first time using the Slip class in Raku, which is mind bending, but very useful for expanding/contracting the universe and generating the lists of galaxy coordinates. And I learned a neat way to transpose 2D arrays using [Z].

    View the code on Github

    :::spoiler Code

    use v6;
    
    sub MAIN($input) {
        my $file = open $input;
    
        my @map = $file.lines».comb».Array;
        my @galaxies-original = @map».grep("#", :k).grep(*.elems > 0, :kv).rotor(2).map({($_[0] X $_[1]).Slip});
        my $distances-original = @galaxies-original.List.combinations(2).map({($_[0] Z- $_[1])».abs.sum}).sum;
    
        # contract the universe
        @map = @map.map: {$_.all eq '.' ?? slip() !! $_};
        @map = [Z] @map;
        @map = @map.map: {$_.all eq '.' ?? slip() !! $_};
        @map = [Z] @map;
    
        my @galaxies = @map».grep("#", :k).grep(*.elems > 0, :kv).rotor(2).map({($_[0] X $_[1]).Slip});
        my $distances-contracted = @galaxies.List.combinations(2).map({($_[0] Z- $_[1])».abs.sum}).sum;
    
        my $distances-twice-expanded = ($distances-original - $distances-contracted) * 2 + $distances-contracted;
        say "part 1: $distances-twice-expanded";
        my $distances-many-expanded = ($distances-original - $distances-contracted) * 1000000 + $distances-contracted;
        say "part 2: $distances-many-expanded";
    }
    

    :::

    3
  • advent_of_code Advent Of Code ❄️ - 2023 DAY 10 SOLUTIONS -❄️
    Jump
  • vole vole 9 months ago 100%

    Raku

    My solution for today is quite sloppy. For part 2, I chose to color along both sides of the path (each side different colors) and then doing a fill of the empty space based on what color the empty space is touching. Way less optimal than scanning, and I didn't cover every case for coloring around the start point, but it was interesting to attempt. I ran into a bunch of issues on dealing with nested arrays in Raku, I need to investigate if there's a better way to handle them.

    View code on github

    Edit: did some cleanup, added some fun, and switched to the scanning algorithm for part 2, shaved off about 50 lines of code.

    :::spoiler Code

    use v6;
    
    sub MAIN($input) {
        my $file = open $input;
    
        my @map = $file.lines».comb».Array;
    
        my @starting-point = @map».grep('S', :k)».[0].grep(*.defined, :kv).List;
    
        my @path = (@starting-point,);
    
        my %tile-neighbors =
            '|' => (( 1, 0),(-1, 0)),
            '-' => (( 0,-1),( 0, 1)),
            'L' => ((-1, 0),( 0, 1)),
            'J' => ((-1, 0),( 0,-1)),
            '7' => (( 1, 0),( 0,-1)),
            'F' => (( 1, 0),( 0, 1)),
        ;
    
        sub connecting-neighbor(@position, @neighbor) {
            my @neighbor-position = @position Z+ @neighbor;
            return False if any(@neighbor-position Z< (0, 0));
            return False if any(@neighbor-position Z> (@map.end, @map.head.end));
            my $neighbor-tile = @map[@neighbor-position[0]; @neighbor-position[1]];
            my @negative-neighbor = @neighbor X* -1;
            return %tile-neighbors{$neighbor-tile}.grep(@negative-neighbor, :k).elems > 0;
        }
    
        # replace starting-point with the appropriate pipe
        my @start-tile-candidates = <| - L J 7 F>;
        for @start-tile-candidates -> $candidate {
            next if %tile-neighbors{$candidate}.map({!connecting-neighbor(@starting-point, $_)}).any;
            @map[@starting-point[0]; @starting-point[1]] = $candidate;
            last;
        }
    
        repeat {
            my @position := @path.tail;
            my $tile = @map[@position[0]; @position[1]];
            my @neighbors = %tile-neighbors{$tile}.List;
            for @neighbors -> @neighbor {
                my @neighbor-position = @neighbor Z+ @position;
                next if @path.elems >= 2 && @neighbor-position eqv @path[*-2];
                if connecting-neighbor(@position, @neighbor) {
                    @path.push(@neighbor-position);
                    last;
                }
            }
        } while @path.tail !eqv @path.head;
        my $part-one-solution = (@path.elems / 2).floor;
        say "part 1: {$part-one-solution}";
    
        my %pipe-set = @path.Set;
        my %same-side-pairs = ;
        my $part-two-solution = 0;
        for ^@map.elems -> $y {
            my $inside = False;
            my $entrance-pipe = Nil;
            for ^@map.head.elems -> $x {
                if %pipe-set{$($y, $x)} {
                    given @map[$y; $x] {
                        when '|' { $inside = !$inside }
                        when 'F' | 'L' { $entrance-pipe = $_ }
                        when 'J' | '7' {
                            $inside = !$inside if %same-side-pairs{$entrance-pipe} ne $_;
                            $entrance-pipe = Nil;
                        }
                    }
                } elsif $inside {
                    $part-two-solution += 1;
                }
            }
        }
        say "part 2: $part-two-solution";
    }
    

    :::

    2
  • advent_of_code Advent Of Code 🦌 - 2023 DAY 9 SOLUTIONS -🦌
    Jump
  • vole vole 10 months ago 100%

    Raku

    First time using Grammar Actions Object to make parsing a little cleaner. I thought about not keeping track of the left and right values (and I originally didn't for part 1), but I think keeping track allows for an easier to understand solution.

    View code on github

    edit: although I don't know why @values.all != 0 evaluates to true why any value is not zero. I thought that @values.any != 0 would do that, but it seems that their behavior is flipped from my expectations.

    edit2: Oh, I think I understand now. != is a shortcut for !==, and !== is actually the equality operator that is then negated. You can negate most relational operators in Raku by prefixing them with !. So the junction is actually binding to the == equality operator and not the !== inequality operator. Therefore @values.all != 0 becomes !(@values.all == 0). I'm not sure why they would choose this order of operations, though.

    edit3: Ah, it's in the documentation, so it's not even an oversight. https://github.com/rakudo/rakudo/issues/3748

    :::spoiler Code (probably still doesn't render correctly)

    use v6;
    
    sub MAIN($input) {
        my $file = open $input;
    
        grammar Oasis {
            token TOP { +%"\n" "\n"* }
            token history { +%\h+ }
            token val { '-'? \d+ }
        }
    
        class OasisActions {
            method TOP ($/) { make $».made }
            method history ($/) { make $».made }
            method val ($/) { make $/.Int }
        }
    
        my $oasis = Oasis.parse($file.slurp, actions => OasisActions.new);
        my @histories = $oasis.made;
        my $part-one-solution;
        my $part-two-solution;
        sub revdiff { $^b - $^a }
        for @histories -> @history {
            my @values = @history;
            my @rightmosts = [@values.tail];
            my @leftmosts = [@values.head];
            while @values.all != 0 {
                @values = @values.tail(*-1) Z- @values.head(*-1);
                @rightmosts.push(@values.tail);
                @leftmosts.push(@values.head);
            }
            $part-one-solution += [+] @rightmosts;
            $part-two-solution += [[&revdiff]] @leftmosts.reverse;
        }
        say "part 1: $part-one-solution";
        say "part 2: $part-two-solution";
    }
    

    :::

    2
  • advent_of_code Advent Of Code Yay for visualisation!
    Jump
  • vole vole 10 months ago 100%

    Very cool. It's interesting to see that all the loops are all crisscrosses until the last few before *Z. I guess that's how they ensured Z stayed at the end of the loop (by requiring RRRR and only having RRRR at the end of the instructions).

    3
  • advent_of_code Advent Of Code 🎄 - 2023 DAY 8 SOLUTIONS -🎄
    Jump
  • vole vole 10 months ago 100%

    Personally, I'm not a fan of requiring analysis of the individualized input to reach the correct (sufficiently efficient) solution for part 2. Or maybe I'm just resentful because I feel like I've been duped after writing an generalized-to-the-puzzle-description-but-insufficiently-efficient solution. 😔

    These quantum ghosts need to come back down to reality.

    13
  • advent_of_code Advent Of Code 🍪 - 2023 DAY 7 SOLUTIONS -🍪
    Jump
  • vole vole 10 months ago 100%

    Raku

    My hand-type strength calculations could probably be trimmed down a bit. I didn't hit any big issues today.

    View code on github

    :::spoiler Code (note: doesn't currently display correctly on Lemmy website)

    use v6;
    
    sub MAIN($input) {
        my $file = open $input;
    
        grammar CamelCards {
            token TOP { +%"\n" "\n"*}
            token row {  " "  }
            token hand { \S+ }
            token bid { \d+ }
        }
    
        my $camel-cards = CamelCards.parse($file.slurp);
        my @rows = $camel-cards.map({ (..Str, ..Int) });
        my @ranked-rows1 = @rows.sort({hand-strength($_[0], &hand-type-strength1, '23456789TJQKA'.comb)});
        my $part-one-solution = (@ranked-rows1»[1] Z* 1..*).sum;
        say "part 1: $part-one-solution";
    
        my @ranked-rows2 = @rows.sort({hand-strength($_[0], &hand-type-strength2, 'J23456789TQKA'.comb)});
        my $part-two-solution = (@ranked-rows2»[1] Z* 1..*).sum;
        say "part 2: $part-two-solution";
    }
    
    sub hand-strength($hand, &hand-type-strength, @card-strengths) {
        my $strength = &hand-type-strength($hand);
        for $hand.comb -> $card {
            $strength = $strength +< 8 + @card-strengths.first({ $_ eq $card }, :k);
        }
        return $strength;
    }
    
    sub hand-type-strength1($hand) {
        my @sorted = $hand.comb.sort;
        my @runs = [1];
        my $card = @sorted[0];
        for @sorted[1..*] -> $new-card {
            if $new-card eq $card {
                @runs.tail += 1;
            } else {
                @runs.push(1);
                $card = $new-card;
            }
        }
        return do given @runs.sort {
            when .[0] == 5 { 6 } # Five of a kind
            when .[1] == 4 { 5 } # Four of a kind
            when .[1] == 3 { 4 } # Full House
            when .[2] == 3 { 3 } # Three of a kind
            when .[1] == 2 { 2 } # Two pair
            when .[3] == 2 { 1 } # One pair
            default { 0 } # High card
        };
    }
    
    sub hand-type-strength2($hand) {
        my @sorted = $hand.comb.grep(none /J/).sort;
        if @sorted.elems == 0 {
            return 6;
        } else {
            my @runs = [1];
            my $card = @sorted[0];
            for @sorted[1..*] -> $new-card {
                if $new-card eq $card {
                    @runs.tail += 1;
                } else {
                    @runs.push(1);
                    $card = $new-card;
                }
            }
            @runs.=sort;
            @runs.tail += 5 - @sorted.elems;
            return do given @runs {
                when .[0] == 5 { 6 } # Five of a kind
                when .[1] == 4 { 5 } # Four of a kind
                when .[1] == 3 { 4 } # Full House
                when .[2] == 3 { 3 } # Three of a kind
                when .[1] == 2 { 2 } # Two pair
                when .[3] == 2 { 1 } # One pair
                default { 0 } # High card
            };
        }
    }
    

    :::

    2
  • advent_of_code Advent Of Code Measuring performance in a hardware-agnostic way
    Jump
  • vole vole 10 months ago 100%

    perf and valgrind might be good places to start. Although, some programs aren't going to have the exact same executed instruction count between runs, and it's possible that executed instruction count can depend on the exact CPU that's running. You can probably mitigate the latter by running valgrind and the program inside of QEMU.

    2
  • advent_of_code Advent Of Code 🌟 - 2023 DAY 6 SOLUTIONS -🌟
    Jump
  • vole vole 10 months ago 100%

    Raku

    I spent a lot more time than necessary optimizing the count-ways-to-beat function, but I'm happy with the result. This is my first time using the | operator to flatten a list into function arguments.

    edit: unfortunately, the lemmy web page is unable to properly display the source code in a code block. It doesn't display text enclosed in pointy brackets <>, perhaps it looks too much like HTML. View code on github.

    ::: spoiler Code

    use v6;
    
    sub MAIN($input) {
        my $file = open $input;
    
        grammar Records {
            token TOP {  "\n"  "\n"* }
            token times { "Time:" \s* +%\s+ }
            token distances { "Distance:" \s* +%\s+ }
            token num { \d+ }
        }
    
        my $records = Records.parse($file.slurp);
    
        my $part-one-solution = 1;
        for $records».Int Z $records».Int -> $record {
            $part-one-solution *= count-ways-to-beat(|$record);
        }
        say "part 1: $part-one-solution";
    
        my $kerned-time = $records.join.Int;
        my $kerned-distance = $records.join.Int;
        my $part-two-solution = count-ways-to-beat($kerned-time, $kerned-distance);
        say "part 2: $part-two-solution";
    }
    
    sub count-ways-to-beat($time, $record-distance) {
        # time = button + go
        # distance = go * button
        # 0 = go^2 - time * go + distance
        # go = (time +/- sqrt(time**2 - 4*distance))/2
    
        # don't think too hard:
        # if odd t then t/2 = x.5,
        #   so sqrt(t**2-4*d)/2 = 2.3 => result = 4
        #   and sqrt(t**2-4*d)/2 = 2.5 => result = 6
        #   therefore result = 2 * (sqrt(t**2-4*d)/2 + 1/2).floor
        # even t then t/2 = x.0
        #   so sqrt(t^2-4*d)/2 = 2.x => result = 4 + 1(shared) = 5
        #   therefore result = 2 * (sqrt(t^2-4*d)/2).floor + 1
        # therefore result = 2 * ((sqrt(t**2-4*d)+t%2)/2).floor + 1 - t%2
        # Note: sqrt produces a Num, so perhaps the result could be off by 1 or 2,
        #       but it solved my AoC inputs correctly 😃.
    
        my $required-distance = $record-distance + 1;
        return 2 * ((sqrt($time**2 - 4*$required-distance) + $time%2)/2).floor + 1 - $time%2;
    }
    

    :::

    3
  • anime Anime [meta] The anime instance, ani.social, has been defederated by lemmy.ml
    Jump
  • vole vole 11 months ago 100%

    It is annoying that you can't necessarily connect to all instances from your favorite instance, but this is also what makes the fediverse great compared to more centralized social media. Even though dessalines decided to delist ani.social, ani.social still exists and is still connected to instances other than lemmy.ml.

    Although seemingly distorted views of reality coming from the main lemmy dev team do concern me.

    8
  • anime Anime Sousou no Frieren • Frieren: Beyond Journey's End - Episode 8 discussion
    Jump
  • vole vole 11 months ago 100%

    It doesn't translate to "the undertaker", I meant that it's a nickname like "The Undertaker" is a nickname. Or "The Red Baron", "Jack the Ripper". That is to say, a nickname that conveys notoriety/fame rather than a nickname for your chums.

    From the Demon's monologue the end of the episode:

    "I see. I remember now. It was Frieren. The mage who contributed significantly to humanity's analysis of Zoltraak and slew more demons than anyone else in history. Frieren the Slayer (葬送のフリーレン). One of the geniuses I despise."

    So we see that in the Crunchyroll translation (and I imagine the translation of the manga as well), 葬送のフリーレン gets 2 translations:

    • Title of the show: 葬送のフリーレン ➡️ Frieren: Beyond Journey's End
    • Nickname of the character: 葬送のフリーレン ➡️ Frieren the Slayer
    2
  • anime Anime Sousou no Frieren • Frieren: Beyond Journey's End - Episode 8 discussion
    Jump
  • vole vole 11 months ago 92%

    The way Demons think in this show is a lot like LLM Chat AIs like ChatGPT work. They don't really think too much, not in the way humans do, but they excel at producing something that humans approve of. If you don't probe them too much, they look just like humans. But if you probe too far you see that their behavior is a facade and that their underlying thoughts are not like humans, and they don't necessarily even understand the words they use to appease humans. What happens when their facade improves? If a demon spent its entire life perfectly acting as a nice and thoughtful human, never causing any harm, would you still call it a monster?

    Demons and LLM Chat AIs differ in what their underlying thoughts are. LLM Chat AIs generally want approval. On the other hand, Demons want to survive and eat humans. They use language to manipulate humans and get what they want.

    12
  • anime Anime Sousou no Frieren • Frieren: Beyond Journey's End - Episode 8 discussion
    Jump
  • vole vole 11 months ago 100%

    I find it a little sad that the double entendre of the title was lost in translation. From the beginning I understood the title to refer to Frieren watching her friends pass away of old age. Then this scene comes around and lets us know that 葬送のフリーレン is not just the title of the story; it's the nickname for Frieren, like The Undertaker or something like that; a name that conveys the destiny of demons that cross Frieren's path.

    4
  • anime Anime Top 10 Anime of the Week #03 - Fall 2023 (Anime Corner)
    Jump
  • vole vole 11 months ago 100%

    When does the pain end!?

    From my experience: never. A lot of shows stop airing before they reach a significant resolution, only to be replaced next season with more shows with new problems. You gotta drop the take-your-lumps, horror, thriller, and melodrama shows if you want a respite from the pain.

    2
  • anime Anime Top 10 Anime of the Week #03 - Fall 2023 (Anime Corner)
    Jump
  • vole vole 11 months ago 100%

    I've now checked out the 3 available episodes of Berserk of Gluttony. From what I've seen I don't expect it to tell a particularly interesting story, but it has been fun to watch.

    1
  • anime Anime Top 10 Anime of the Week #03 - Fall 2023 (Anime Corner)
    Jump
  • vole vole 11 months ago 100%

    Update: I've now watched the available episodes of Berserk of Gluttony and Ragna Crimson. Both are good fun.

    Berserk of Gluttony so far has not been much more than an edgy fantasy power-fantasy. But it's executed well and has been enjoyable. I think it's a little darker than the typical power-fantasy. The bad-guys are laughably evil and I'm not sure if the plot is going anywhere interesting.

    Ragna Crimson is more story focused. I supposed this show also has the makings of a power-fantasy, but it has not leaned too heavily into the wish fulfillment aspect. The characters are more interesting. The bad-guys are also laughably evil here, but in a way that's more pure (literally being monsters helps, I guess), and thus a bit more horrifying. Every reward has a price, and you often do not know what that price actually is.

    5
  • anime Anime Top 10 Anime of the Week #03 - Fall 2023 (Anime Corner)
    Jump
  • vole vole 11 months ago 100%

    Anime Corner rankings have always been strange. That being said, I was pushing off watching episode 2 of Spy x Family because I just wasn't interested for some reason. I did get around to watching episode 2 and it was great.

    4
  • anime Anime Top 10 Anime of the Week #03 - Fall 2023 (Anime Corner)
    Jump
  • vole vole 11 months ago 100%

    Hm, I had written off Ragna Crimson and Berserk of Gluttony based on instinct, but it looks like they might be worth a try.

    3
  • anime Anime Level 1 dakedo Unique Skill de Saikyou desu • My Unique Skill Makes Me OP even at Level 1 - Episode 12 discussion - FINAL
    Jump
  • vole vole 12 months ago 100%

    I did it, I made it all the way to the end. It wasn't easy, but here I am. I probably should have dropped it, but I didn't. There's really not much to praise this anime for, but it had a positive tone and there were mildly interesting events happening. They also definitely made it feel like a fantasy world; the idea that everything comes from dungeon drops is in itself interesting, but the exploration of this concept was just wacky. I guess maybe I was supposed to laugh at all the lukewarm wacky stuff.

    The fact that they had an episode summary at the start of most episodes was pretty crazy.

    2
  • anime Anime Discussion Reign of the Seven Spellblades - Episode 6 discussion
    Jump
  • vole vole 1 year ago 100%

    haha, I didn't think of Eminence in the Shadow. Oliver is almost living out Cid's dream, with his secret special ability, secret special motivation, secret special ambitions, and secret special coronation.

    Eminence in the Shadow really nailed it on the head.

    2
  • anime Anime Discussion Reign of the Seven Spellblades - Episode 6 discussion
    Jump
  • vole vole 1 year ago 100%

    Huh, lots of stuff going on in this episode. We finally get the titular seventh spellblade... Funnily enough, Bungou Stray Dogs season 5 also showcases the ability to cut through space-time that kinda makes the seventh spellblade look quaint.

    Oliver's motivations are revealed with a little bit of his mother's (?!) backstory from seven (?!) years ago, but it seems like there is more to tell. Hopefully they also get around to explaining why there is a cult.

    Looks like Oliver didn't need the advice that Richard Andrews gave him last episode.

    2
  • anime Anime [Discussion] Jujutsu Kaisen Season 2 - Episode 5
    Jump
  • vole vole 1 year ago 100%

    I'm almost happy for Getou, at least he looks happy now. It looks like we're done watching Gojo and Getou's past and are going back to the main story timeline.

    3
  • anime
    Anime vole 1 year ago 100%
    Watch "Skip and Loafer"

    cross-posted from: https://lemmy.world/post/2395857 > I just finished watching *Skip and Loafer*, which aired this most recent spring season. I'm here to tell you: you should watch it too! > > It's a coming of age story about a girl moving from the countryside to Tokyo to go to a better high school. It's full of heart-warming moments as these kids become friends and try to figure out how they should interact with the world. > > The characters, story, animation, and sound are all fantastic. The show brings a comforting warmth, with a little drama to keep things interesting. Don't let this show pass you by! > > Links: > * [MyAnimeList](https://myanimelist.net/anime/50416/Skip_to_Loafer) > * [CrunchyRoll](https://www.crunchyroll.com/series/G9VHN9185/skip-and-loafer)

    6
    3
    anime
    Anime Discussion vole 1 year ago 80%
    Watch "Skip and Loafer"

    I just finished watching *Skip and Loafer*, which aired this most recent spring season. I'm here to tell you: you should watch it too! It's a coming of age story about a girl moving from the countryside to Tokyo to go to a better high school. It's full of heart-warming moments as these kids become friends and try to figure out how they should interact with the world. The characters, story, animation, and sound are all fantastic. The show brings a comforting warmth, with a little drama to keep things interesting. Don't let this show pass you by! Links: * [MyAnimeList](https://myanimelist.net/anime/50416/Skip_to_Loafer) * [CrunchyRoll](https://www.crunchyroll.com/series/G9VHN9185/skip-and-loafer)

    3
    0
    anime Anime I Ranked EVERY Anime of Summer 2023 - Mother's Basement
    Jump
  • vole vole 1 year ago 100%

    It was nice to get an overview of all the airing anime.

    I can confirm that Jujutsu Kaisen and Mushoku Tensei are bangers.

    I just watched the first 3 episodes of Reign of the Seven Spellblades because he was enthusiastic about it, but I didn't find it particularly good. I'd definitely place it lower than Bungo Stray Dogs. I'll continue watching it for now.

    I want to give Undead Murder Farce a watch, but I have a feeling it'll be better to binge it once the season has finished.

    I wasn't even aware of Zom 100 or Link Click, some more to watch in the future.

    I haven't watched Dark Gathering. I'm skeptical, but I'm willing to give it try.

    I can confirm My Unique Skill Makes Me OP Even At Level 1 is trash and mildly enjoyable. Level 1 Demon Lord and One Room Hero sounds like it's worth trying out.

    As for The Duke of Death and His Maid, I didn't find the first season interesting enough for me to watch the second. I didn't even think the CGI looked that bad, I just never felt particularly interested in the contents. The OP song for season 1 was great, though.

    Masamune-kun’s Revenge R is a show I thought I'd watch, but then I saw that I had actually rated the first season a score of 6 on MyAnimeList (which is a barely-not-dropped score for me). So, I decided to hold off. I'll watch it if it has favorable reviews when it finishes.

    3
  • anime Anime Discussion People who like Iseleve or similar anime, please help me understand the appeal
    Jump
  • vole vole 1 year ago 100%

    I'm not a huge fan of Iseleve, but I found enjoyment in it. For me it was a bit like watching a campy movie for fun, part of the fun was very much jeering at it with others. Everything is so over the top and absolutely ridiculous. Some parts are bananas, but not once does the show acknowledge its ridiculousness -- it plays everything completely straight faced. It made me wonder: was it written this way because the author thought this Mary Sue would be super cool, or was it written this way because the author wanted to absolutely abuse a few tropes to the furthest extent that he possibly can. I don't know what the truth is, it may be a mixed bag, either way the end product is fascinating to watch.

    To enjoy the show, I think you probably also have to enjoy the Mary Sue & wish-fulfillment aspect to some extent. There's just too much of it to ignore or jeer at all of it.

    I think what I don’t like is that is feels like the MC is literally handed everything and there is no challenge whatsoever; for me it feels a bit like a story-on-rails feeling and I don’t feel really connected to any of the characters, as if they are just cookie-cutter templates with no depth or personality.

    Absolutely, this show has little nuance. The characters don't feel like real people. The plot and character development is asinine. The visuals were actually OK, there were a few pretty scenes.

    I think the top review on MAL is worth a read if you haven't read it yet https://myanimelist.net/reviews.php?id=490093 ... Though be warned, that review may be more interesting than the show itself.

    2
  • anime Anime Discussion Jujutsu Kaisen 2 - Episode 3 Discussion
    Jump
  • vole vole 1 year ago 100%

    RIP Gojou. I guess he's just too cool for TV.

    But seriously, JJK continues to deliver episodes overflowing with style, an interesting plot, and great animation & sound & voice. It's awesome.

    It was interesting to see Nanami in this time period, I was not expecting to see him.

    2
  • anime
    Anime Discussion vole 1 year ago 100%
    Jujutsu Kaisen 2 - Episode 3 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GRDV0019R/jujutsu-kaisen) Show information: * [MyAnimeList](https://myanimelist.net/anime/51009/Jujutsu_Kaisen_TV_2nd_Season)

    6
    1
    anime Anime Discussion Mushoku Tensei Season 2 Episode 2 Preview
    Jump
  • vole vole 1 year ago 100%

    A bit late, Episode 2 already aired July 16...

    1
  • anime Anime Discussion Bungou Stray Dogs 5 - Episode 2 Discussion
    Jump
  • vole vole 1 year ago 100%

    An exciting episode. Man, Ouchi is really loved by the UN members. It seemed a bit unnecessary for Ouchi to get on the boat. Maybe Ranpo didn't have enough information, but it probably wouldn't have hurt have used his 'ability' a bit earlier. It looks like next episode will have a battle, as an impossible prophesy is fulfilled and the classic combo is reunited.

    These first two episodes have been intense, and it looks like the show has no intention of stopping.

    1
  • anime
    Anime Discussion vole 1 year ago 100%
    Bungou Stray Dogs 5 - Episode 2 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GR5VXQ8PR/bungo-stray-dogs) Show information: * [MyAnimeList](https://myanimelist.net/anime/54898/Bungou_Stray_Dogs_5th_Season)

    2
    1
    anime
    Anime Discussion vole 1 year ago 100%
    Bungou Stray Dogs 5 - Episode 1 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GR5VXQ8PR/bungo-stray-dogs) Show information: * [MyAnimeList](https://myanimelist.net/anime/54898/Bungou_Stray_Dogs_5th_Season)

    4
    1
    anime
    Anime Discussion vole 1 year ago 100%
    Vinland Saga Season 2 - Episode 24 Discussion FINAL

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GEXH3WKK0/vinland-saga) Show Information: * [MyAnimeList](https://myanimelist.net/anime/49387)

    5
    0
    anime
    Anime Discussion vole 1 year ago 100%
    Kimetsu no Yaiba: Katanakaji no Sato-hen (Demon Slayer: Kimetsu no Yaiba Swordsmith Village Arc) - Episode 11 Discussion FINAL

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GY5P48XEY/demon-slayer-kimetsu-no-yaiba) * [Direct link to episode](https://www.crunchyroll.com/demon-slayer-kimetsu-no-yaiba/episode-11-a-connected-bond-daybreak-and-first-light-895631) because the season page on Crunchyroll doesn't seem to be fully functional at the time of posting Show Information: * [MyAnimeList](https://myanimelist.net/anime/51019)

    22
    13
    anime
    Anime Discussion vole 1 year ago 100%
    Mobile Suit Gundam: Suisei no Majo (Mobile Suit Gundam: The Witch from Mercury) - Episode 22 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/G79H2307W/mobile-suit-gundam-the-witch-from-mercury) Show Information: * [MyAnimeList](https://myanimelist.net/anime/53199)

    5
    4
    anime
    Anime Discussion vole 1 year ago 100%
    Jigokuraku (Hell's Paradise) - Episode 11 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GJ0H7Q5ZJ/hells-paradise) Show Information: * [MyAnimeList](https://myanimelist.net/anime/46569)

    5
    0
    anime
    Anime Discussion vole 1 year ago 100%
    Mahou Tsukai no Yome Season 2 (The Ancient Magus' Bride Season 2) - Episode 11 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GRZXQJJ8Y/the-ancient-magus-bride) Show Information: * [MyAnimeList](https://myanimelist.net/anime/52955)

    5
    1
    anime
    Anime Discussion vole 1 year ago 98%
    [Oshi no Ko] - Episode 9 Discussion

    Streams: * [HIDIVE](https://www.hidive.com/tv/oshi-no-ko) Show Information: * [MyAnimeList](https://myanimelist.net/anime/52034)

    59
    3
    anime
    Anime Discussion vole 1 year ago 100%
    Isekai de Cheat Skill wo Te ni Shita Ore wa, Genjitsu Sekai wo mo Musou Suru: Level Up wa Jinsei wo Kaeta (I Got a Cheat Skill in Another World …) - Episode 11 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GEXH3W49E/i-got-a-cheat-skill-in-another-world-and-became-unrivaled-in-the-real-world-too) Show Information: * [MyAnimeList](https://myanimelist.net/anime/52830)

    5
    1
    anime
    Anime Discussion vole 1 year ago 100%
    Vinland Saga Season 2 - Episode 23 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GEXH3WKK0/vinland-saga) Show Information: * [MyAnimeList](https://myanimelist.net/anime/49387)

    11
    1
    anime
    Anime Discussion vole 1 year ago 100%
    Kimetsu no Yaiba: Katanakaji no Sato-hen (Demon Slayer: Kimetsu no Yaiba Swordsmith Village Arc) - Episode 10 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GY5P48XEY/demon-slayer-kimetsu-no-yaiba) Show Information: * [MyAnimeList](https://myanimelist.net/anime/51019)

    7
    2
    anime
    Anime Discussion vole 1 year ago 100%
    Mobile Suit Gundam: Suisei no Majo (Mobile Suit Gundam: The Witch from Mercury) - Episode 21 Discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/G79H2307W/mobile-suit-gundam-the-witch-from-mercury) Show Information: * [MyAnimeList](https://myanimelist.net/anime/53199)

    5
    0
    anime
    Anime Discussion vole 1 year ago 100%
    Yamada-kun to Lv999 no Koi wo Suru (My Love Story with Yamada-kun at Lv999) - Episode 11 discussion

    Streams: * [Crunchyroll](https://www.crunchyroll.com/series/GNVHKNPQ7/my-love-story-with-yamada-kun-at-lv999) Show Information: * [MyAnimeList](https://myanimelist.net/anime/53126/Yamada-kun_to_Lv999_no_Koi_wo_Suru)

    6
    1
    anime
    Anime Discussion vole 1 year ago 100%
    Jigokuraku (Hell's Paradise) - Episode 10 Discussion

    Streams: * [CrunchyRoll](https://www.crunchyroll.com/series/GJ0H7Q5ZJ/hells-paradise) Show Information: * [MyAnimeList](https://myanimelist.net/anime/46569/Jigokuraku)

    5
    0