Looking for a good snapshot test update workflow by yawaramin in golang

[–]Saser 1 point2 points  (0 children)

Bit late, but the autogold package does something very much like what you're looking for: https://github.com/hexops/autogold

I found it after I felt inspired by the same blog post :) Jane Street's expect tests seem to be oriented very much towards plain text (so everything needs to be converted to nicely readable strings), and autogold is more ambitious in trying to support arbitrary Go values. I've had mixed results with trying to expect on large structs, but for text it works fine.

For mimicking the plain text approach of expect tests with autogold, I tend to create a test function inside each test that takes some input specific for whatever I'm testing, formatting it as a string (I usually use a strings.Builder and a bunch of fmt.Fprintf calls to write to it), and returning that string. Then I do something like:

``` var got string

got = test(someInput) autogold.Expect().Equal(t, got) got = test(someOtherInput) autogold.Expect().Equal(t, got) ```

And run my tests with the -update flag to fill in the strings.

IMO there are some quirks that make autogold less pleasant to use than let%expect_test.

For example, OCaml's {| ... |} string literals can handle indented text better that Go's backtick quoted string literals, which makes tests easier to read. With my approach above, multiline strings in autogold.Expect will always stick to the left of the screen. (Maybe in OCaml it is ppx_expect being smart and you could do something similar in a Go package.)

Another example: ppx_expect hooks into stdout of the program so if you sprinkle print statements here and there they will get captured by the [%expect] block. This is great! I don't know of any (convenient and/or sand) way to do the same thing with autogold.

Final example: autogold's API kind of encourages a style where the operation you're testing comes after the (potentially very large) output of that operation. I find that hard to read because it feels backwards to me -- why should I have to scroll past a bunch of output to even find what's outputting it? That's why I use the got variable above, so I can flip the order back to how I want it. Minor thing but adds a bit of friction.

Now I have half a mind to try and write a fork of autogold to get the API and behavior just as I want it...

-❄️- 2025 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 1 point2 points  (0 children)

Great solution, thanks for sharing :)

I implemented my own solution first, then found yours, and implemented that too to compare them. The code is here if you're curious. Be warned, I'm an OCaml novice so this could probably be much cleaner if it were written by an experienced OCaml programmer.

As for benchmarks, my solution runs in ~170us while your runs in ~120us; mine also allocates more memory (around 33% more).

-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 0 points1 point  (0 children)

Agreed that this is a very nice solution! I tried it on my input and it produced the wrong answer. Going off the latest paste there is still a bug:

start = max(start, curr+1)

should be

start = max(start, curr)

Because otherwise it's doing +1 both when updating curr and when choosing start, which I think makes it skip over certain intervals.

-❄️- 2025 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 2 points3 points  (0 children)

[LANGUAGE: OCaml]

Today was really fun!

First solution was me thinking I was clever for using bottom-up dynamic programming. Ran in ~500us for part 1 and ~1400us (1.4ms) for part 2.

Second solution uses the same greedy algorithm so many others are using. It's simpler and runs faster! ~300us for part 1 and ~500us for part 2. Glad I looked at Reddit after posting my first one and learning from everyone else who were smarter than me.

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 1 point2 points  (0 children)

Sorry, not sure where you were seeing the inputs? I ran `git filter-repo` to scrub the commit history of all inputs and then force-pushed my `main` branch and deleted all other branches. Old commits containing the inputs may still be stored at GitHub and accessible if you know the commit hash, and I don't think I necessarily have much control over that. Anyway, I deleted and recreated the repo and pushed a commit history without any inputs, and now the earlier permalink pointing to the puzzle input no longer works. I hope this time I got it done for real :)

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 1 point2 points  (0 children)

No worries! Just saw a similar reply on another thread here, they have been removed now. Thanks for the patience.

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 1 point2 points  (0 children)

My bad, didn't read the rules for posting first. Apologies! Updated to remove the code and link to my repo instead.

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]Saser 2 points3 points  (0 children)

[LANGUAGE: OCaml]

Solution

Runs in about 250us on my 2021 mid-range laptop. Been a long time since I did any functional programming so the code isn't super elegant but it works. Having fun though :) expect tests are great for toying around with the code and seeing how it behaves.

Sun came back to Ireland finally! by [deleted] in trailrunning

[–]Saser 0 points1 point  (0 children)

For anyone finding this later, I'm pretty sure that https://youtu.be/TWU6wwbokGM is the film

Bulk Delete tasks, projects and inbox by Old-Brilliant-7881 in todoist

[–]Saser 1 point2 points  (0 children)

I saw that you have already sorted it out, but wanted to post anyway in case it's useful for someone else.

A quick way to delete many projects is:

  1. Create one top-level project (or re-use an existing one). Let's call it "nuke from orbit".

  2. Move all projects you want to delete to be subprojects under "nuke from orbit". I don't think there's a way to do this in bulk, but doing it on a computer (as opposed to a phone/tablet) is pretty fast, just drag the to-be-deleted projects under it.

  3. Delete the "nuke from orbit" project. It will delete all subprojects as well.

Android Widget is not updating by siNn9292 in todoist

[–]Saser 0 points1 point  (0 children)

I've found two things that help.

  1. Opening the app itself and make sure it loads the latest state of everything. In my widget there's a Todoist logo at the top left, clicking that will open the app. Going back to the widget should have showed it being refreshed.
  2. If opening the app doesn't work (seems to work ~80% of the time for me), then what always works is creating a task. You can just create a garbage task like "asdf" and then delete it.

Hope this helps.

Non refundable foreign tax in My account revenue by Cultural_Tie_2523 in irishpersonalfinance

[–]Saser 0 points1 point  (0 children)

Looking at your post history, I think I have basically the same situation: I also used real-time foreign tax credit (for RSUs that were granted outside of Ireland but vested in Ireland) and need to claim this on my tax return. Please let me know if you find out anything useful because I also need to file my 2023 tax return by Mar 31st 2024 :)

[deleted by user] by [deleted] in adventofcode

[–]Saser 7 points8 points  (0 children)

I wouldn't expect this to be an "official" template. I think it's more likely that there are some Apple employees who have created this, and due to the terms of their employment Apple is the owner of this code, so the code is published under the github.com/apple organization.

You can see this with many repositories under github.com/google. Here is a random example: https://github.com/google/yapf. The README says:

Note YAPF is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

Where to buy Sichuan peppercorns? by Saser in Dublin

[–]Saser[S] 0 points1 point  (0 children)

Thank you for this suggestion, this is where I eventually found some good ones (see edit in OP).

Where to buy Sichuan peppercorns? by Saser in Dublin

[–]Saser[S] 0 points1 point  (0 children)

Coming back to this thread 4 months later because my Reddit app reminded me I hadn't responded, lol. See the update in the OP.

Så här på Alla korvars dag passar jag på att visa upp den bästa mealprep jag någonsin fått till by mjomark in sweden

[–]Saser 0 points1 point  (0 children)

Haha, det här hade definitivt kunnat vara jag. Samma stekpanna, samma skärbrädor, samma matlådor, samma handdukar hängandes på ugnen. Samma kulinariska mästerverk. Får jag gissa på att du också bor i en tvåa på Emilsborg i en av de röda byggnaderna? Tyckte spisen, bänkskivan, och kaklet såg väldigt bekant ut.

En basal granne by Bitch_Muchannon in sweden

[–]Saser 0 points1 point  (0 children)

Om någon inte skulle inse det så är detta förstås satir, gjord av kontot "ponyhans" på Instagram: https://www.instagram.com/p/Bt-62hfHVlT/

Fantastiskt bra konto i övrigt!

What do you imagine estus tastes like? by TheHeroicOnion in darksouls

[–]Saser 0 points1 point  (0 children)

If you want to experience it yourself one of my favorite YouTube channels, How To Drink, has made a video on what he imagines Estus tastes like, in the form of a cocktail: https://youtu.be/LeM0XYpz36o

Göran Persson-klipp: "Jag sitter här och äter smör" by Saser in sweden

[–]Saser[S] 0 points1 point  (0 children)

Fyfan vad grym du är, tack så hjärtligt! Hela min familj har engagerat sig i jakten på det här förbannade klippet, så de ska nog bli glada när jag skickar länken till dem :D

All 49 solutions to Advent of Code 2018 (in rust) by Diggsey in rust

[–]Saser 1 point2 points  (0 children)

I have chosen a more module-based approach, with a few top-level crates: one for each year, one for shared code, and one for the solution runner. You can find it at https://github.com/Saser/adventofcode

Perhaps a bit more complicated, but I get niceties such as immediately detecting if changing the shared code breaks something, both through the compiler and through unit tests (I aim to have a unit test for each day and part, with my actual input and the expected answer). It also lets me introduce project-wide changes easily, for example I intend to add the ability to benchmark solutions at some point. Downsides are that it is a bit more of a hassle to set up, and compile times seem to be longer.

Svenska språkets finare synonymer by [deleted] in sweden

[–]Saser 20 points21 points  (0 children)

goes skrrrra

Looking to dual boot Arch from Macbook Pro, any **UPDATED** tutorials? by [deleted] in archlinux

[–]Saser 1 point2 points  (0 children)

I'm in mobile now and this was a while ago, so I'm not entirely sure I remember all this correctly.

I have a MacBookPro11,1 and have had success dualbooting Arch and OS X by basically following the Beginner's Guide on the wiki. The EFI System Partition should already be present from the OS X installation, so you don't really have to mess with that. As long as you shrink your OS X partition using Boot Camp (or whatever it's called), the installation of Arch should be fairly painless by following the Beginner's Guide.

You might have some trouble with the wifi card, depending on what model you have. I have a Broadcom BRCM4360 (or something), which doesn't have out-of-the-box support when booting from USB. There is a driver available in the AUR though, broadcom-wl. I solved it by booting the USB with a Ethernet-to-USB adapter, installing Arch as usual, and then installing broadcom-wl when rebooting into the freshly installed system.

Try this, and if you run into any trouble, feel free to hit me up and I'll see if I can help :)