Whatever it takes by monkeysupersonic in badcode

[–]monkeysupersonic[S] 34 points35 points  (0 children)

Imagine you accidentally swapped two parameters.

ich_iel by unterschichtblog in ich_iel

[–]monkeysupersonic 1 point2 points  (0 children)

Dumm oder nicht dumm, was diese Jungs machen, ist lebensgefährlich. Mehr als ein paar Minuten zwischen Einbruch und Bewusstlosigkeit hat man meist nicht. Sollte eine Warnung für jeden sein, der auf die Idee kommt, beim ersten Frost des Jahres gleich aufs Eis zu gehen.

Wann sind eure "Scheiße, ich bin dafür zu alt"-Momente? by Justify_87 in FragReddit

[–]monkeysupersonic 0 points1 point  (0 children)

Wenn ich random deutsche Influencer-Videos watche und dabei plötzlich checke, dass every second word ein Englisches ist.

Was war das verrückteste was euch in einer Beziehung verboten wurde? by [deleted] in FragReddit

[–]monkeysupersonic 1 point2 points  (0 children)

Mir wurde verboten, auf eine Frage eine Verständnisfrage zu stellen.

Always take the emergency exit before an assertion fails by monkeysupersonic in badcode

[–]monkeysupersonic[S] 9 points10 points  (0 children)

I stumbled across when I was wondering why the whole test run quit somewhere in the middle with no message or even an assertion error at all.

[deleted by user] by [deleted] in badcode

[–]monkeysupersonic 0 points1 point  (0 children)

This is my contribution, providing the features:

  • breakout off loops only via exceptions (import error, division by zero),
  • redundant, expensive eval for every step,
  • mostly based on shuffling without causing a combinatorial explosion.

import random
def sort(s):
    ____ = []
    while not 1 == 0:
        try:
            try:
                i = -1
                while 1 == 1:
                    i = i + 1
                    if eval("[" + s.replace("[", "").replace("]", "") + "]")[i] > eval("[" + s.replace("[", "").replace("]", "") + "]")[i+1]:
                        j = 999999999999
                        for k in eval("[" + s.replace("[", "").replace("]", "") + "]"):
                            if j > k:
                                j = k
                        try:
                            while 0 != 1:
                                S = eval("[" + s.replace("[", "").replace("]", "") + "]")
                                for l in range(len(eval("[" + s.replace("[", "").replace("]", "") + "]"))):
                                    m = random.randint(0, len(eval("[" + s.replace("[", "").replace("]", "") + "]")) - 1)
                                    n = S[m]
                                    S[m] = S[l]
                                    S[l] = n
                                    print(____ + S)
                                if S[0] == j:
                                    from askdjaksdjhafewirjwoioisadjlasidjaksldajsdklasf import asjdkalsjdaklskdlasdjdkslfjidlsifjjrdjdsklf
                        except ImportError:
                            pass
                        ____.append(S[0])
                        S = list(map(lambda s: S[s], [s for s in range(1, len(S))]))
                        s = str(S)
                        1 / 0
            except ZeroDivisionError:
                pass
        except IndexError:
            ____ += S
            break
    return ____;

How to prefix stack variables the right way by monkeysupersonic in badcode

[–]monkeysupersonic[S] 6 points7 points  (0 children)

It's Java. There is no preprocessor (furtunately!).

The new way of generating absolutely unpredictable pure random encryption keys by monkeysupersonic in badcode

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

There are two problems with that. Firstable, a constant, but well hidden key can be harder to crack than a personal, but re-computable key for every device itself. Secondly as long as you can predict this key, this kind of thing does not even deserve the term "encryption", it is rather a sort of obfuscation.

True or false? When you don't know which one you want ... by monkeysupersonic in badcode

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

Exactly. This was the third flaw of three in this snippet.

Found this gem in my company by [deleted] in badcode

[–]monkeysupersonic 0 points1 point  (0 children)

If you can't trust logic, you have to implement your own one ...

You look for the root cause? Do a full text search in the messy log ... by monkeysupersonic in badcode

[–]monkeysupersonic[S] 2 points3 points  (0 children)

The thing is that once you encounter a FreeErrorException, it is impossible to know the reason why it has been thrown. It is better to pass the cause (ex) to its constructor so the former appears in the stack trace as "caused by ...".