According to the source code (https://github.com/gleitz/howdoi/blob/master/howdoi/howdoi.p...), 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.
It should probably use symbolhound.com instead, which does exact symbol queries on stackoverflow content. Google, alas, thinks we are all terrible people for wanting our precious bytes.
That's a nice search tool. I found that the relevance is not quite as good as Google (for example "howdoi get referrer url php") but this could be used when you enter a query that contains symbols.
Some queries I tried (results were not perfect but pretty decent):
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"];
?>
An enhancement I've been considering is noticing when users ask for a second or third answer with "-p2" or "-p3". If it happens often and the user never queries again after reading the second answer you can assume it is probably correct and display it to all users as the default response.
Also.. don't you think the more common case is not that the top answer is incorrect but rather you picked the wrong question from the search results? Seems to me that would be more common.
That sounds smart but it also means that you'd need to keep track of and store user actions centrally. I don't know if I'd like that. You could always make it an opt-in feature I suppose.
That's not a bad idea, kind of meta level answer tracking.
What about making it even easier by just prompting as to whether it answered their question? (perhaps defaulting to 'y' so you can just hit enter if so)
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.
Thanks for playing with it. Sometimes the first answer isn't the greatest but -p2 or -p3 will get it. In this case the following command gets you closer:
Bad news if you use it at work. Management will see all the search queries using the Internet and think you are doing a lot of surfing.
This is basically like those old Technet and MSDN programs for Windows, they searched the online Microsoft database for new content. I found that out the hard way when I was asking why I was using so much Internet and then I found out it was my MSDN lookups when encountering bugs in the Windows API calls etc and even if business related, management was counting them. Management didn't know the difference between MSDN and MSN even if they paid a lot for my MSDN subscription. Management was constantly searching MSN for stock quotes and news items BTW because it was the default web page in Internet Explorer.
Neither would I, but this was back during the Dotcom crashes when jobs were hard to find because the market was flooded with people looking for work.
You also don't know it until after you are hired, and you find out they install remote access trojans on your Windows workstation, and count the number of characters you type, and monitor your Internet use and don't know the difference between a work related site, a non-work related site, or just accessing ASP rendered pages on the Intranet I was developing for them. Basically it was a Big Brother type of organization, a law firm in downtown Saint Louis MO.
It was very stressful, the IT department at the law firm I worked at had a 90% turnaround for over four years that I worked there. They treated us like dirt/crap. For example I had to call Seagate Software for Crystal Report issues and their tech support number was in Canada. Everything a law firm does is tagged to a client and matter number for accounting purposes. I used the office numbers because it was business related. Since it was in Canada there was no 1-800 or toll free number, so they took the cost of the calls (what they usually bill the clients for LD calls) out of my paycheck because it was Canada. I asked to be reimbursed because it is business related, and they refused, telling me not to call Canada anymore as they only want to deal with US based companies. Keep in mind that Crystal Reports was bundled with Visual Studio 5.0/6.0 back then and they paid for Crystal Reports 7.0 to give everyone that nifty Web based server that gave them RTF, Word, Excel, and PDF files on the fly. It had a lot of bugs, and you had to talk to Seagate (I think they changed names or got bought out since there, Business Objects, SaS, whatever) which was located in Canada. I got so upset that I bought a LD calling card to make those calls.
Moving from Windows 95 and Office 97 to Windows 2000 and Office 2000 was a nightmare, because there were bugs and I was told Microsoft was aware of it and will fix it in the next service pack. We had gone to the latest and greatest of Microsoft's software instead of waiting for service packs to be released to address bugs so it is more stable. My Fax program used a Word Object to copy RightFAX codes into a document and print with a RightFax printer driver to fax out documents. Problem was Word 2000 had a bug that messed up the toolbar after a document was closed using the Word object in Visual BASIC. Microsoft admitted the bug, but didn't release a service pack to fix it yet. Management didn't understand that and had me search MSDN for a solution or maybe a beta service pack to address the issue. Then I am chewed out for wasting five hours searching the MSDN knowledgebase for a solution. I forget how we fixed it, but the work-a-round from Microsoft was to minimum Word 2000 and then restore it and the toolbar bug went away after that. After the service packs were released the bug went away.
While working for that company I suffered a nervous breakdown from the abuse and stress, and ended up on short-term disability, when I returned I was fired two weeks later for having a panic attack at work. They had moved me to an open area, no more cubical, near a bookshelf, and people mocked me and laughed at me as they walked by.
I had the right to sue, but because I am mentally ill, no lawyer would take the case. I am considering writing an ebook on the computer industry, as well as another ebook on what lead up to me becoming mentally ill and no longer able to work as a result.
Yes it was not a good work environment, it ruined my life and career.
They also have odata endpoints so you should be able to get at the data (updated weekly) that way. It looks like there is a problem with it at the moment, though (I get 'server error'):
http://data.stackexchange.com/stackoverflow/atom
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.
Isn't that an Arch bug? Last I heard, there was consensus in the upstream Python community that /usr/bin/python should not be Python 3, which makes sense because Python 3 is deliberately incompatible with Python 2. Of course, that viewpoint might have changed.
But still, even if upstream disagrees, I think it is the responsibility of the packagers not to break ABI compatibility in this way (just as they wouldn't ship OpenSSL 1.0 as libopenssl0.9.8.so). I'm pretty sure every script that uses Python 3 uses python3 in the shebang.
You're talking about PEP 394[1]. It suggests that "python" point to either "python2" or "python3", depending on what ships with the distro by default or on the distro's stated goals. Arch tries to be as cutting edge as possible, even putting out new kernels within weeks after their release. It makes sense for Arch to begin pushing the boundaries here.
There was a discussion on the arch-dev-public mailing list[2] recently that you might be interested in.
In any case, I think it's clearly beneficial for every new Python application to make their version requirements explicit in the hashbang.
Cool, thanks for the pointers! I'm a little disappointed that Debian doesn't seem to be shipping the python2 symlink, which means that I can't switch to using that in my own code.
This is pretty cool, but it doesn't really feel a need for me.
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.
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.
I think the appeal of this for me would be that it feels less flow breaking to use my command-line (all work things) than using the browser (mix of work things and distractions.)
A similar program is `cheat`, from http://cheat.errtheblog.com/. 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.
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.
"Have I ever had this problem ?"
"Did I save the answer ? (In evernote or whatever)"
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.
What I meant with that - post your solution not locally but somewhere useful (Stackoverflow?). You'll do yourself a favor and others can benefit from that.
Great tweet! :) Maybe it`s my fear of finding my own post on stackoverflow. Anyway I`ll try to follow your advice. I have a bad ratio giving back knowledge to the community- mostly due to my even worse time management.
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
I was very impressed by responses to queries like this:
howdoi retrieve the keys from an array of hashes in ruby
hash = {"apple" => "fruit", "carrot" => "vegetable"}
array = hash.keys #=> ["apple", "carrot"]
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.
No way to currently contribute answers. Another commenter mentioned cheat.errtheblog.com that uses a wiki system. The downside is that when the wiki fails (like right now) the application breaks.
You may want to just submit a good answer to StackOverflow and make sure it is well written and gets lots of votes.
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).
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.
$ howdoi mvp pattern
$ howdoi wittgenstein
$ howdoi hopfield network
$ howdoi feed forward network
$ howdoi artificial heart
It's like an overly precocious child that got trapped in a library, and is now set to aid you in your research/development.