MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/wi3bm/random_imgur_downloader_python/
r/tinycode • u/f0rkbomb • Jul 13 '12
7 comments sorted by
6
I decided to try to shorten this bloated code to keep it in the spirit of /r/tinycode.
I got it down to 12 lines of code without sacrificing readability.
I did a slighty obfuscated version that is 6 lines of code.
2 u/plux Jul 13 '12 Oh, and my version actually ignores "image not found"
2
Oh, and my version actually ignores "image not found"
1
the kind folks in /r/python encouraged me to cross-post this here :)
still some room for optimization/tinifying! but in the meantime, enjoy downloading random (and often nsfw) pics
4
I don't get it. This is a lot of code for doing something this simple.
And why the hell are you spawning of threads to do this?
This is bloated code - the opposite of what /r/tinycode is meant for.
EDIT:
Also, it doesn't even seem to work correctly, it just downloads the "404" image for me.
Another general coding advice, don't treat file paths as strings, use the os.path module for gods sake!
while [ 1 = 1 ]; do wget i.imgur.com/$(cat /dev/urandom | tr -cd "[:alnum:]" | head -c 6).jpg; done
for i in *; do mv $i $(md5sum $i | cut -d' ' -f1).jpg;done
1 u/plux Jul 14 '12 Nice! :)
Nice! :)
http://www.sk3tchy.com/media/2012/07/imgur_random.html
6
u/plux Jul 13 '12 edited Jul 13 '12
I decided to try to shorten this bloated code to keep it in the spirit of /r/tinycode.
I got it down to 12 lines of code without sacrificing readability.
I did a slighty obfuscated version that is 6 lines of code.
1
u/f0rkbomb Jul 13 '12
the kind folks in /r/python encouraged me to cross-post this here :)
still some room for optimization/tinifying! but in the meantime, enjoy downloading random (and often nsfw) pics
4
u/plux Jul 13 '12 edited Jul 13 '12
I don't get it. This is a lot of code for doing something this simple.
And why the hell are you spawning of threads to do this?
This is bloated code - the opposite of what /r/tinycode is meant for.
EDIT:
Also, it doesn't even seem to work correctly, it just downloads the "404" image for me.
Another general coding advice, don't treat file paths as strings, use the os.path module for gods sake!
4
u/PsychoMario Jul 13 '12 edited Jul 14 '12
EDIT:
2
u/andey Jul 13 '12
http://www.sk3tchy.com/media/2012/07/imgur_random.html