TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Howdoi – Instant Coding Answers via the Command Line

245 点作者 gleitz超过 12 年前

28 条评论

roryokane超过 12 年前
According to the source code (<a href="https://github.com/gleitz/howdoi/blob/master/howdoi/howdoi.py" rel="nofollow">https://github.com/gleitz/howdoi/blob/master/howdoi/howdoi.p...</a>), the answers come from Stack Overflow, searched using Google site search. Howdoi scrapes and prints the first code block in the top answer, or the full text of the top answer if it contains no code block.
评论 #5027203 未加载
评论 #5027230 未加载
评论 #5030201 未加载
评论 #5029833 未加载
davej超过 12 年前
Super useful, love it.<p>Some queries I tried (results were not perfect but pretty decent):<p><pre><code> howdoi split string javascript var split = 'john smith~123 Street~Apt 4~New York~NY~12345'.split('~'); var name = split[0]; var street = split[1]; etc... howdoi get day from date javascript var date = new Date(); var day = date.getDay(); howdoi iterate coffeescript ages = [] ages["jim"] = 12 ages["john"] = 7 for k,v of ages console.log k + " is " + v howdoi get referrer url php &#60;?php session_start(); if (!isset($_SESSION["origURL"])) $_SESSION["origURL"] = $_SERVER["HTTP_REFERER"]; ?&#62;</code></pre>
评论 #5027251 未加载
decktech超过 12 年前
<i>$ howdoi program</i><p><i>Why do you need the Apple Developer Program Enrollment ID? I also tried to apply to the iOS Developer Program this weekend. I applied, I paid and I got my activation codes. But then when I tried to activate with my Apple ID I got an error saying (in my case) they "were not able to successfully verify my identity". In that error message there was an Enrollment ID# consisting of both letters and numbers, a total of 10 characters, that I was supposed to include when contacting the support regarding this issue. I have not seen the same Enrollment ID somewhere else in the process and therefore I assume it is some kind of internal ID for my signing up process and you should only see it/use it when you hit some problems during the process.</i><p>I'll figure it out one of these days.
评论 #5028101 未加载
nicpottier超过 12 年前
I really like the idea of this, I'm getting some good results and some not so good.<p>One that fails rather badly:<p><i>format dates django templates</i> Returns simply "date", despite StackOverflow having lots of hits: <a href="http://stackoverflow.com/search?q=format+dates+django+templates" rel="nofollow">http://stackoverflow.com/search?q=format+dates+django+templa...</a><p>But some others are super cool:<p><i>create datetime from epoch</i> &#62;&#62;&#62; datetime.datetime.fromtimestamp(1284286794)<p>One suggestion is that by default I would include the link to the stackoverflow page.<p>Some color might be nice to make it extra sexy, look at the colorama package to do it easily cross platform.
评论 #5027300 未加载
nnq超过 12 年前
It even has a good sense of humor:<p><pre><code> $ howdoi kill someone ps aux </code></pre> ...yeah, first I must find out if "he"'s alive and how can I find "him", so it's a good first step :)<p><pre><code> $ howdoi clean up blood stains No, you cannot achieve that with PHP [...] </code></pre> ...indeed, PHP has never been my fav language :)
评论 #5030885 未加载
alexkus超过 12 年前
Excellent, I can give it to a friend who seems to use me (via Skype) as a proxy for StackOverflow.<p>He hasn't got the hint with lmgtfy links so I'll try a different tack...
cllns超过 12 年前
Very cool! You might want to change<p>USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17"<p>to something a little more honest though, unless you have a good reason for keeping it.
评论 #5027655 未加载
darkarmani超过 12 年前
It took a minute to realize that it requires an internet connection. Maybe you should spell that out?<p>I thought at first you had compiled a corpus of knowledge, but this is much better, but with the requirement of internet access.
评论 #5029550 未加载
评论 #5027494 未加载
coldpie超过 12 年前
Be nice if you'd make it explicit that it depends on Python 2 (change your hashbang to point to python2, or make it work in either runtime). Arch Linux defaults to Python 3 these days.
评论 #5029525 未加载
评论 #5027490 未加载
andrewljohnson超过 12 年前
This is pretty cool, but it doesn't really feel a need for me.<p>Google for _split string javascript_ or the other queries, and you'll get basically the same results, just not limited to StackOverflow as howdoi does.<p>Maybe if I were more married to my command line this would be useful, but in general, I'm only there for bash and git. I spend most of my time in an editor, so popping over to the browser is no more work for me than showing the terminal.
评论 #5028511 未加载
评论 #5029926 未加载
roryokane超过 12 年前
A similar program is `cheat`, from <a href="http://cheat.errtheblog.com/" rel="nofollow">http://cheat.errtheblog.com/</a>. Like howdoi, it prints short help on various topics to the commandline. But rather than searching Stack Overflow, it accesses a much smaller online wiki of cheat sheets. I’d give some examples of cheat sheets it has, but the online wiki seems to be down right now.
评论 #5027739 未加载
travisby超过 12 年前
This is awesome! I'm going to create some issues (and hopefully pull requests!) later with some feature ideas.<p>I'm thinking seeing the question, and listing all questions so I know which -pX I want ;)
评论 #5027838 未加载
评论 #5031189 未加载
madethemcry超过 12 年前
I can`t use tools like this nor other local knowledge databases like evernote (although I save programming notes in evernote). If I have a pending question I ask myself two questions.<p><i>"Have I ever had this problem ?" "Did I save the answer ? (In evernote or whatever)"</i><p>To think about those two answers I need around 2000ms. After 1000ms I wrote the query and asked google again... Is it only me? I wish I would use my local knowledge database but I only use it when I`m not lucky with google after the first queries.
评论 #5027637 未加载
Hawkee超过 12 年前
I think the code here is a very good example to get started with Python. It includes some very essential elements for interacting with external websites.
评论 #5028714 未加载
tathagatadg超过 12 年前
Whoa! I was just doing the same thing but with stackoverflow's api and in vim ... instead of making the query from the command line i.e. leave your editor, I'm thinking of writing the query like a comment and highlight it so that I can see the returned search results in a separate buffer. Haven't made much progress due to unfamiliarity with programming vim
评论 #5027711 未加载
lightyrs超过 12 年前
This is amazing. Thank you so very much!<p>I was very impressed by responses to queries like this:<p><pre><code> howdoi retrieve the keys from an array of hashes in ruby hash = {"apple" =&#62; "fruit", "carrot" =&#62; "vegetable"} array = hash.keys #=&#62; ["apple", "carrot"]</code></pre>
firesofmay超过 12 年前
Would be nice if it caches 2-3 answers so it doesn't have to call each time. Also if I could specify like -p123 it shows me first three answers instead of only first and I have to make a new call till I find my answer. Really useful. Thanks for sharing.
评论 #5031836 未加载
kwang88超过 12 年前
Looks like an awesome tool for the little things that nobody bothers to memorize -- very cool!
评论 #5027149 未加载
niggler超过 12 年前
Is there a way to "contribute answers"? I think a hookup with a wiki-type system would make this useful and essentially replace the text file of commands I discovered.
评论 #5027447 未加载
thiderman超过 12 年前
I enjoy this, since it's a very clever and well executed idea. Cheers!<p>However, something bugs me a little; Is there any reason for not mentioning Stack Overflow in the README?
mtraven超过 12 年前
Very nice. I like the -l feature but wish the link could appear with the normal answer, doesn't seem to be a way to do that.
crazydiamond超过 12 年前
btw, on my system the `brew install` failed giving an error about "make the appropriate changes to your system". When I tried installing pyquery I realized it requires sudo access to write to /Library. I was able to install using "sudo python setup.py install". (pip gave a stack trace).<p>Tried "howdoi split string zsh" and it gave me a good answer.
评论 #5030919 未加载
slajax超过 12 年前
Can't seem to get it installed either via brew, pip or python setup.py install on osx 10.8.2<p>Bummer. It looks really cool.
评论 #5029784 未加载
cpa超过 12 年前
Would be cool if one could directly call howdoi from the python shell.<p>&#62;&#62;&#62; howdoi foo bar<p>Or as a magic function for ipython.
hughdbrown超过 12 年前
Classic Stackoverflow moment:<p>howdoi -a parse HTML with regex
udfalkso超过 12 年前
Very nice, I'm going to use this. Thanks!
SonicSoul超过 12 年前
this is incredible! thanks so much for creating this. now i just need to figure out how to port it to Alfred :)
nerdfiles超过 12 年前
Brilliant. Given the data set, this appears somewhat intelligent, since more theoretical computer science problems may simply result in something like "advice" rather than code blocks.<p>$ howdoi mvp pattern<p>$ howdoi wittgenstein<p>$ howdoi hopfield network<p>$ howdoi feed forward network<p>$ howdoi artificial heart<p>It's like an overly precocious child that got trapped in a library, and is now set to aid you in your research/development.
评论 #5028166 未加载
评论 #5027392 未加载