Howdoi – Instant Coding Answers via the Command Line
github.com
github.com
I find myself using the following command quite a bit:
open `howdoi print stack trace python -l`
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"];
?>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)
$ howdoi format dates django templates -l
http://stackoverflow.com/questions/7737146/django-template-d...
$ howdoi format dates django templates -p2 -l
http://stackoverflow.com/questions/1180372/how-to-format-dat...
$ howdoi format dates django templates -p3 -l
http://stackoverflow.com/questions/4087717/django-template-d...
Another improvement might be to list the second and third answers to the currently selected question.
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'll figure it out one of these days.
One that fails rather badly:
format dates django templates Returns simply "date", despite StackOverflow having lots of hits: http://stackoverflow.com/search?q=format+dates+django+templa...
But some others are super cool:
create datetime from epoch >>> datetime.datetime.fromtimestamp(1284286794)
One suggestion is that by default I would include the link to the stackoverflow page.
Some color might be nice to make it extra sexy, look at the colorama package to do it easily cross platform.
howdoi format dates django templates -p3
Excellent idea for colorization! I've already got that suggestion on the github page -> https://github.com/gleitz/howdoi/issues/4
$ howdoi kill someone
ps aux
...yeah, first I must find out if "he"'s alive and how can I find "him", so it's a good first step :) $ howdoi clean up blood stains
No, you cannot achieve that with PHP [...]
...indeed, PHP has never been my fav language :) howdoi kill myself
Thread.AbortHe hasn't got the hint with lmgtfy links so I'll try a different tack...
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"
to something a little more honest though, unless you have a good reason for keeping it.
I thought at first you had compiled a corpus of knowledge, but this is much better, but with the requirement of internet access.
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
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.
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.
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.
#!/usr/bin/env python
Edit: Hee hee
[aeikum@aeikum howdoi]$ howdoi use python2 on default python3
/usr/bin/env python2.7
#!/usr/bin/env python2
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.
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.
[1] http://www.python.org/dev/peps/pep-0394/
[2] https://mailman.archlinux.org/pipermail/arch-dev-public/2012...
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.
But parsing a web page to find an precise answer usually takes a while.
I'm thinking seeing the question, and listing all questions so I know which -pX I want ;)
"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.
:r!howdoi python regex
:r! executes a command and inserts its standard output below the cursorI 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"]You may want to just submit a good answer to StackOverflow and make sure it is well written and gets lots of votes.
However, something bugs me a little; Is there any reason for not mentioning Stack Overflow in the README?
Tried "howdoi split string zsh" and it gave me a good answer.
Bummer. It looks really cool.
% uname -a
Darwin xxx 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 16:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64 x86_64
% sudo pip install howdoi
Password:
Downloading/unpacking howdoi
Downloading howdoi-0.2.tar.gz
Running setup.py egg_info for package howdoi
Requirement already satisfied (use --upgrade to upgrade): pyquery in /Library/Python/2.7/site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): lxml>=2.1 in /Library/Python/2.7/site-packages (from pyquery->howdoi)
Requirement already satisfied (use --upgrade to upgrade): cssselect in /Library/Python/2.7/site-packages (from pyquery->howdoi)
Installing collected packages: howdoi
Running setup.py install for howdoi
Installing howdoi script to /usr/local/bin
Successfully installed howdoi
Cleaning up...
Maybe file a bug with what happens when you try? sudo chmod -R go+w /Library/Python/2.7/site-packages/
which is noted at the bottom of the readme and I missed it.>>> howdoi foo bar
Or as a magic function for ipython.
howdoi -a parse HTML with regex
$ 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.
This thing is great.
$ howdoi solve the halting problem
$ howdoi find the holy grail
I could do this all day.