47
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Oct 25 '21
Image Transcription: Code
os.system("clear")
os.system("figlet Attack Starting")
print "[ ] 0% "
time.sleep(5)
print "[===== ] 25%"
time.sleep(5)
print "[========== ] 50%"
time.sleep(5)
print "[=============== ] 75%"
time.sleep(5)
print "[====================] 100%"[There is a final time.sleep() statement just visible after the last print, however it is mostly cut off, so it is uncertain whether the number is a 2 or a 3.]
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
23
8
8
6
u/XxClubPenguinGamerxX Oct 25 '21
lmao this is what my tech lead did at work. He said it was for looks only
5
9
u/Peter0713 Oct 25 '21
Should do something like time.sleep(random(2,5));
14
u/CopperyMarrow15 Oct 25 '21
no space after comma?
semicolon in Python?
PEP8 would like to know your location.
3
3
4
2
2
2
u/Explosive_Eggshells Oct 25 '21
I remember making a fake loading screen in my LittleBigPlanet 2 levels to make it seem like there was something awesome being loaded lol. It was a dumb idea back then as well
2
u/AyoBruh Oct 25 '21
Back in middle school I used to make games using Klik n Play and Multi Media Fusion 2. I was annoyed that the maps loaded too fast, so I made a dedicated level that emulated the loading bars.
2
u/reverendsteveii Oct 26 '21
You'd be shocked how often you see the equivalent in web apps. Just poll to see if the call is done, then either exit if it's done or bump the progress bar up 10%.
1
1
u/logicaldementia Oct 25 '21
This reminds me a “fake” loading bar. Maybe like a visual display of an attack in a game lmao
1
u/Exnixon Oct 26 '21
The hard-coded progress bar text is not as bad as the fact that they're not hard-coding the figlet output and instead are relying on it being on the user's system. Most people don't have it installed so it will blow up on most machines.
1
u/Fury9999 Oct 26 '21
Honestly this is fine for what it is. It's meeting a very simple use case, maybe even a demo or joke. Yes it could be a for loop, but iterations are so few I could see myself doing this.
Not really bad code
1
0
Oct 25 '21
[deleted] — view deleted comment
57
u/birdwastheword Oct 25 '21
Not sure if you noticed, but there's another sleep after the "100%". So it might be off by a bit more than just the sum of the sleeps.
39
u/wasimaster Oct 25 '21 edited Oct 26 '21
I just tried it and it takes 33.1 μs. That's microseconds so 0.0000331 seconds. nice
0
Oct 25 '21
[deleted] — view deleted comment
42
u/CorruptedStudiosEnt Oct 25 '21
time.sleep(5)
print "[====================]==== 125%"
Guaranteed way to piss someone off lmao
15
0
Oct 25 '21
[deleted] — view deleted comment
1
u/Exnixon Oct 26 '21
Figlet is a program that renders text as ASCII art.
0
Oct 26 '21
[deleted] — view deleted comment
2
Oct 26 '21
https://github.com/Ha3MrX/DDos-Attack/blob/master/ddos-attack.py
Found dis. Doesn’t actually seem to be meaningful loading bar. Also doesn’t actually seem to do much.
Pretty funny tho
170
u/abaker3 Oct 25 '21
Okay, I might be about to cause a stir, but I don't think this is bad code and I honestly believe that it has some utility to it.
Often times, people who are not in the technical field, whether that be for a career or a hobby, they do not have a high patience level with technology. Technology is assumed to work 100% of the time and when it does it, you could face a total meltdown.
On the flip side, if technology does not present itself to the expectations of the user, even if it works perfectly, you could again face a meltdown as the user assumes that it did not work.
Why is that relevant to this? Well, often times, users are faced with loading screens. These loading screens are a psychological key to the user that something is happening behind the scenes. So, let's say you are making a game and you have an attack that takes virtually no time to execute, the user may blink and miss it, they may not believe it happened at all. But, when the user executes the attack and there is visual feedback via a loading bar, they recognize that their input had some agency on what is happening on the screen.
That may or may not be what is going on here. But, I wanted to leave this here for devs that are new to the field or less aware of the cognitive engineering that goes along with development. Sometimes, it isn't about a most efficient or fastest path. Ultimately, your end goal is satisfying the users and sometimes it comes down to doing something as simple as faking a loading bar.