jonah's recent activity

  1. Comment on Day 4: Printing Department in ~comp.advent_of_code

    jonah
    Link
    Python Standard brute-force method of solving both of these and didn't take too long on my machine (sub 1s for both) so I'm happy enough to share my solution. I'm used to there being some kind of...

    Python

    Standard brute-force method of solving both of these and didn't take too long on my machine (sub 1s for both) so I'm happy enough to share my solution. I'm used to there being some kind of edge case that my test input didn't capture, but it was pretty straight forward today and I didn't end up running into any of those problems.

    I'm also going to remove my utility grid_at method because... well you can imagine how that's implemented and it's just noise in the code (and I did not save any grid utilities from last year...)

    Part 1
    from common import load_input
    input = load_input()
    
    # def grid_at(grid, x, y)
    
    relative = [
        (-1, -1), (0, -1), (1, -1),
        (-1, 0),           (1, 0),
        (-1, 1),  (0, 1),  (1, 1),
    ]
    
    grid = list(map(lambda x: list(x), input.splitlines()))
    w, h = len(grid[0]), len(grid)
    
    total = 0
    for y in range(h):
        for x in range(w):
            if grid_at(grid, x, y) != '@':
                continue
            res = list(map(lambda d: grid_at(grid, x + d[0], y + d[1]), relative))
            if res.count('@') < 4:
                total += 1
    
    print(total)
    
    Part 2
    from common import load_input
    input = load_input()
    
    # def grid_at(grid, x, y)
    
    relative = [
        (-1, -1), (0, -1), (1, -1),
        (-1, 0),           (1, 0),
        (-1, 1),  (0, 1),  (1, 1),
    ]
    
    grid = list(map(lambda x: list(x), input.splitlines()))
    w, h = len(grid[0]), len(grid)
    
    total = 0
    
    while True:
        to_remove = []
        local_total = 0
        for y in range(h):
            for x in range(w):
                if grid_at(grid, x, y) != '@':
                    continue
                res = list(map(lambda d: grid_at(grid, x + d[0], y + d[1]), relative))
                if res.count('@') < 4:
                    to_remove.append((x, y))
                    local_total += 1
        if local_total == 0:
            break
        total += local_total
        for (x, y) in to_remove:
            grid[y][x] = '.'
    
    print(total)
    
    1 vote
  2. Comment on Day 3: Lobby in ~comp.advent_of_code

    jonah
    Link
    Python I almost gave up. I did not write my part 1 to be generalized for the second part, but when I figured out how to generalize it, I was able to keep the same efficiency as part 1. On my...

    Python

    I almost gave up. I did not write my part 1 to be generalized for the second part, but when I figured out how to generalize it, I was able to keep the same efficiency as part 1. On my machine, my benchmark times (thank you hyperfine) were 8.4ms and 9.4ms respectively.

    Part 1
    from common import load_input
    input = load_input()
    
    def find_largest(batteries: [int], start_index: int, chop: int) -> int:
        largest = -1
        largest_index = -1
        for i in range(start_index, len(batteries) - chop):
            if batteries[i] > largest:
                largest = batteries[i]
                largest_index = i
        return largest_index
    
    total = 0
    banks = input.split('\n')
    for bank in banks:
        batteries = list(map(int, list(bank)))
        a = find_largest(batteries, 0, 1)
        b = find_largest(batteries, a + 1, 0)
        total += (batteries[a] * 10) + batteries[b]
    
    print(total)
    
    Part 2
    from common import load_input
    input = load_input()
    
    def find_largest(batteries: [int], start_index: int, chop: int) -> int:
        largest = -1
        largest_index = -1
        for i in range(start_index, len(batteries) - chop):
            if batteries[i] > largest:
                largest = batteries[i]
                largest_index = i
        return largest_index
    
    total = 0
    banks = input.split('\n')
    for bank in banks:
        batteries = list(map(int, list(bank)))
    
        allowed = 12
        last_index = 0
        for i in range(allowed):
            n = find_largest(batteries, last_index, (allowed - i - 1))
            power = pow(10, (allowed - i - 1))
            total += batteries[n] * (1 if power == 0 else power)
            last_index = n + 1
    
    print(total)
    
    1 vote
  3. Comment on Day 2: Gift Shop in ~comp.advent_of_code

    jonah
    Link Parent
    You're welcome! good luck and have fun

    You're welcome! good luck and have fun

    1 vote
  4. Comment on Day 2: Gift Shop in ~comp.advent_of_code

    jonah
    Link Parent
    Because in those numbers, the repeated digits are repeated more than twice

    Because in those numbers, the repeated digits are repeated more than twice

    2 votes
  5. Comment on Day 2: Gift Shop in ~comp.advent_of_code

    jonah
    Link
    I didn't post yesterday because I was annoyed at how long it took me. I was much happier today. My part 1 took very little time to write and executed pretty quickly, but part 2 took a little...

    I didn't post yesterday because I was annoyed at how long it took me. I was much happier today. My part 1 took very little time to write and executed pretty quickly, but part 2 took a little longer. On my machine I averaged about 1.2s. I decided to plug in some threading (not included here) to see if I could get it faster, and got it down to ~230ms. That was a cool win for today!

    Part 1
    from common import load_input
    input = load_input()
    
    # There's gotta be a better way to do this
    def id_is_invalid(prod_id: int) -> bool:
        str_id = str(prod_id)
        if len(str_id) % 2 != 0:
            return False
        mid = int(len(str_id) / 2)
        first, last = str_id[:mid], str_id[mid:]
        return first == last
    
    # Gross, but it works
    ranges = list(map(lambda x: list(map(lambda y: int(y), x.split('-'))), input.split(',')))
    counter = 0
    
    # Dumb solution but it works
    for r in ranges:
        for prod_id in range(r[0], r[1] + 1):
            if id_is_invalid(prod_id):
                counter += prod_id
    
    print(counter)
    
    Part 2
    from common import load_input
    input = load_input()
    
    def has_pattern_count(s, m, k):
        if s.count(s[:m]) >= k:
            return True
        return False
    
    def id_is_invalid(prod_id: int) -> bool:
        # Single digit IDs can't possibly match the criteria
        # And yes, this got me
        if prod_id < 10:
            return False
    
        str_id = str(prod_id)
        str_len = len(str_id)
    
        # m -> pattern length
        # k -> number of repetitions
        # m * k should always equal str_len
        # i.e., str_len / m should always be a whole number, and the result is k
    
        m = 1
        while m < (str_len / 2) + 1:
            if str_len % m == 0:
                k = str_len / m
                if has_pattern_count(str_id, m, k):
                    return True
            m += 1
    
        return False
    
    # Gross, but it works
    ranges = list(map(lambda x: list(map(lambda y: int(y), x.split('-'))), input.split(',')))
    counter = 0
    
    # Dumb solution but it works
    for r in ranges:
        print("Processing range:", r)
        for prod_id in range(r[0], r[1] + 1):
            if id_is_invalid(prod_id):
                counter += prod_id
    
    print(counter)
    
    2 votes
  6. Comment on Netflix kills casting from phones in ~tech

    jonah
    (edited )
    Link Parent
    If you have an old-ish PC lying around, you can get a cheaper NAS without all the bells and whistles. I have an older desktop powering my Jellyfin setup and it works pretty well. I got a Ubiquiti...

    If you have an old-ish PC lying around, you can get a cheaper NAS without all the bells and whistles. I have an older desktop powering my Jellyfin setup and it works pretty well. I got a Ubiquiti NAS and I’ve been thrilled with it. I wanted something that was actually… network attached storage and not another fully fledged computer setup built for media transcoding and all that. If you already have some hardware lying around it doesn’t have to be super expensive to self host.

    Edit: I also missed your point about fixing stuff that doesn’t work. That used to be me too, so I get it. Once I dockerized everything, the time I’ve spent managing my stuff has approached zero. Managing that stuff is not for everyone. Sometimes it’s easier to have someone else worry about it

    7 votes
  7. Comment on I think nobody wants AI in Firefox, Mozilla in ~tech

    jonah
    Link Parent
    Quick answers are enabled by default insofar as your search will prompt a quick answer if it ends in a question mark. Given that most people do not literally type questions into their search...

    Quick answers are enabled by default insofar as your search will prompt a quick answer if it ends in a question mark. Given that most people do not literally type questions into their search engine (and also ending it in a question mark) I would not consider this to be an AI feature that is enabled by default the same way that Google’s quick answers is. It’s also very easy to disable if you would in fact like to write your search query in the form of a question.

    I read your other comment about wanting to use products that are 100% AI free, so I’ll just concede that Kagi does in fact develop many AI features and if that’s a problem for you then I won’t try and convince you otherwise. I was instead trying to argue against the implied characterization of Kagi that they are chasing trends which I think is obviously false based on their history and their AI philosophy. Perhaps you disagree! Either way I appreciate the discussion.

    4 votes
  8. Comment on I think nobody wants AI in Firefox, Mozilla in ~tech

    jonah
    Link Parent
    Kagi started out focused on AI technology in 2018. Their AI philosophy is also to create integrations that are opt-in and ostensibly provide some value. I don’t personally feel as though they are...

    Kagi started out focused on AI technology in 2018. Their AI philosophy is also to create integrations that are opt-in and ostensibly provide some value. I don’t personally feel as though they are “shoving AI features everywhere” and I think to say as much implies they are chasing trends or adding AI for the sake of having AI in their product. You may not find any value in their AI features which is understandable. I don’t really find much value in them either. But I’ve also never had the feeling that they’ve been shoving them into their main product.

    4 votes
  9. Comment on Experiences with united healthcare in ~health

    jonah
    (edited )
    Link
    We’re on a PPO plan and In my experience they’ve been good. We had a baby while covered by UHC and my wife has a health concern that would be very expensive to treat without coverage. Granted, we...

    We’re on a PPO plan and In my experience they’ve been good. We had a baby while covered by UHC and my wife has a health concern that would be very expensive to treat without coverage. Granted, we live in an area with a lot of health care options, but we’ve basically been able to go wherever we want, be in network, and have not yet had to fight any claims.

    The only issue we had was them not wanting to give us a non-standard refill window on new-ish name brand speciality medication. And I’m not convinced another insurance provider would’ve done so either. They also barely paid anything for our medications before our deductible was hit. You mentioned not being worried about prescriptions, but wanted to mention for others reading the thread.

    In any case, it’s been pretty much the same compared to my last job with insurance through BCBS.

    YMMV

    6 votes
  10. Comment on 2025 NFL Season 🏈 Weekly Discussion Thread – Week 1 in ~sports.american_football

    jonah
    Link Parent
    I'm a Chiefs fan. My wife's family are all Chiefs people, and due to my location it seemed like a good team to be a fan of when I started paying attention to the NFL a few years ago. Some may call...

    I'm a Chiefs fan. My wife's family are all Chiefs people, and due to my location it seemed like a good team to be a fan of when I started paying attention to the NFL a few years ago. Some may call me a bandwagon fan which is okay because I know I'm not, it's more of a timing issue.

    I say all that because I'd like for you to have the context before I say: I love my team, but I would be absolutely thrilled to see either of those two teams make it to the Super Bowl this year. Both of those teams absolutely deserve an appearance at least, but I'd love to see them win it all too.

  11. Comment on Do we have enough NFL fans to warrant weekly discussions? in ~sports.american_football

    jonah
    Link
    Sorry to comment so late on this; I’m a casual NFL enjoyer and would very much enjoy conversation around the week! I may not contribute much as I too often lurk around here. I’d love to hear...

    Sorry to comment so late on this; I’m a casual NFL enjoyer and would very much enjoy conversation around the week! I may not contribute much as I too often lurk around here. I’d love to hear others’ thoughts on the games though!

    2 votes
  12. Comment on Moser's Frame Shop: I am an AI hater in ~tech

    jonah
    Link Parent
    I left a very generic message in my claude.md for the agent to refer to me as "Batman" and it's very fun. At the end of a session if I say "thank you" it'll often say something to the effect of...

    I left a very generic message in my claude.md for the agent to refer to me as "Batman" and it's very fun. At the end of a session if I say "thank you" it'll often say something to the effect of "I'm glad I could assist you in protecting Gotham!"

    I try to have fun

    1 vote
  13. I am still awake after feeding my newborn

    It’s before 5am CT, and I’ve been awake since… 2:30am. Most nights, I can feed my newborn and fall right back asleep. I believe that some work stress has kept me awake. It got me thinking about...

    It’s before 5am CT, and I’ve been awake since… 2:30am. Most nights, I can feed my newborn and fall right back asleep. I believe that some work stress has kept me awake. It got me thinking about some questions to ask the group:

    1. For those of us who would rather be productive than lie in bed awake for an extended period of time, how long before you decide to just get up and do something? I’m a little surprised I haven’t just gotten up yet. I think I will here in a few minutes.
    2. What are some fun activities you like to get up to when it’s the middle of the night and everyone is asleep? I’m a software engineer by trade so I tend to work on a side project. Maybe a music project if it’s something quiet.
    3. The age old question: how can I fall back asleep? I can usually count backwards from 100 and by the second time through I’ll be out. Does anyone have anything more interesting?

    I’m sure variations of this topic have been posted before, so I apologize if this is less than novel. Retitle as necessary, I couldn’t think of a good one.

    38 votes
  14. Comment on iOS26 "Liquid Glass" - is it really such a big deal? in ~tech

    jonah
    Link Parent
    So FYI, iOS 26 jumped from iOS 18. So you got me there, I cannot name anything that came out in iOS 25 or 24! Anyways, as an example, iOS 18 introduced text formatting in iMessage if I am not...

    So FYI, iOS 26 jumped from iOS 18. So you got me there, I cannot name anything that came out in iOS 25 or 24!

    Anyways, as an example, iOS 18 introduced text formatting in iMessage if I am not mistaken which was actually huge for me.

    And yes, I do think Liquid Glass is a bigger deal than the other 4. I think I was clear about it being a big deal in my first reply. I just don't think it's a big deal from a technical perspective. There are certainly impressive things about it like I mentioned.

    9 votes
  15. Comment on iOS26 "Liquid Glass" - is it really such a big deal? in ~tech

    jonah
    Link Parent
    At the beginning of the video he says he's going through the top five features of iOS 26 with the Liquid Glass redesign coming in at number 1. That definitely seems like he's saying it's a big...

    At the beginning of the video he says he's going through the top five features of iOS 26 with the Liquid Glass redesign coming in at number 1. That definitely seems like he's saying it's a big deal. On one hand, it kind of is a big deal because it's a major front end redesign that most iPhone users are going to notice. On the other hand... it's not super impressive at a high level. I think the redesign really shines in the subtleties (like glass refraction at the edges of some areas), but I don't think most users will be very aware of those. At the end of the day, it's a different theme. Large visibility, but not ultimately super impressive from my own experiences.

    8 votes
  16. Comment on Question about REST APIS and encryption in ~tech

    jonah
    Link
    Lots of excellent practical advice has been given to you so far in the thread, but I believe I am somewhat qualified to answer your theoretical questions more directly. I did my best to read...

    Lots of excellent practical advice has been given to you so far in the thread, but I believe I am somewhat qualified to answer your theoretical questions more directly. I did my best to read through all the comments, so I apologize if I'm adding thoughts that have already been added. Not too long ago, I was working at Mastercard for a couple of years developing in-house key management software which involved a lot of different encryption methods and some pretty complex architecture. Developing that kind of system requires diving deep into the world of cryptography. Before answering your questions, I want to concur with some other advice in the thread: Doing cryptography yourself is a great exercise, but the closer you are to the cryptographic implementation layer, the more likely it is that you'll screw something up. In a production setting you would want an expert in the subject to verify your architectural decisions and implementation. Now that that's out of the way, some direct answers to your questions:

    1. Google does not store their encryption keys (or at least their root encryption keys) in a database. Most likely, Google stores their encryption keys in Hardware Security Modules (HSMs). These are specially designed hardware devices for the specific purpose of securely generating and storing cryptographic keys. Without getting too technical, it is practically impossible for anyone (even most people at Google) to ever have access to these keys. Data encryption and decryption with those keys takes place inside the HSM, so the keys are never exposed "in the clear." So while Google at-large can decrypt the data that gets sent to its server, there is almost certainly a complicated web of cryptographic services within Google that ensure their encryption keys are never exposed.

    2. End-to-end encryption I think by definition means that the server or any other actor between the ends never receives sensitive data in plaintext. That would defeat the purpose. So if you have a server in the middle, that server should never receive plaintext data that should otherwise be encrypted, or cryptographic keys that can be used to decrypt any sensitive information. There's a whole wealth of knowledge on the internet, and some in this thread, that describes in detail how these systems work that I will not belabor here. Asymmetric cryptography plays a role, but there is usually some hybrid of asymmetric and symmetric cryptography that is in place for systems like this. To answer more directly, if I were designing an E2EE API, the sensitive bits would be encrypted the whole way through until it reached a client.

    All that being said, I worked pretty closely with some of this stuff for a couple of years which makes me more knowledgeable on the subject than most, but it still does not make me an expert. Cryptography is a vast and complex web of math and computer science. Given the demographic of the site, it's very likely there are some engineers here with more experience than me on this topic. To those more experienced folks, please correct any info here if misleading or incorrect.

  17. Comment on What programming/technical projects have you been working on? in ~comp

    jonah
    Link Parent
    I've been using Cursor at work which has actually done a much better job than I expected. I think because I sort of refused to use AI for a few years my mind is still stuck in 2022. Especially...

    I've been using Cursor at work which has actually done a much better job than I expected. I think because I sort of refused to use AI for a few years my mind is still stuck in 2022. Especially after the Claude 4 release, I was shocked to see how well it was able to write code.

    To the doubters, let me give you a scenario that Cursor has massively assisted me with:
    I'm a newer member of the team and have had some work to do in larger legacy codebases with a framework I'm not super familiar with. Cursor saved me probably hours of reading documentation and writing boilerplate code to implement a new feature. Now, I still did a good chunk of the feature implementation, but Cursor helped me get there so much faster than if I did it myself. I made a joke in the Cloudflare outage thread the other day about writing unit tests, but I'm being serious now, Cursor again saved me hours of writing unit tests and it actually did a good job. Again, I have been very surprised by its performance.

    It felt like I was cruising through the code. "Cruise coding" if you will.

    2 votes
  18. Comment on Cloudflare is down causing multiple services to break in ~tech

    jonah
    Link Parent
    What am I supposed to do, write my unit tests manually?

    What am I supposed to do, write my unit tests manually?

    14 votes
  19. Comment on Looking for home networking recommendations in ~tech

    jonah
    Link Parent
    I run it alongside a bunch of other services and I haven’t noticed any difference at all. It’s a Java program underneath so I think you have to “allocate” a certain amount of memory to the JVM...

    I run it alongside a bunch of other services and I haven’t noticed any difference at all. It’s a Java program underneath so I think you have to “allocate” a certain amount of memory to the JVM that may just sit around being unused. CPU usage is negligible from what I’ve seen.

    2 votes
  20. Comment on Looking for home networking recommendations in ~tech

    jonah
    Link Parent
    I suppose I wouldn’t know, I didn’t start buying networking equipment until five years ago. Since 2020 I’ve been happy with my TP-Link stuff! But YMMV

    I suppose I wouldn’t know, I didn’t start buying networking equipment until five years ago. Since 2020 I’ve been happy with my TP-Link stuff! But YMMV

    2 votes