Hmm.. instead of keeping the length in memory, could you null-terminate the array and maybe get a challenge that way?
@saturdaymp16 күн бұрын
Thanks for the suggestion @hex7329. I do try using a null terminated string towards the end but couldn't get it to work. I'll have to re-watch the video and see what I missed.
@Dandelionq8 ай бұрын
Thanks i was confused how to do it and now i can do it step by step
@Dandelionq8 ай бұрын
And how is that possible that you have less than 50 subs lol
@saturdaymp8 ай бұрын
Glad I could help @Dandelionq.
@Endede9 ай бұрын
Quick update: I did end up getting the game, and it's a lot of fun. For Three Sort, it really did feel like a sudden steep ramp-up in difficulty. I have managed to get a solution that beats the "Number of steps/cycles" challenge. It's very ugly and did not reveal any great insight. It's just a giant sequence of "if negative" jumps for each possible permutation of a < b < c. I'm hoping that the "number of instructions" challenge is more satisfying. I haven't tried it yet, and I honestly don't actually have any good idea for it yet.
@saturdaymp9 ай бұрын
@Endede glad you where able to figure out the number of steps for the Three Sort. I agree it was a big jump in difficulty, at least for me. I really miss having a higher level loop (e.g. a while or for loop). I wonder if my brain is so used to having the higher level programming features I can't solve problems without them? Feel free to share your solution either in the comments or a link a blog, video, etc.
@Endede9 ай бұрын
@@saturdaymp Oh yeah, I can definitely relate to the higher-level handicap. I don't think that's anything to lament about, but I have the same impression. Low-level thinking is just different from working with abstractions that are multiple layers above. Anyways, here's my approach for beating the number of cycles challenge for Three Sort. As I said, there's no big trick, it's just a completely unspooled decision tree, so I really needed to keep those helpful sticky note comments in the code to be able to keep track of which state we're in. At least it's in proper in-game format this time. :D -- HUMAN RESOURCE MACHINE PROGRAM -- a: b: c: d: e: f: INBOX COPYTO 0 INBOX COPYTO 1 INBOX COPYTO 2 SUB 1 JUMPN i COMMENT 1 COPYFROM 1 SUB 0 JUMPN g COMMENT 4 COPYFROM 0 OUTBOX COPYFROM 1 OUTBOX COPYFROM 2 OUTBOX JUMP b g: COMMENT 5 COPYFROM 1 OUTBOX COPYFROM 2 SUB 0 JUMPN h COMMENT 7 COPYFROM 0 OUTBOX COPYFROM 2 OUTBOX JUMP c h: COMMENT 6 COPYFROM 2 OUTBOX COPYFROM 0 OUTBOX JUMP d i: COMMENT 0 COPYFROM 1 SUB 0 JUMPN k COMMENT 3 COPYFROM 2 SUB 0 JUMPN j COMMENT 9 COPYFROM 0 OUTBOX COPYFROM 2 OUTBOX COPYFROM 1 OUTBOX JUMP e j: COMMENT 8 COPYFROM 2 OUTBOX COPYFROM 0 OUTBOX COPYFROM 1 OUTBOX JUMP f k: COMMENT 2 COPYFROM 2 OUTBOX COPYFROM 1 OUTBOX COPYFROM 0 OUTBOX JUMP a DEFINE COMMENT 0 eJyTZGBgkIg86iwR+XlSSNSKHUAuw4Lc6QEy+dMDJhQ/iljb8Ccrtdm5YFUjT7lzReHE6PyuxSA1rv2X fD5PveTzbvo1f62ZSyK1ZnaVrpkR02Q6de/Mmkk+S9r7rq02nTp5ZfPyySsZRsEoGAWDFgAAYuss0A; DEFINE COMMENT 1 eJxTY2BgmBdmZDYv7OCcOeEBy4FchmXZ7sVXC1kKsxufR4t1Tvbt6m1yBImrZ1tn/ay2ztJuZMjj7o2o b+9L7QCJ85eodTpXqHXuqn7dk9C6d+asdpb5IPHARe6uZWs43N6v63JP23TJR2Xz9IDkzYXJ6psY8vLW X6qqW1k40X3Z3plXF3QtNl/TtkBwV9uCisNdi1+euLSCYRSMglFAFwAA11k/cw; DEFINE COMMENT 2 eJzTZWBgcDOY7HtJ+3v6Je3pdR367/sbjHZO+266d6aazd6ZcvalU/pdbjWweezNdvVIjRJ2FvRZZHvU ea1lk6ONibOTnfFR5wajSz5AYxjCI8968sae9bRKueY/tfBzSmPi9Lpj8bLNILnaqirr2qo/WdXVB+eA +P8mnnSzmHLSrW2Zfa7q7K7SLVN5ykHit7Y5O4nsdHby3hMT4rE3N8FjL0+5957ZjZd2avXc37J3ZtHR ulkMo2AUjAKqAQDQNUql; DEFINE COMMENT 3 eJwzZWBg2GQeE1JtYpTCZORd1mw4vY7JyHrGH+O2BRssJq9cZSW6erpjyCpvN5b5zp5aPfVeglWMXlWZ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SE9InB3sreHe3yTY1TEXtv4sDo7oFEM/yvbXAK6teJa+kvT5reK1oLEttdkdj9vet45v1WxDcSfPa/O zn1ZnV3jCkGfxhVGKYeX780+uqytiH/x7MaZ81d0uS9b0ZW3fk1v2I4tkxlGwSgYBTQFAH7qRP8; DEFINE COMMENT 7 eJzTY2BgqPcS9NnoL+izPFg2VCHsc0p82NFCa5+EVg/3qun7vaxnbPE7OMcl4dIKoFKGvAxBH5l8QR/j utyE6R3uxWrN58qtq2WbJQty+0Dy1wtEVzdXiK42rPdZEtRlNpWvByL+fl2A96e1r+N+rZJs2L2Kd2nl 6skry9ZMX7NiY+Lm+1seb+nao7Sl6hDv0jXHN0zQOJna8ezk9LpnJ0+WaJysyyk9Mjv4z8FLPq37vD00 N3K47VgdE8IwCkbBKKAKAAAUc1Ic; DEFINE COMMENT 8 eJzTZWBgWB+gGFHqtyKm1ts6q97rXPl+r/f9VT72s5cHT18TFSG7sS5JdqN+RsDyxTk7p83NS+2Izncv ls+ry1HJMUv/kK6XaJ/0PPpGxPww3cD5YUDjGD7WPYp43vQoIrlFLXpWe2EyW79orVinWqdC65bJLxsP ztlaO30NSB3vkltBp5ckhLMv25t9Yqn1DP7FEWtj5q3ZfWO+3t5b23L3gNRkzSxMfjFzTXz83IRw0YXT A/wXX/NnGAWjYBRQDQAAtHZPQg; DEFINE COMMENT 9 eJwzZGBg2O4bE7LdN6G1yJ9l/sqgiLVLQmQ3hkcu2dqSsGTrjpT5m1ZkCa5QzHVfeDfPfvat/C2TZxRE 1EcW7M2+n7smPjMrIfxD+q0ghqRLPiFRXe4awSfddAO73C18Q/yARjMU17kXZze6F6s1sxRe6cyM5eib HQwSL6gPqNRsCqnZN5FlPohvXLd3pl6D/WyxzlvrQHz+xf1e7sv6vVyWC/o4rpAMsl+5JdV+5euexhXW M44u4116YZHadt4lK3bIbFPbzjAKRsEoIBsAAPGIUDs;
@Endede9 ай бұрын
I'm really glad that the solution worked this time! And to clarify, I don't have the game (yet, I fully intend to buy it soon, probably this weekend), and I haven't looked at any solutions. That didn't even occur to me, tbh. I just like puzzles. :D I haven't watched the whole video yet. "Three Sort" seems even harder than Fibonacci. Sorting is an option, but I wonder if three passes of "just" finding the minimum is the easier (i.e. shorter) answer here. I find it interesting how difficult it is to guess what the optimal approach is in this game until I actually try writing down a solution.
@Endede10 ай бұрын
Sorry about the incorrect suggestion! I've thought about it all morning, and I *think* I have a surprisingly concise solution, though I am a bit suspicious just how short it turned out. Spoilers ahead, if you want to think about it yourself some more, and also apologies, I know there is some format that would allow you to just copy and paste the solution into the game, but I'm not familiar enough with the format to provide it. I do believe it is legible, though. First, here is the non-working program at the end of your video: 01: BUMP+ 9 LABEL: Setup 02: OUTBOX 03: INBOX 04: COPY TO In 05: COPY FROM 9 06: COPY TO L 07: COPY TO R LABEL: Loop 08: OUTBOX 09: COPY FROM R 10: ADD L 11: SUB In 12: JUMP IF NEGATIVE 15 13: ADD In 14: JUMP Setup 15: ADD In 16: COPY TO R 17: SUB L 18: COPY TO L 19: JUMP Loop Now, for the (hopefully) working solution, there are two main ideas: Instead of R, we (check and) output L. That should save us the first OUTBOX command in 02: in the Setup section. The second idea is to calculate In - L instead of L - In to check if we are done. This makes the use of the JUMP IF NEGATIVE directive more natural, and doesn't require us to add another check for zero. I believe this should work (I've added a bunch of comments to explain motivation for changes): 01: BUMP+ 9 LABEL: Setup 02: COPY FROM 9 # Moved this up so that we can hold In after setup 03: COPY TO L 04: COPY TO R 05: INBOX 06: COPY TO In LABEL: Loop # Invariant: holding In 07: SUB L # Here we first test if we are already done. We calculate In - L instead of L - In now, so that the JUMP IF NEGATIVE is less awkward 08: JUMP IF NEGATIVE Setup # Done, go back to Setup 09: COPY FROM L # Grab our output value... 10: OUTBOX # ... and output it 11: COPY FROM L 12: ADD R 13: COPY TO R 14: SUB L 15: COPY TO L 16: COPY FROM In # This is for the invariant in the above Loop entry 17: JUMP Loop Somehow it's only 17 lines, which surprises me, because typically games like this know the optimal goal for a challenge, but I've gone over it multiple times, and couldn't find any missed edge cases. *fingers crossed*
@saturdaymp10 ай бұрын
Thanks for possible solution @Endede. I am switching to recording some videos about upgrading a Rails application but will come back to Human Resource Machine in the future.
@Endede10 ай бұрын
@@saturdaymp Looking forward to it!
@saturdaymp9 ай бұрын
@Endede I tired your solution and it worked! kzbin.info/www/bejne/mnPWaox6otqWiqs
@Endede9 ай бұрын
@@saturdaymp Oh, that's awesome! Thanks for giving it another try!
@Endede10 ай бұрын
So, for the Fibonacci step optimization (spoiler ahead, if you still want to think about it yourself). I think you were really close several times, especially with your intuition that it should work with 2 registers. It should work like this: When you get to step 15, you're holding SUM - IN == L + R - IN in your hand. 15. ADD IN -> Now you're holding SUM == L + R 16. COPY TO R -> You're still holding SUM == L + R, and the R-register now holds SUM 17. SUB L -> Now you're holding SUM - L == R 18. COPY TO L -> Now the L-register holds the R from the previous step, and the R register holds the SUM from the previous step 19. JUMP IF ZERO
@saturdaymp10 ай бұрын
Thanks for providing a possible solution @Endede. I tried implementing the solution in episode #27 but couldn't get it to work, likely my fault as I was short on time. I'll keep trying solutions as time permits, possibly off camera, and let you know if I find one that works. I'm trying really hard to not look up the solution on the Internet. kzbin.info/www/bejne/ppWleaqViKmNj8U
@Endede10 ай бұрын
@@saturdaymp No no. Not at all your fault. I saw your follow up, and you're right, it doesn't work as is. I fixated on the two registers and forgot to double check the exit invariant, which should be to hold the SUM in your hand. It would be easy if we could COPY TO outbox, but I'm not sure that's possible. I'm invested now, so I'll think about it more. Maybe I have to get the game to be able to debug easier. Or write a simple interpreter?
@a11aaa11a11 ай бұрын
Wow thanks a bunch!! Good point with the root mounting, I just wanted to be sure the directory existed but /tmp might even have been better. Also, fyi i just wrote the compose yml for the comment, I actually found this from a "real" (non-scratch) image (hasura specifically). You also don't need to run the container in addition to watching, you can just run watch (maybe build first? I'm not sure what the difference is here). I'm liking compose watch for rebuilding when specific files change, but i still mount volumes for bidirectional sync for my src and generated files Fun watching you go through a similar process to me! I hadn't seen that bug on GitHub.
@a11aaa11a11 ай бұрын
Btw I don't think you can actually use the `image` section instead of a dockerfile, it needs a build context and if you provide one without a dockerfile (i.e. just `image`), it will fail.
@saturdaymp11 ай бұрын
@a11aaa11a that is a good question and the answer is: yes you can use an image in a docker-compose.yml file. You can test it yourself by creating a file that uses Docker's Hello-World image: services: hello: image: hello-world Then run `docker-compose run --rm hello`. It will download and run the Hello-World image. No Dockerfile needed. You can find another example in my Rails 6 template example at. This Docker Compose setup uses a Dockerfile for the website but a image for the database: github.com/saturdaymp-examples/rails-6.0-template/blob/master/docker-compose.yml Let me know if the above helps. All the best.
@a11aaa11a11 ай бұрын
@@saturdaymp ah sorry, I mean you can't use just an image _with compose watch_. This fails for me (as does adding a context without a dockerfile): services: hi: image: hello-world develop: watch: - action: rebuild path: "./" target: "/"
@saturdaymp11 ай бұрын
@@a11aaa11a you are correct, you can't use Docker Compose Watch without a Dockerfile. At least I couldn't get it to work in this video kzbin.info/www/bejne/ZmaupaStpMeLa7s. Thank you for clarifying your question and pointing out something I missed.
@parity9911 ай бұрын
Awesome video, saved me from having to test this stuff out myself. I think that the look-only-for-changes-since-watch-has-been-running behavior of watch can be leveraged in various ways, but agreed, it can be much harder to achieve certainty about which files are where on host vs container. On the dev side, I haven't tried this but it could be a good workaround for permissions issues where containers are running as root and need to place artifact files in various spots, where normally you would have had a bind-mount setup. I wonder why docker hasn't come out with an option to transmit the host user info and id into the container at runtime so that it can choose to switch to that user before running such applications. That would be the most ideal way to fix permissions. I have a hacky script to find out the user owner of mounts in the container, create a matching user id and switch to that user before running said app.
@saturdaymp11 ай бұрын
@parity99 I'm glad you found the video helpful. I have also run into the problem of having a Docker container run as a non-root user and not able access the volume on my local host. Specially running NGINX/Passenger. I briefly highlight how I got around that problem in the below video. Spoiler, I force NGINX to run as root in development. kzbin.info/www/bejne/fmrPi2VqbNR8ncU Let me know if the above was helpful and if not I can go into more detail about how I setup my website development environment. Many years ago I did try writing a script that would map the host and container users but wasn't able to get it to work reliably. How does your script work? Do you mind sharing it, or at least parts of it?
@parity9911 ай бұрын
@saturdaymp I took a look at your video. The script I provided in my previous comment (I think? can't see it now) has a variable UNAME which may help; you could set it to nginx so that the nginx process assumes the user of the detected host bind mount volume. Also, have a look at envsubst which is included in the nginx image. Also, it may be easier to keep nginx in a separate container/service from the rails app; they can still communicate via reverse proxy tcp or via a shared unix socket on a volume, although I'm not a rails person so not sure if that's the recommended setup or not!
@saturdaymp11 ай бұрын
Thanks for trying to upload the script. My guess is KZbin didn't like your script and flagged it as spam or something worse. Also thanks for the envsubst command tip. Great minds think alike as I discovered that command a couple days ago used it for my NGINX config in currently unreleased videos. I didn't bother splitting up the Rails server and NGINX onto separate Docker containers as the SaturdayMP website is simple, small, and mostly static. No need to manage, and pay, for two Docker containers. That said, if you have a more complicated setup then setting up NGINX on a separate Docker container from your Rails, or other framework, server is a good idea.
@victorajayi9056 Жыл бұрын
Docker watch is quite interesting although it's only one way. Is volumes a two-way sync?
@saturdaymp Жыл бұрын
@victorajayi9056 that is a good question. I said two-way sync in the video but Volumes are only "kind-of" a two way sync. Assume we have a Docker Compose below: ``` volumes: - .:/app ``` The above will overlay the host file at '.', which is the current directory the docker-compose.yml file is in, inside the container at `/app`. This will work if the `/app` does not exist in the container, the folder will be created and visible while the volume is mounted. Changes made in the `/app` folder inside the container will be reflected on the host and vice versa. When the volume is unmounted the container will unhide the `/app` folder on the container. The `/app` folder did not exist before the volume was mounted it will cease to exist when the volume is unmounted. If the `/app` folder did exist before the mount then the files in it will be reverted back to. For example, if `/app` in the container contains `file1.txt` that file will be hidden while the volume is mounted and will re-appear when the volume is unmounted. I attempt the explain the above in the below video: kzbin.info/www/bejne/pIvOiYSge7p8ndU Let me know if the above helped and ping me if you have any more questions.
@estrelladeaurora6065 Жыл бұрын
You can be my mentor
@saturdaymp Жыл бұрын
Thank you for the kind words @estrelladeaurora6065 and I'm glad the video helped you. Feel free to ping me with any questions you have an I can try to answer them in a future episode.
@Raubritterr222 Жыл бұрын
Just found the video and didn't watch yet, but -- are you trying to setup RubyMine debugger with Rails app running in Docker-compose? I am about to embark on that journey as well.
@saturdaymp Жыл бұрын
Yes, I was attempting to get the RubyMine debugger working with Rails running in Docker. I had done it many times before but ran into issues in this video as there was a bug in RubyMine: youtrack.jetbrains.com/issue/RUBY-31246 The issue has now been fixed in RubyMine but my solution in the video was to download the preview version of RubyMine. Give me a shout if you have a specific question about getting RubyMine debugger to work with Docker.
@tanaykale15713 жыл бұрын
can you make a video on Single session login if the user already logged in and using another tab to login with the same link it should log out from previous tab
@saturdaymp3 жыл бұрын
Thanks for the question but I don't fully understand what you are asking. Can you provide a detailed example of the problem you are trying to solve?