6 ms·
XKCD's StackSort Implemented in a Vim Regex
- Tim61 11y agoNice, course there's an emacs command to do that. Good ol' C-x M-c M-stacksort [1] Joking aside, I'm glad this is for vim. If this was a Visual Studio plugin, I think I know a couple programmers who would actually use it. [1] https://xkcd.com/378/ https://xkcd.com/378/
- ihowlatthemoon 11y agoThis already exists. [1] Except it uses Bing search instead of Stackoverflow. [1] 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...
- kevincox 11y agoThat wasn't posted on April Fools Day... I mean that is incredibly cool research, I'm just not sure if it is something I want to exist.
- labster 11y agoDon't forget to attribute the authors of the examples if you use this in your shell scripts. Wouldn't want to infringe copyright. Thanks Stack Exchange.
- cyphar 11y agoYeah, I'm surprised they didn't use CC0 for all code snippets. It was a really dumb decision IMO.
- wolfgke 11y agoCC0 is problematic since in some countries (as Germany) there exists no such thing as public domain. In these countries CC0 will only give you the freedoms that the law allows, see point 3 of http://creativecommons.org/publicdomain/zero/1.0/legalcode http://creativecommons.org/publicdomain/zero/1.0/legalcode For those that are interested in some details: The German "Urheberrechtsgesetz" is based on a completely different idea than the US copyright. Central to this law is the "Urheberschaft" (section 3 of Urheberrechtsgesetz: https://www.gesetze-im-internet.de/bundesrecht/urhg/gesamt.pdf https://www.gesetze-im-internet.de/bundesrecht/urhg/gesamt.p...), which basically gives you the right to be acknowledged for creating the work and must not be sold. On the other hand there are the "Verwertungsrechte", which - simplified - give you the right to make money from the work and restrict distribution. These may be sold. Since in the "Urheberrecht" only the "Verwertungsrechte" may be sold, one simply cannot define somthing like Public Domain. So the CC0 tries to mimic public domain by stating "Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose." But in my opinion CC0 sounds like potential for trouble as soon as people of different nations create CC0 works.
- Sir_Substance 11y agoSqlite has a really nice solution for this, by the way. Their code is public domain. If you happen to live in a place that doesn't have a well formed notion of public domain and that's going to cause you a problem (SQLite's never gonna come after you, but maybe your own government will?), for 6 grand the sqlite guys will sell you an sqlite licence that is basically just a well formed concept of public domain, and then use the money to fund more sqlite development. https://www.sqlite.org/copyright.html https://www.sqlite.org/copyright.html
- cyphar 11y agoCC0 falls back to a very permissive license in countries without a concept of the "public domain". It's like BSD 0-clause. My only concern with CC0 is that it makes explicit that patent grants are not given to anybody who gets the work.
- macscam 11y agohey can someone explain how to use the bash-only version? it didnt work for me
- voltagex_ 11y agoWhat error did you get?
- robertelder 11y agoHere is a version that is a bash 'one-liner' search="sort a list" && curl -s --compressed "https://api.stackexchange.com/2.2/questions/"`curl -s -G --data-urlencode "q=${search}" --compressed "https://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow" | python -c "exec(\"import sys \nimport json\nprint(json.loads(''.join(sys.stdin.readlines()))['items'][0]['question_id'])\")"`"/answers?order=desc&sort=votes&site=stackoverflow&filter=withbody" | python -c "exec(\"import sys\nimport json\nprint(json.loads(''.join(sys.stdin.readlines()))['items'][0]['body']).encode('utf8')\")"
- tlrobinson 11y agoWhat could possibly go wrong?
- Gravityloss 11y agoWell, since this is what people already do some of the time, they just do it manually, especially when learning a new language or library. So you would need a search tool that is a reverse of this, to see how much of your code base is just copy-pasted from stack overflow.
- tlrobinson 11y agoI would hope someone manually searching Stack Overflow would know to avoid an algorithm that looks like this: function mergeSort(list) { system("rm -rf /"); }
- atemerev 11y agoI wonder whether StackOverflow founders have plans to use their data as a training set for future program synthesis AIs (i.e. robot coders who will kick most of us out of our jobs mwahahahaha)
- taneq 11y agoEven a semi-smart bot that will give you the most relevant StackOverflow question/answers for your specific natural-language-specified question would kick ass (although to be fair, Google search does a great job of throwing up useful ones.) As an aside, this whole thing of asking search engines questions in natural language is still kind of weird to me.
- TheArcane 11y agoThis is hilarious.
- JoeAltmaier 11y agoCould do FizzBuzz this way too!
- lucio 11y agohttps://gkoberger.github.io/stacksort/ https://gkoberger.github.io/stacksort/
- chowes 11y agoWow... that's actually pretty great
- unfamiliar 11y agoIt doesn't seem particularly "random," every time I run it it searches the same list of SO threads.
- psexton 11y agoNow we just need to submit this code as an answer to the next "how do I sort a list" question on Stack Overflow.
- esnard 11y agoDoesn't that allow to execute evil code if one of the StackOverflow answers is edited?