9 ms·
StackOverflow Importer – Import code from Stack Overflow as Python modules
- prodigal_erik 10y agoIt's hard to imagine a better argument for vendoring your dependencies in case they change.
- 89vision 10y agobecause executing arbitrary unknown code is always a good idea
- chc 10y agoI think that's the point of this parody.
- marcoperaza 10y agoSure, but even playing with this joke on a machine that has your personal or work data is a very stupid thing to do.
- railorsi 10y agoDo not do that then.
- pavel_lishin 10y agoIt's all arbitrary and unknown unless you verify the whole thing yourself down to the kernel. And then you better hope that the processor dies are as advertised.
- cmdrfred 10y agoAlso, this is a joke.
- mooreds 10y agoAm I dumb? How is this a joke?
- HammadB 10y agoI think the commenter was being facetious haha
- hiou 10y ago> Do you ever feel like all you're doing is copy/pasting from Stack Overflow? I don't really feel like anyone is taking this very seriously.
- chc 10y agoIt seems pretty apparent from the readme that it's a joke along the lines of "If you're going to just copy and paste the first thing you find on Stack Overflow, you may as well do this."
- emmelaich 10y agoOn the other hand, at least the code has gone through some review. Compare that to NPM or PyPI, which is full of crap. Some of the modules in PyPI were merely ads for putlocker, without even a single line of Python.
- voltagex_ 10y ago>Some of the modules in PyPI were merely ads for putlocker Seriously? Are they still there?
- clifanatic 10y agoJob security for us, I guess...
- lifeisstillgood 10y agoCan I be all code review mode, and ask you to lower case the first f. It's sticking out like a sore thumb
- hughes 10y agoIf I have editing powers could I hijack the answer that gets its code imported?
- avg_dev 10y agoEdits get reviewed before being published.
- Alupis 10y agoThat doesn't guarantee the folks doing the reviewing know what they are reviewing.
- stuartd 10y agoNo they don't. From http://stackoverflow.com/help/privileges/edit http://stackoverflow.com/help/privileges/edit > We believe in the power of community editing. That means once you've generated enough reputation, we trust you to edit anything in the system without it going through peer review. Not just your posts—anyone's posts!
- 0xmohit 10y agoIf you've been on Stack Overflow enough, you might have noticed that crap is sometimes approved even after peer-review. Many doing the review do it like robots (to earn internet reputation and badges).
- mooreds 10y agoWhat a fascinating concept! I think that with some kind of review built in, this kind of dynamic loading would be really useful. I think if you do this, you'd want external tests, or some way to pull the code in and "freeze" it so that you wouldn't be at risk of external compromises. (For example, a high ranked SO user might be able to change a highly ranked answer . They might not do it, but someone suborning their account might.) But really, this is an optimization of a lot of code that is currently written.
- RA_Fisher 10y agoAgreed. It'd be cool if snippets had a checksum api.
- bthornbury 10y agoI was thinking the same thing about the freeze. Something like the equivalent of `pip freeze`
- Ph0X 10y agoI don't see this being useful for real programs, but it could be amazing for interactive use in a shell. I use iPython for all sorts of quick data manipulation daily, and being able to just quickly type an idea and get it would be amazing.
- mooreds 10y agoYou're right, maybe it is better for prototyping, but as I've experienced, for better or worse what you prototype sometimes becomes production.
- pizza 10y agocode is data; lispy!
- yefim 10y agoReminds me of stacksort[1] [1] https://gkoberger.github.io/stacksort/ https://gkoberger.github.io/stacksort/
- dabber 10y agoVery funny. I hadn't seen this before. I particularly like: >>Is it safe? >>Uh… it evals both user input and random code, unchecked, from an external site. This is what security-minded folks would refer to as Very Bad™.
- nom 10y agoIt's not hard to imagine that stacksort works, but seeing it in action is really something different. It's scary and awesome at the same time.
- marcoperaza 10y agoThis is a really stupid idea, even as a joke to play with. Someone can just edit the top answer to make it malicious and steal your personal or work data from your workstation.
- 45h34jh53k4j 10y agoand then own your network, your DVR, your toaster, your cat.
- StreamBright 10y agoPlease leave the cat!
- libeclipse 10y agoSomeone stupid enough to actually use this in a serious environment arguably deserves it.
- bthornbury 10y agoThis is a pretty cool idea! Concerns for running unknown code aside, it seems like the results of this type of thing would be prone to potentially frequent change. I wonder if there'd be a way to maintain consistency, something like a requirements.txt file that got spit out to describe what the results of the search terms mapped to when the code was run. It could just contain the search term and link to the chosen question. Although you'd still run the risk of the answer itself being edited. The code itself would have to be cached in whatever this file was.
- hiou 10y agoSomewhat related https://github.com/gleitz/howdoi https://github.com/gleitz/howdoi with the vim frontend https://github.com/laurentgoudet/vim-howdoi https://github.com/laurentgoudet/vim-howdoi
- selljamhere 10y agoRelevant xkcd: https://xkcd.com/1185/ https://xkcd.com/1185/ "StackSort connects to StackOverflow, searches for 'sort a list', and downloads and runs code snippets until the list is sorted."
- 0xmohit 10y ago"StackSort connects to StackOverflow, searches for 'sort a list', and downloads and runs code snippets until the list is sorted." If still unable to sort a list, it'll emit an arbitrary sorted list as the result.
- roryokane 10y agoAnd https://gkoberger.github.io/stacksort/ https://gkoberger.github.io/stacksort/ is an actual implementation of that sort.
- fkejaoignerio 10y agoFilip, good job! Bra jobbat!
- nhatbui 10y agoThis is awesome. But how is `time_delay` used?
- drathier 10y agoThe code snippet it finds imports sleep and calls it directly. Fire it up in a repl and check __author__ or _code yourself :)
- gigatexal 10y agoThis is so funny. Kudos to the author!
- jbpetersen 10y agoAnyone else tinkering with / armchair philosophizing about ways of making stuff like this practical for regular use?
- orasis 10y agoAwesome. Now we just need to integrate upwork with our IDE so I can just write the method signature and a bid price and my method will be magically implemented.
- 45h34jh53k4j 10y agoCool joke. Post leftpad it needs a disclaimer lest someone actually do this for real.
- ramblenode 10y agoI'm kind of shocked how many people here are talking as though they would actually include this in a codebase.
- noescape 10y agoWhat if, somehow, there was a guarantee that the code can't harm your machine -- would you use it then? This isn't a joke.
- Alupis 10y agoIt's not just about harming your machine - it can harm your* data, or data passing through your* system! * Where "your" can mean you, your employer, your customer, another company, etc.
- noescape 10y agoWhat if it can't harm your data, or data passing through your system? What if it can't harm anything.
- emodendroket 10y agoHow could a system that executed arbitrary code ever make such guarantees? I mean sure, if there were a magical thing that only ever produced correct code for what you wanted to do I guess people would use it.
- deleted 10y ago[deleted]
- xg15 10y agoWay ahead of you: https://twitter.com/ckolderup/status/789002880246177792 https://twitter.com/ckolderup/status/789002880246177792
- sparky_ 10y agoBased on some of the comments here, a sarcasm disclaimer might be necessary on the repo!
- pmarreck 10y ago(OT) HEY! I finally noticed your Desert Combat comment and responded to it. If only HN had a better commenting/messaging system...
- guelo 10y agoThis might be a joke but everybody does it manually for real. Whenever I copy-paste some tricky function from SO I like to add a code comment with the url pointing to the stackoverflow.com answer. This allows future maintainers to refer back to SO and see if a better answer has surfaced or read comments about any issues.
- jaredsohn 10y agoI do it for that reason but also for license attribution and indicate that I didn't write it.
- vmarsy 10y agoAlmost 3 years ago Visual Studio demo-ed a feature that would copy-paste code from StackOverflow, while automatically renaming the variables to fit your code : https://blogs.msdn.microsoft.com/visualstudio/2014/02/17/introducing-bing-code-search-for-c/ https://blogs.msdn.microsoft.com/visualstudio/2014/02/17/int... The tool is available here: https://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9-4a48-a5fd-504ff4ad1b65 https://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9...
- Biganon 10y agoI never, ever copy paste code, unless it's really long. I always end up rewriting everything myself, so I have the time to think about what's happening.
- andybak 10y agoHmmmm. I'm the other way round. I copy and paste short snippets because I'm lazy and I can see if they are ok at a glance. Longer code I'll go through line by line and try and 'touch' each line to force me to think about it.
- clifanatic 10y ago> everybody does it manually for real I've been programming professionally for much longer than there's been a stack overflow. I have never, ever, cut and pasted code from stack overflow.
- denfromufa 10y agoStackoverflow-driven development (SDD): https://goo.gl/images/xXCZrx https://goo.gl/images/xXCZrx
- drathier 10y agoDid I just render that book obsolete?
- denfromufa 10y agoNot sure what you mean..
- pryelluw 10y agoIts amazing how little code it takes to implement this (aside from dependencies).
- StreamBright 10y agoImporting and running code from an external site without verification or code review. What could possibly go wrong?
- rplst8 10y agoIt brings new meaning to the term "full-stackoverflow developer."
- 0xmohit 10y agoErr.. did you mean "full-stack(overflow) developer"?
- shade23 10y agoAnd the relevant book for people who prefer reading material. https://tra38.gitbooks.io/essential-copying-and-pasting-from-stack-overflow/content/ https://tra38.gitbooks.io/essential-copying-and-pasting-from...
- Uptrenda 10y agoIt's interesting to imagine adding something like this to an editors auto complete or as some kind of search function to automate functions you've coded a million times. I.e. maybe you type: "repeat a function over a list python" in a special format and your editor pastes in the accepted answer from stackoverflow for you to choose whether that's acceptable / whether you want to use it as a template. Then maybe you could get into a better flow without ever having to stop what you're doing to Google something ... It would all just show up magically in your editor. You could even have libraries of common answers written in such a way that you could write expected input and output formats and then get a code fragment that would fit that description. Something like a more organized test driven development. Though that would really only work for very specific things. Improve these ideas enough and make them more general - and maybe you could improve programmer productivity by quite a large margin. Disclaimer: I know the OP was a joke but I see no problem with reusing code if you understand what its doing and the costs / trade-offs for doing so.
- lotkowskim 10y agoThere is something like that for JavaScript https://emilschutte.com/stackoverflow-autocomplete/ https://emilschutte.com/stackoverflow-autocomplete/
- hashhar 10y agoVisual Studio has an extension by Microsoft called Bing Code Search which does exatcly what you want. It's really good.
- 0xmohit 10y agoI like the description: "Import arbitrary code from Stack Overflow as Python modules." (Emphasis mine.) -- Now Stack Overflow should be even more concerned about the availability of their service.
- Alex3917 10y agoI look forward to using this in a future job interview and seeing what happens.
- jstoiko 10y agoMakes me think of Kite[1]. Kite is a "real" thing that one can use though. [1] https://kite.com https://kite.com
- libeclipse 10y agoI did something similar with a project that allowed you to import code from anywhere[0]. StackOverflow would be a nice addition. [0] https://github.com/libeclipse/import-from https://github.com/libeclipse/import-from
- ronreiter 10y agoThis is a license hell, whatever you do, don't use it if you care about your code not being owned by other people.
- mobiuscog 10y agoAnd then: http://code.visualstudio.com/blogs/2016/11/3/rollback http://code.visualstudio.com/blogs/2016/11/3/rollback
- qud 10y agoWhat a time to be alive. Edit: this is officially the best thing to happen to me this week, heck, month.
- dustinmoris 10y agoI often find that the accepted answer with the most votes is the oldest and often outdated and that there's a newer answer with also a lot of votes which is more up to date and better many times.