gleitz/howdoi

 gleitz / howdoi

gleitz / howdoi

instant coding answers via the command line http://blog.gleitzman.com/post/433301…

howdoi-2-200224466881010121214142017-06-222017-06-232017-06-242017-06-252017-06-262017-06-272017-06-282017-06-292017-06-302017-07-012017-07-022017-07-032017-07-042017-07-052017-07-062017-07-072017-07-082017-07-092017-07-102017-07-112017-07-122017-07-132017-07-142017-07-152017-07-162017-07-172017-07-182017-07-192017-07-202017-07-21howdoi09.11538461538142.3559813842017-06-22224.8315649867123.9597469132017-06-23240.5477453581123.9597469132017-06-24056.2639257294142.3559813842017-06-25071.9801061008142.3559813842017-06-26187.6962864721133.1578641492017-06-274103.412466844105.5635124412017-06-2810119.12864721550.37480902582017-06-294134.844827586105.5635124412017-06-301150.561007958133.1578641492017-07-012166.277188329123.9597469132017-07-022181.9933687123.9597469132017-07-032197.709549072123.9597469132017-07-043213.425729443114.7616296772017-07-058229.14190981468.77104349752017-07-062244.858090186123.9597469132017-07-073260.574270557114.7616296772017-07-080276.290450928142.3559813842017-07-090292.0066313142.3559813842017-07-103307.722811671114.7616296772017-07-112323.438992042123.9597469132017-07-122339.155172414123.9597469132017-07-131354.871352785133.1578641492017-07-141370.587533156133.1578641492017-07-151386.303713528133.1578641492017-07-160402.019893899142.3559813842017-07-171417.736074271133.1578641492017-07-183433.452254642114.7616296772017-07-1915449.1684350134.384222846452017-07-205464.88461538596.36539520512017-07-21-19.11538461538151.554098622017-06-22024.8315649867142.3559813842017-06-23040.5477453581142.3559813842017-06-24056.2639257294142.3559813842017-06-25171.9801061008133.1578641492017-06-26287.6962864721123.9597469132017-06-27-2103.412466844160.7522158562017-06-281119.128647215133.1578641492017-06-290134.844827586142.3559813842017-06-300150.561007958142.3559813842017-07-01-1166.277188329151.554098622017-07-020181.9933687142.3559813842017-07-030197.709549072142.3559813842017-07-040213.425729443142.3559813842017-07-051229.141909814133.1578641492017-07-060244.858090186142.3559813842017-07-071260.574270557133.1578641492017-07-080276.290450928142.3559813842017-07-090292.0066313142.3559813842017-07-100307.722811671142.3559813842017-07-110323.438992042142.3559813842017-07-121339.155172414133.1578641492017-07-13-1354.871352785151.554098622017-07-140370.587533156142.3559813842017-07-150386.303713528142.3559813842017-07-161402.019893899133.1578641492017-07-172417.736074271123.9597469132017-07-182433.452254642123.9597469132017-07-192449.168435013123.9597469132017-07-201464.884615385133.1578641492017-07-2109.11538461538142.3559813842017-06-22024.8315649867142.3559813842017-06-23040.5477453581142.3559813842017-06-24056.2639257294142.3559813842017-06-25071.9801061008142.3559813842017-06-26087.6962864721142.3559813842017-06-270103.412466844142.3559813842017-06-280119.128647215142.3559813842017-06-290134.844827586142.3559813842017-06-300150.561007958142.3559813842017-07-010166.277188329142.3559813842017-07-020181.9933687142.3559813842017-07-030197.709549072142.3559813842017-07-040213.425729443142.3559813842017-07-050229.141909814142.3559813842017-07-060244.858090186142.3559813842017-07-070260.574270557142.3559813842017-07-080276.290450928142.3559813842017-07-090292.0066313142.3559813842017-07-100307.722811671142.3559813842017-07-111323.438992042133.1578641492017-07-120339.155172414142.3559813842017-07-132354.871352785123.9597469132017-07-140370.587533156142.3559813842017-07-150386.303713528142.3559813842017-07-160402.019893899142.3559813842017-07-170417.736074271142.3559813842017-07-18-1433.452254642151.554098622017-07-190449.168435013142.3559813842017-07-200464.884615385142.3559813842017-07-21starforkwatch

 README

howdoi

http://imgs.xkcd.com/comics/tar.png

instant coding answers via the command line

https://secure.travis-ci.org/gleitz/howdoi.png?branch=master

Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programing tasks?

Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi:

$ howdoi format date bash
> DATE=date +%Y-%m-%d

howdoi will answer all sorts of queries:

$ howdoi print stack trace python
> import traceback
>
> try:
>     1/0
> except:
>     print '>>> traceback <<<'
>     traceback.print_exc()
>     print '>>> end of traceback <<<'
> traceback.print_exc()

$ howdoi convert mp4 to animated gif > video=/path/to/video.avi > outdir=/path/to/output.gif > mplayer "$video" \ > -ao null \ > -ss "00:01:00" \ # starting point > -endpos 10 \ # duration in second > -vo gif89a:fps=13:output=$outdir \ > -vf scale=240:180

$ howdoi create tar archive > tar -cf backup.tar --exclude "www/subf3" www

Installation

pip install howdoi

or

pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi

or

brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb

or

python setup.py install

Usage

usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...]

instant coding answers via the command line

positional arguments: QUERY the question to answer

optional arguments: -h, --help show this help message and exit -p POS, --pos POS select answer in specified position (default: 1) -a, --all display the full text of the answer -l, --link display only the answer link -c, --color enable colorized output -n NUM_ANSWERS, --num-answers NUM_ANSWERS number of answers to return -C, --clear-cache clear the cache -v, --version displays the current version of howdoi

Author

Notes

  • Works with Python2 and Python3
  • A standalone Windows executable with the howdoi application is available here.
  • An Alfred Workflow for howdoi can be found at http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers.
  • Slack integration available through slack-howdoi.
  • Howdoi uses a cache for faster access to previous questions. Caching functionality can be disabled by setting the HOWDOI_DISABLE_CACHE environment variable. The cache is stored in ~/.cache/howdoi.
  • You can set the HOWDOI_URL environment variable to change the source url for answers (default: stackoverflow.com). Other options include serverfault.com or pt.stackoverflow.com. Here's the full list.
  • Setting the HOWDOI_COLORIZE environment variable will colorize the output by default.
  • Special thanks to Rich Jones (@miserlou) for the idea.

Development

  • Checkout the repo
  • Run python -m howdoi.howdoi QUERY (if you try running python howdoi/howdoi.py you my get ValueError: Attempted relative import in non-package).

Troubleshooting

You might get the following error when installing with Homebrew:

==> python setup.py install

http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.

Fix the error by executing the following command:

sudo chmod -R go+w /Library/Python/2.7/site-packages/

An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing. Try and install an unofficial binary for lxml from

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml