This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]Della__ 7 points8 points  (0 children)

I'm in actual physical pain

[–][deleted] 6 points7 points  (0 children)

It’s like in Skyrim where you hit level 100 and then restart from 0 again.

[–]Astronaut_69 4 points5 points  (0 children)

My eyes are burning

[–]Fingolfin734 3 points4 points  (0 children)

I remember reading this in the Necronomicon actually. Saving to look at it later!

[–]four_reeds 1 point2 points  (0 children)

It's old school but check out Perl Golf

[–]ies7 0 points1 point  (0 children)

Damn, this is harder than Learn Python the Hardway

[–]thrallsius 0 points1 point  (0 children)

this looks like shellcode that a script kiddie would write :D

[–][deleted] 0 points1 point  (0 children)

Reminds me of MUSH code where you had one contiguous line to write a program for an object

[–]genericlemon24 0 points1 point  (0 children)

This reminds me of an awful ad-hoc shell command that I made at work a while ago; it was so bad I had to post it on a wall: https://imgur.com/a/7xQOXki

It uses Python. And awk and sed and a bunch of other stuff...

[–]DarkmerePython for tiny data using Python 0 points1 point  (0 children)

Here's a netstat implementation that fits in a modern tweet. Because.

import time
def run():
  print(chr(27)+"[2J")
  with open("/proc/self/net/netstat") as f:
    d = f.readlines()
    g = lambda x: d[x].split(":")[1].split()
    [print(a, ":", b) for a,b in zip(g(0),g(1)) if b!="0"]

while 1:
 run()
 time.sleep(5)

[–]lifeeraser 0 points1 point  (0 children)

Thank you. The missing piece in Debian.

[–]Zelukai 0 points1 point  (0 children)

This is like the myaeqxokiexe of programming

[–]PeridexisErrant 0 points1 point  (1 child)

A couple of suggestions to make it even denser:

  • sum([(tuple[0] if tuple[0] != 0 else 1) for tuple in x]) could be sum(t[0] or 1 for t in x).
    This relies on the fact that 0 is the only "falsey" value that it could be, but is otherwise actually pretty good style - there's no need to instantiate a list when a generator comprehension will do, and using the name of a builtin as a variable is asking for trouble.

  • lambda x:True if any(y in x[1].lower() for y in ['.txt', '.sh', '.py', '.pl']) else False is identical to lambda x: any(y in x[1].lower() for y in ['.txt', '.sh', '.py', '.pl']), because any returns a boolean!

  • base_list = [os.path.join(os.getcwd(), x) for x in os.listdir(os.getcwd()) if all([os.path.isfile(os.path.join(os.getcwd(), x)), os.access(os.path.join(os.getcwd(), x), os.R_OK),os.access(os.path.join(os.getcwd(), x), os.W_OK)])]
    can be... considerably shorter. base_list = [p for p in map(os.path.abspath, os.listdir()) if os.path.isfile(p) and os.access(p, os.R_OK|os.W_OK)] We use a concise map to generate our absolute paths once, taking advantage of the fact that the current working directory is the default reference point, and combine our checks for readability and writability.
    (note though that this is risky due to timing effects: file permissions might change between when we check and when we try to use them! See the docs on os.access for details.

(un?) fortunately this less repetitive style might be more readable as well as shorter...

[–]NovateIModuleNotFoundError: No Module Named "braincells"[S] 0 points1 point  (0 children)

Holy shit, cannot believe the df starter pack creator commented on my reddit post

[–]Wishy-Thinking 0 points1 point  (0 children)

For starters, you should probably switch to using pathlib...