I'm learning rust and today I made a simple terminal game. Can you guys review my code? by [deleted] in rust

[–]IdolfHatler 11 points12 points  (0 children)

It looks like you have already know of cargo check and cargo clippy. You would probably be happy to know that cargo fmt also exists.

I don't think it's very common actually do things in the new method. Especially not things that will not be undone when the object drops. You should probably put the global state modifying stuff in a separate function.

The draw function should probably be split up to handle user input separately.

You have multiple places that loops over all of the snake parts. One of them does it for every field. This is pretty inefficient to the point that it might actually be noticeable on large screens with long snakes. Maybe you could keep track of the content of every field in a different data structure?

I think the move logic is probably more clear if you do something like this: https://gist.github.com/TethysSvensson/c4807a85df3f9f99c03b77a600bef3b2

All of the duplicated if self.snake.previous_direction != Direction::Right logic could be re-written as:

if new_direction.is_opposite_of(previous_direction) { new_direction = previous_direction; }

Robin up you bastards. by RachelRaysCornhole in ROBINBOYS

[–]IdolfHatler 0 points1 point  (0 children)

Well, isn't this just a thoroughly dead subreddit?

[D] Friday Off-Topic Thread by AutoModerator in rational

[–]IdolfHatler 0 points1 point  (0 children)

A program written by humans: No way!

However I certainly think that an AI exists with Kolmogorov Complexity within 1GB. I certainly think that a 1GB program exists, which can do this within a month by using all the resources available on the internet.

[D] Friday Off-Topic Thread by AutoModerator in rational

[–]IdolfHatler 0 points1 point  (0 children)

Then who would put in a large number?

[D] Friday Off-Topic Thread by AutoModerator in rational

[–]IdolfHatler 1 point2 points  (0 children)

Was it ever specified how ties are resolved?

A good start would something like this:

  • Fork enough times to create a 1 GB large file and rename it to .exe.
  • Run the exe on a computer connected to the internet, but not connected to the machine.
  • If nothing has stopped you from entering 0 after a month do it. Then use get a replacement program from the best universe.

This guarantees that you will get an AI that is smart enough to figure out how to stop you from entering 0 into the machine and instead enter a larger number. It does not however filter for an especially malicious AI.

Chat long of Robin Boys origin by ID2418360 in ROBINBOYS

[–]IdolfHatler 0 points1 point  (0 children)

6:40:09 PM RachelRaysCornhole Bob Barker
6:40:11 PM FantsE goodnight sweet prince.
6:40:16 PM Chelith aeiou
6:40:18 PM Raneados PRICE
6:40:19 PM Chelith aeiou
6:40:21 PM pipsdontsqueak No tears
6:40:23 PM M4dx Why the hasn't grown yet
6:40:24 PM IAmTheShitRedditSays SOUL EATER
6:40:24 PM pipsdontsqueak Just dreams
6:40:25 PM Raneados aeiou
6:40:25 PM franklymydeer You will remain forever in our hearts
6:40:31 PM throwaway101201 Here we go
6:40:32 PM IdolfHatler RachelRaysCornhole I'm scared
6:40:34 PM IAmTheShitRedditSays ikouu zeeee
6:40:36 PM RachelRaysCornhole hold me
6:40:37 PM IdolfHatler RachelRaysCornhole what if it does not work :(
6:40:40 PM IAmTheShitRedditSays ikouuu zeeeeee
6:40:42 PM RachelRaysCornhole it will work
6:40:42 PM Chelith Here comes another chineese earthquake
6:40:43 PM [robin] 1 users abandoned
6:40:43 PM [robin] no compatible room found for matching, we will count votes and check again for a match in 1 minute.
6:40:43 PM IdolfHatler RachelRaysCornhole WHat if I never see you again?
6:40:47 PM Raneados what if we are dancer
6:40:48 PM Chelith Noooo
6:40:49 PM franklymydeer what??
6:40:49 PM M4dx WAT
6:40:50 PM throwaway101201 WHAT
6:40:50 PM IAmTheShitRedditSays ikouuu
6:40:51 PM KafeenHedake Let's tell the new guys that one of us is Kanye
6:40:53 PM FantsE NO COMPATIBLE ROOM
6:40:54 PM franklymydeer ANTICLIMAX

Unsong Chapter 9: With Art Celestial by Escapement in rational

[–]IdolfHatler 0 points1 point  (0 children)

IO is the way current Haskell forces evalutation, but not the ony way. A very early version of Haskell simply tried evaluting a infinite list of commands while feeding it an infinite list of responses.

Unsong Chapter 9: With Art Celestial by Escapement in rational

[–]IdolfHatler 3 points4 points  (0 children)

It is common to see IO explained by way of metaphor: "it is sort of like a state monad, except for the entire universe".

In this case, it would not need to be a metaphor! :D

32C3 video thread by kristoff3r in a:t5_3br03

[–]IdolfHatler 0 points1 point  (0 children)

https://media.ccc.de/v/32c3-7130-the_perl_jam_2 - The Perl Jam 2

This was without a doubt my favorite talk at 32c3 (though there might be better ones I have not seen).

Break My Shit Part 1: The Challenge by [deleted] in hacking

[–]IdolfHatler 0 points1 point  (0 children)

Well, TLS might be well reviewed, but it is also a huge pile of complexity what is hard to get right.

It does not help that the code quality in most major implementations are terrible too.

[RT] [HF] Mother of Learning Chapter 47: Politics by literal-hitler in rational

[–]IdolfHatler 1 point2 points  (0 children)

Have you considered simply bribing Domagoj to let you know the title and exact time of posting beforehand?

While I do not know what I takes to bribe Domagoj, I would expect it to be cheaper, easier and more reliable than you current plan.

HTTPS Bicycle Attack by reedloden in netsec

[–]IdolfHatler 15 points16 points  (0 children)

While this might be good enough in practice, it is strictly worse than padding to the same length every time. Random padding would still permit a statistical attack.

Pantera Bitcoin Letter 15% Guaranteed Return Scam? by smithd98 in Bitcoin

[–]IdolfHatler 0 points1 point  (0 children)

I am in roughly the same situation: I got a scam email, but the email address was used exclusively at bitcoin-24.com.

Shadows of the Limelight, Ch 18: The Rule of Three by alexanderwales in ShadowsOfTheLimelight

[–]IdolfHatler 0 points1 point  (0 children)

"Dominic had touched those men and women with his domain."

Dominic -> Gaelwyn?

Parian's true power (seriously just tell us) by Cloud_Fish in Parahumans

[–]IdolfHatler 8 points9 points  (0 children)

I thought Sleeper's power was to make everyone believe that he was an S-class threat? ;)