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.
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
<?php
session_start();
if (!isset($_SESSION["origURL"]))
$_SESSION["origURL"] = $_SERVER["HTTP_REFERER"];
?></code></pre>
<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.
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>
>>> 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.
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 :)
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...
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.
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.
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.
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.
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.
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 ;)
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.
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.
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
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" => "fruit", "carrot" => "vegetable"}
array = hash.keys #=> ["apple", "carrot"]</code></pre>
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.
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.
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?
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.
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.