64 points

You call that russian roulette? This is real russian roulette. Dying is a 1/6 probability.

#!/usr/bin/env python3
import random

barrel = [0, 0, 0, 0, 0, 1]
random.shuffle(barrel)

print("Russian Roulette")
for i in barrel:
  input("Press enter to shoot")
  if i == 1:
    print("You are dead.")
    exit()
  else:
    print("Phew. You survived.")
permalink
report
reply
20 points

I love this, except for i i hate i.

permalink
report
parent
reply
16 points

And maybe the fact that you have to continue until the gun actually fires :|

permalink
report
parent
reply
10 points

You can quit control-c at any point. Sometimes, the game plays you.

permalink
report
parent
reply
11 points

but it’s easier than thinking of a useful variable name.

permalink
report
parent
reply
5 points

bullet_idx

permalink
report
parent
reply
3 points

Like bullet?

permalink
report
parent
reply
3 points

I always use i because I’m too lazy to type out iterator when I’m making my garbage spaghetti code that will support infrastructure for years

permalink
report
parent
reply
1 point

I like it, i for int easy to remember. I also use i, j, k as u it vectors and remember at what depth of a multidimentional array in working at.

permalink
report
parent
reply
1 point
*
Removed by mod
permalink
report
parent
reply
1 point

You forgot the switch.

permalink
report
parent
reply
31 points

That can’t remove a directory.

permalink
report
reply
30 points

Perfectly safe on Windows, too. The remove() function doesn’t work on directories.

permalink
report
reply
10 points

Remove-Item -LiteralPath "C:" -Force -Recurse

permalink
report
parent
reply
8 points

I’m curious. Does anyone like PowerShell, and the syntax you end up with?

permalink
report
parent
reply
6 points

Yeah I’m a big fan of it. People complain about the verbosity of it but I like that for readability and autocomplete makes that a non issue I find. Plus if you really want to save on typing when using it as a terminal tool you can just make aliases for all your common commands.

permalink
report
parent
reply
2 points

I work pretty frequently with PS and have no issues with syntax. It’s easy to read and you always have autocomplete so there is just 1 extra click to get from -r to -Recurse. Same command could be also written as this due to alias feature.

rm 'C:' -r -fo

It’s just not the best practice since in PowerShell it is recommended to not use aliases for readability reasons. Also less chance to mess things up due to how verbose all commands and their parameters are.

permalink
report
parent
reply
1 point

Powershell isn’t perfect, but I like it a lot more than anything that takes sh as a major influence or thing to maintain backwards compatibility with. I don’t think the Unix philosophy of having lots of small tools that do one thing and do it well that you compose together has ever been achieved as I think being consistent with other tools you use at the same time should be part of doing your thing well, and things like sed, grep and perl all having different regular expression syntax demonstrate inconsistency and are easy to find. I also like that powershell is so verbose as it makes it much easier to read someone else’s script without knowing much powershell, and doesn’t end up getting in the way of actually writing powershell as the autocomplete is really good. I like having a type system and structured data, too.

Some of these things are brought to a unixier shell with nushell, but I’m not convinced it’ll take off. Even if people use it, it’ll be a long while before you Google a problem and the solution also includes a nushell snippet, whereas for any Windows problem, you’ll typically get a GUI solution and a powershell solution, and only a maniac would give a CMD solution.

permalink
report
parent
reply
5 points

And Windows nowadays have like dozen of different security measures that stop you from removing critical system components. It is not like in Windows 95 days, that OS allowed you to remove kernel by just typing a single command.

permalink
report
parent
reply
2 points

And much like Windows, everything dangerous is done better elsewhere.

permalink
report
parent
reply
25 points

Wow, a Lain meme was not something I was expecting.

I should watch that show again sometime, I still have the DVDs somewhere I think.

permalink
report
reply
9 points

“And you don’t seem to understand…”

permalink
report
parent
reply
5 points

A shame you seemed an honest man…

permalink
report
parent
reply
20 points

Fuck off, I know what I’m doing.

Omg someone please help how did I get this far they’re going to realize I’m stupid when they fire me everything will collapse because it’s all in a single excel file I need to figure out how to live in a tent in the woods and hunt and forage

permalink
report
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.1K

    Monthly active users

  • 954

    Posts

  • 36K

    Comments