GithubHelp home page GithubHelp logo

gleitz / howdoi Goto Github PK

View Code? Open in Web Editor NEW
10.5K 10.5K 867.0 27.09 MB

instant coding answers via the command line

Home Page: http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line

License: MIT License

Python 73.11% TypeScript 26.89%

howdoi's People

Contributors

abbi031892codenation avatar adbenitez avatar almenon avatar anthonypt87 avatar atharvakale343 avatar bellecp avatar benjaminhafen avatar dependabot[bot] avatar diarreola avatar eddie-dunn avatar ellisonleao avatar eoglethorpe avatar gleitz avatar gmelodie avatar jianli avatar joeyouss avatar ovezovs avatar paulie-g avatar prateek93a avatar rtruxal avatar saurusxi avatar shezamunir avatar sinasamavati avatar tayoogunbiyi avatar telelvis avatar tra38 avatar tusharmakkar08 avatar v2dha avatar windsoilder avatar yko20010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

howdoi's Issues

howdoi not finding answer to question

Command: howdoi sleep with your mom
Program returns: t1.interrupt(); //this will throw the exception when t1 is sleeping
Excepted response: more detailed instructions

change -f to -a

$ howdoi -f git commit

usually the "-f" flag is used for "force" and feels volatile, it might be nice to change it to "-a" for "--article"

ImportError: No module named lxml

Hey, I am having problem getting it to run on OSx 10.7 python 2.7 as default.

Traceback (most recent call last):
File "howdoi/howdoi.py", line 35, in
from pyquery import PyQuery as pq
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyquery-1.2.8-py2.7.egg/pyquery/init.py", line 11, in
from .pyquery import PyQuery
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyquery-1.2.8-py2.7.egg/pyquery/pyquery.py", line 9, in
from lxml import etree
ImportError: No module named lxml

I tried to install lxml then which ended up to another issue:

llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-
aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/private/var/folders/43/m1qv9zf53q19sqh6h9kg9pz80000gn/T/pip_build_sanjeevkumar/lxml/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.7-intel-2.7/src/lxml/lxml.etree.o -flat_namespace

unable to execute llvm-gcc-4.2: No such file or directory

error: command 'llvm-gcc-4.2' failed with exit status 1

howdoi get a job throws an error

A facetious query on my part, but there's an error nonetheless:

 File "/usr/local/bin/howdoi", line 9, in <module>
    load_entry_point('howdoi==0.2', 'console_scripts', 'howdoi')()
  File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 93, in command_line_runner
    howdoi(args)
  File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 80, in howdoi
    instructions = get_instructions(args) or 'Sorry, couldn\'t find any help with that topic'
  File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 66, in get_instructions
    page = get_result(link)
  File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 27, in get_result
    result = opener.open(url)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

pkg_resources.DistributionNotFound: cssselect

Im getting the following error after install with pip install howdoi on Fedora release 14 (Laughlin) i686 python 2.7

[ozdemircili@localhost ~]$ howdoi
Traceback (most recent call last):
File "/usr/bin/howdoi", line 5, in
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2707, in
working_set.require(requires)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: cssselect

Installation fails

OS: Windows 7 x64

C:\Users>pip --version
pip 1.3.1 from c:\python33\lib\site-packages\pip-1.3.1-py3.3.egg (python 3.3)

C:\Users>python --version
Python 3.3.1

Note: This is the second run as my console did not capture all lines on the first try.

C:\Users>pip install howdoi
Downloading/unpacking howdoi
  Running setup.py egg_info for package howdoi

Requirement already satisfied (use --upgrade to upgrade): pyquery in c:\python33\lib\site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): pygments in c:\python33\lib\site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): requests in c:\python33\lib\site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): requests-cache in c:\python33\lib\site-packages (from howdoi)
Downloading/unpacking lxml>=2.1 (from pyquery->howdoi)
  Running setup.py egg_info for package lxml
    Building lxml version 3.2.3.
    Building without Cython.
    ERROR: b'Der Befehl "xslt-config" ist entweder falsch geschrieben oder\r\nkonnte nicht gefunden werden.\r\n'
    ** make sure the development packages of libxml2 and libxslt are installed **

    Using build configuration of libxslt
    c:\Python33\lib\distutils\dist.py:257: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)

    warning: no files found matching '*.txt' under directory 'src\lxml\tests'
Downloading/unpacking cssselect (from pyquery->howdoi)
  Running setup.py egg_info for package cssselect

    no previously-included directories found matching 'docs\_build'
Installing collected packages: howdoi, lxml, cssselect
  Running setup.py install for howdoi

    Installing howdoi-script.py script to c:\Python33\Scripts
    Installing howdoi.exe script to c:\Python33\Scripts
  Running setup.py install for lxml
    Building lxml version 3.2.3.
    Building without Cython.
    ERROR: b'Der Befehl "xslt-config" ist entweder falsch geschrieben oder\r\nkonnte nicht gefunden werden.\r\n'
    ** make sure the development packages of libxml2 and libxslt are installed **

    Using build configuration of libxslt
    building 'lxml.etree' extension
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\marco\appdata\local\temp\pip-build-marco\lxml\src\lxml\includes -Ic:\Python33\include -Ic:\Python33\include /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win-amd64-3.3\Release\src\lxml\lxml.etree.obj
    lxml.etree.c
    c:\users\marco\appdata\local\temp\pip-build-marco\lxml\src\lxml\includes\etree_defs.h(9) : fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "libxml/xmlversion.h": No such file or directory
    c:\Python33\lib\distutils\dist.py:257: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    error: command '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
    Complete output from command c:\Python33\python.exe -c "import setuptools;__file__='c:\\users\\marco\\appdata\\local\\temp\\pip-build-marco\\lxml\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\marco\appdata\local\temp\pip-rpxb94-record\install-record.txt --single-version-externally-managed:
    Building lxml version 3.2.3.

Building without Cython.

ERROR: b'Der Befehl "xslt-config" ist entweder falsch geschrieben oder\r\nkonnte nicht gefunden werden.\r\n'

** make sure the development packages of libxml2 and libxslt are installed **



Using build configuration of libxslt

running install

running build

running build_py

copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-3.3\lxml\includes

running build_ext

building 'lxml.etree' extension

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\users\marco\appdata\local\temp\pip-build-marco\lxml\src\lxml\includes -Ic:\Python33\include -Ic:\Python33\include /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win-amd64-3.3\Release\src\lxml\lxml.etree.obj

lxml.etree.c

c:\users\marco\appdata\local\temp\pip-build-marco\lxml\src\lxml\includes\etree_defs.h(9) : fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "libxml/xmlversion.h": No such file or directory

c:\Python33\lib\distutils\dist.py:257: UserWarning: Unknown distribution option: 'bugtrack_url'

  warnings.warn(msg)

error: command '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe"' failed with exit status 2

----------------------------------------
Command c:\Python33\python.exe -c "import setuptools;__file__='c:\\users\\marco\\appdata\\local\\temp\\pip-build-marco\\lxml\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\marco\appdata\local\temp\pip-rpxb94-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\marco\appdata\local\temp\pip-build-marco\lxml
Storing complete log in C:\Users\marco\pip\pip.log
C:\Users>howdoi test
Traceback (most recent call last):
  File "c:\Python33\Scripts\howdoi-script.py", line 5, in <module>
    from pkg_resources import load_entry_point
  File "c:\Python33\lib\site-packages\distribute-0.6.36-py3.3.egg\pkg_resources.py", line 2806, in <module>
    working_set.require(__requires__)
  File "c:\Python33\lib\site-packages\distribute-0.6.36-py3.3.egg\pkg_resources.py", line 696, in require
    needed = self.resolve(parse_requirements(requirements))
  File "c:\Python33\lib\site-packages\distribute-0.6.36-py3.3.egg\pkg_resources.py", line 594, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: cssselect

Do you happen to have any idea why this fails?
Looks to me that calling xslt-config fails, do I have to add that manually or was it just "not installed"?

windows UAC problem and window closes

Hi, Is there anything to do with the exe to avoid the UAC besides disabling UAC?

Also running howdoi.exe from command line, it finishes execution and closes the window before see what it says.

IndexError: list index out of range

howdoi meo
Traceback (most recent call last):
File "/usr/bin/howdoi", line 9, in
load_entry_point('howdoi==1.1.5', 'console_scripts', 'howdoi')()
File "/usr/lib/python2.7/site-packages/howdoi/howdoi.py", line 241, in command_line_runner
print(howdoi(args).encode('utf-8', 'ignore'))
File "/usr/lib/python2.7/site-packages/howdoi/howdoi.py", line 201, in howdoi
return get_instructions(args) or 'Sorry, couldn't find any help with that topic\n'
File "/usr/lib/python2.7/site-packages/howdoi/howdoi.py", line 177, in get_instructions
answer = get_answer(args, links)
File "/usr/lib/python2.7/site-packages/howdoi/howdoi.py", line 136, in get_answer
link = get_link_at_pos(links, args['pos'])
File "/usr/lib/python2.7/site-packages/howdoi/howdoi.py", line 108, in get_link_at_pos
link = links[-1]
IndexError: list index out of range

howdoi is not compatible with the new version of requests

The requests module has finally fixed its ssl problems, however, now they require explicit proxy schemes for the requests.get method. Currently I get this error when trying to run howdoi:

<snipped long stacktrace>
requests.exceptions.MissingSchema: Proxy URLs must have explicit schemes.

The problem is that my environment proxy variables don't use explicit schemes; for example http_proxy is set to wwwproxy.company.com:3128 instead of http://wwwproxy.company.com:3128. Naturally, this can be solved if I make sure that all my environment proxy variables use explicit schemes, i.e. http://wwwproxy.company.com:3128, https://wwwproxy.company.com:3128, etc. Unfortunately this solution is not readily apparent to the hapless user.

A more elegant solution would be to instead modify howdoi to filter out http and https, since those are the only proxies howdoi uses, and then make sure that they use explicit schemas.

I have a working solution on my computer, if you are interested in reviewing a pull request.

display multiple answers instead of just one

This is a cool tool. It seems like some people on HN aren't satisfied with the first answer that howdoi provides, and instead of searching again and again it would be nice to have an option that displays, for example, the first three results

line wrapping / formatting answer

Love this tools :)

It would gain a lot of readability if the output would wrap the line at a given width - or is there a way to force that? at this point the output cut whatever word in order to move to next line.

thanks!

pip install howdoi fails

Fails to build lxml.etree

building 'lxml.etree' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/root/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o

src/lxml/lxml.etree.c:4:20: fatal error: Python.h: No such file or directory

Unable to install howdoi on Mac Snow Leopard

Tried installing on my MacBook; results are as follows:

EDP24:ArborwellWebForms jseidel$ brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb
######################################################################## 100.0%
==> Downloading http://pypi.python.org/packages/source/h/howdoi/howdoi-1.0.tar.gz
Already downloaded: /Users/jseidel/Library/Caches/Homebrew/howdoi-1.0.tar.gz
==> python setup.py install
Using build configuration of libxslt 1.1.24
warning: no files found matching '*.txt' under directory 'src/lxml/tests'
cc1: error: unrecognized command line option "-march=core2"
lipo: can't open input file: /var/folders/0Y/0YhDVwcDGu4v6rBRQGIUdk+++TM/-Tmp-//cc6ZuOKi.out (No such file or directory)
error: Setup script exited with error: command '/usr/bin/gcc-4.2' failed with exit status 1

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

Also, see http://pastie.org/5811939 for details

Error INstalling with pip

when i try and install howdoi with sudo pip install howdoi i get an error message in compilation. Reproducing the relevant lines below:

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so

/usr/bin/ld: cannot find -lz

I've googled on this issue and the error seems to be a broken link to a library. But while google points to the genric error unfortunately it doesn't specify which library corresponds to -lz. I found links for -lm and a few others.

I really want to try this applciation so any help will be appreciated

thanks

Create a standalone version for Windows

First off, since I'm not a Python developer I have no idea if this is easy to include in a build process or not. However, since I've seen several Python applications that run on Windows without having to install Python (for example, PyLoad), I think that it might be easier in Python than say, .NET or Java.

I'm not expecting this issue to be fixed soon - I just thought I should post it as a wish.

Also, it doesn't necessarily need an installer (I think any user of this knows how to copy a folder to Program Files), but with one, it would be possible to add howdoi to the %PATH%, so that people can pop up a prompt and run it easily.

-l flag could be more useful

I'd like to always see the link with results, or at least have a flag to do that. Right now you can only geet one or the other.

'PyQuery' object has no attribute 'items'

$ howdoi -n 3 -a list to string python

Traceback (most recent call last):
File "/usr/local/bin/howdoi", line 8, in
load_entry_point('howdoi==1.1.5', 'console_scripts', 'howdoi')()
File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 226, in command_line_runner
print(howdoi(args).encode('utf-8', 'ignore'))
File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 187, in howdoi
return get_instructions(args) or 'Sorry, couldn't find any help with that topic\n'
File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 163, in get_instructions
answer = get_answer(args, links)
File "/Library/Python/2.7/site-packages/howdoi/howdoi.py", line 136, in get_answer
for html_tag in first_answer.items('.post-text > *'):
AttributeError: 'PyQuery' object has no attribute 'items'

💩

Package, PIPify

It'd be nice to able to install this anywhere via a global pip install!

How to install?

Can't get this installed on my mac:

pip install howdoi
-bash: pip: command not found

install directions with brew

for people like me (python-idiots), pip install is unfamiliar. i think having installation go through something with a bit broader reach might be useful. i personally would prefer to have this as a brew formula.

"Failed to establish network connection", behind proxy

At home I can use howdoi, no problem. At work I get this:
edwardd@lnxedwardd> howdoi say hello in german
Failed to establish network connection
edwardd@lnxedwardd>

I edited howdoi.py to print the ConnectionError before returning, which displays this message:
[Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

No idea what it means, but I'm guessing it is a proxy error, mainly because all network errors here at work usually have to do with the proxy.

Is it possible to make howdoi work behind a proxy?

Suggestions

If the search found no results , Howdoi could returns "Did you mean X ?" instead of nothing.

Cache breaks between python2 and python3

The new cache feature is not compatible between major versions of python:

$ howdoi-python2.7 python hello world
print("Hello, World!")

$ howdoi-python3.2 python hello world
Traceback (most recent call last):
File "/usr/bin/howdoi-python3.2", line 9, in
load_entry_point('howdoi==1.1.4', 'console_scripts', 'howdoi')()
File "/usr/lib64/python3.2/site-packages/howdoi/howdoi.py", line 217, in command_line_runner
print(howdoi(args).encode('utf-8', 'ignore'))
File "/usr/lib64/python3.2/site-packages/howdoi/howdoi.py", line 176, in howdoi
return get_instructions(args) or 'Sorry, couldn't find any help with that topic\n'
File "/usr/lib64/python3.2/site-packages/howdoi/howdoi.py", line 143, in get_instructions
links = get_links(args['query'])
File "/usr/lib64/python3.2/site-packages/howdoi/howdoi.py", line 68, in get_links
result = get_result(url)
File "/usr/lib64/python3.2/site-packages/howdoi/howdoi.py", line 59, in get_result
return requests.get(url, headers={'User-Agent': random.choice(USER_AGENTS)}, proxies=get_proxies()).text
File "/usr/lib64/python3.2/site-packages/requests/api.py", line 55, in get
return request('get', url, *_kwargs)
File "/usr/lib64/python3.2/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/lib64/python3.2/site-packages/requests_cache/core.py", line 111, in request
hooks, stream, verify, cert)
File "/usr/lib64/python3.2/site-packages/requests/sessions.py", line 335, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib64/python3.2/site-packages/requests_cache/core.py", line 89, in send
response, timestamp = self.cache.get_response_and_time(cache_key)
File "/usr/lib64/python3.2/site-packages/requests_cache/backends/base.py", line 64, in get_response_and_time
if key not in self.responses:
File "/usr/lib64/python3.2/_abcoll.py", line 365, in contains
self[key]
File "/usr/lib64/python3.2/site-packages/requests_cache/backends/storage/dbdict.py", line 171, in getitem
return pickle.loads(bytes(super(DbPickleDict, self).getitem(key)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 192993: ordinal not in range(128)

StackExchange API usage (optionally)

@gleitz I have done some work some time ago, mainly involving:

  1. StackExchange API integration
  2. (Better) Answer formatting and pagination
  3. I used SQLite for caching
  4. Optionally return the full text of the answer or in cases code is not found or below a threshold (e.g. 2 words)
  5. Return the answer link too

Most of these features can be controlled through command line arguments.
I see though that there has been a lot of work done in the meanwhile, let me know if you are interested in merging any of the above, I'll be more than happy to discuss.

https://github.com/georgepsarakis/howdoi/

P.S.:
Great idea! 👍

Update version installed via `pip`, please

Hi there

I've just recommended howdoi to my colleagues and found that the version they've all installed via pip is quite out of date. :( (Still suffers from unicode bug)

Could you release a new one, please?
Thanks!

brew install doesn't work

$ brew update
Already up-to-date.
$ brew doctor
Your system is raring to brew.
$ brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb
######################################################################## 100.0%
Warning: HOMEBREW_USE_LLVM is deprecated, use HOMEBREW_CC="llvm" instead
==> Downloading http://pypi.python.org/packages/source/h/howdoi/howdoi-0.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/howdoi-0.2.tar.gz
==> python setup.py install

  http://packages.python.org/distribute/easy_install.html

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


READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

Syntax error on Windows

I really wanted this so I just installed Python 3.3.0, and tried to install howdoi.

Seemingly I could not compile lxml, but that was sorted out getting a binary here

Problem is, when I run howdoi, it gives me this:

  File "howdoi.py", line 81
    print instructions
                     ^
SyntaxError: invalid syntax

Why? I am completely clueless and know nothing about Python to sort it out. I have all dependencies (even installed argparse just now, seeing this)

Edit: just in case it matters, I installed using pip install howdoi, then I tried the setup.py later, and even tried it all again after installing the lxml binary for Windows, but still nothing happens. Oh, and I have the python directory in my path, also python/Scripts one. Tested on Windows XP 32-bit.

Unsupported backend "sqlite"

Python 2.7.2

$ howdoi ask
Traceback (most recent call last):
  File "/opt/zenoss/bin/howdoi", line 8, in <module>
    load_entry_point('howdoi==1.1.4', 'console_scripts', 'howdoi')()
  File "/opt/zenoss/lib/python2.7/site-packages/howdoi/howdoi.py", line 217, in command_line_runner
    print(howdoi(args).encode('utf-8', 'ignore'))
  File "/opt/zenoss/lib/python2.7/site-packages/howdoi/howdoi.py", line 176, in howdoi
    return get_instructions(args) or 'Sorry, couldn\'t find any help with that topic\n'
  File "/opt/zenoss/lib/python2.7/site-packages/howdoi/howdoi.py", line 143, in get_instructions
    links = get_links(args['query'])
  File "/opt/zenoss/lib/python2.7/site-packages/howdoi/howdoi.py", line 68, in get_links
    result = get_result(url)
  File "/opt/zenoss/lib/python2.7/site-packages/howdoi/howdoi.py", line 59, in get_result
    return requests.get(url, headers={'User-Agent': random.choice(USER_AGENTS)}, proxies=get_proxies()).text
  File "/opt/zenoss/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/opt/zenoss/lib/python2.7/site-packages/requests/api.py", line 43, in request
    session = sessions.Session()
  File "/opt/zenoss/lib/python2.7/site-packages/requests_cache/core.py", line 155, in <lambda>
    **backend_options)
  File "/opt/zenoss/lib/python2.7/site-packages/requests_cache/core.py", line 63, in __init__
    (backend, ', '.join(backends.registry.keys())))
ValueError: Unsupported backend "sqlite" try one of: redis, memory

support for other search engines

I gave a fast look to the code and i saw that support for duckduckgo is planned (at least there is a func for it) but not in use.

BTW, isn't it better to directly search on stackoverflow?

Some Unicode issues...

bash-4.2$ howdoi make a log scale d3
Traceback (most recent call last):
File "/usr/local/bin/howdoi", line 8, in
load_entry_point('howdoi==0.2', 'console_scripts', 'howdoi')()
File "build/bdist.macosx-10.8-intel/egg/howdoi/howdoi.py", line 93, in command_line_runner
File "build/bdist.macosx-10.8-intel/egg/howdoi/howdoi.py", line 81, in howdoi
UnicodeEncodeError: 'ascii' codec can't encode characters in position 195-196: ordinal not in range(128)

I think this is because the source page has a ± character in it.
http://stackoverflow.com/questions/11924335/horizon-chart-not-visible-when-using-d3-scale-log

Add option to open answer in browser

There are cases, when I want to see the found answer in a web browser, e.g. for following a link or upvoting the answer (which is an important give-back to the community).

Therefore I propose an -o / --open flag, that opens the answer in the browser instead of printing to the terminal:

$ howdoi upvote an answer
# ...ah, interesting, let's upvote the answer
$ howdoi --open upvote an answer
# opens browser at stackoverflow.com/...

An implementation could be based on Python's webbrowser module:

if args['open']:
    webbrowser.open(link)
else:
    print answer

If the argument to --pos is too large, howdoi returns the last answer

If a query has only say, 10 answers and you request the 11th, or even the 100th, howdoi will silently give you the last one.

$ howdoi -p8 python quickcheck
What unit testing in PHP to start
$ howdoi -p9 python quickcheck
I don't know of any one resource which will provide you with sample inputs[…]
$ howdoi -p10 python quickcheck
xldate_as_tuple
$ howdoi -p11 python quickcheck
xldate_as_tuple
$ howdoi -p100 python quickcheck
xldate_as_tuple

Shouldn't it print an error message in such a case ?

colors

for readability, it might be nice to colorize the output that is code vs text. additionally, you could make keyword matches bold.

No answers found on Windows stand alone version

I followed the link in the readme file to download the Windows stand alone executable. I have tried moving this file to c: and to "C:\Program Files\howdoi", after adding these to my path environment variable I can access the application, but cannot find any answers.

howdoi -h
returns the expected help menu, however any subject I search on returns "Sorry, couldn't find any help with that topic". I have even tried the date format example that you give in the readme and still get the same response.

screenshot 2014-05-04 11 28 25

Try using HTTP instead of HTTPS by setting the environment variable "HOWDOI_DISABLE_SSL".

Try using HTTP instead of HTTPS by setting the environment variable "HOWDOI_DISABLE_SSL".
how to fix this!
Thanks
mac ox 10.8

I install howdoi success.
In terminal:
$:howdoi convert doc to pdf
show the error message: Try using HTTP instead of HTTPS by setting the environment variable "HOWDOI_DISABLE_SSL".

I try to fix it, but i do not how to setting the environment variable "HOWDOI_DISABLE_SSL".

please help!
thanks

Pip fails to build

From pip:

Downloading/unpacking howdoi
Running setup.py egg_info for package howdoi

Requirement already satisfied (use --upgrade to upgrade): pyquery in /usr/local/lib/python2.7/site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): pygments in /usr/local/lib/python2.7/site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/site-packages (from howdoi)
Requirement already satisfied (use --upgrade to upgrade): requests-cache in /usr/local/lib/python2.7/site-packages (from howdoi)
Downloading/unpacking lxml>=2.1 (from pyquery->howdoi)
Running setup.py egg_info for package lxml
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.2.3.
Building without Cython.
Using build configuration of libxslt 1.1.26

warning: no files found matching '*.txt' under directory 'src/lxml/tests'

Downloading/unpacking cssselect (from pyquery->howdoi)
Running setup.py egg_info for package cssselect

no previously-included directories found matching 'docs/_build'

Installing collected packages: howdoi, lxml, cssselect
Running setup.py install for howdoi

Installing howdoi script to /usr/local/bin

Running setup.py install for lxml
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.2.3.
Building without Cython.
Using build configuration of libxslt 1.1.26
building 'lxml.etree' extension
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-build-johanndiedrick/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.7-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace
clang: warning: argument unused during compilation: '-flat_namespace'
In file included from src/lxml/lxml.etree.c:16:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
Complete output from command /usr/local/opt/python/bin/python2.7 -c "import setuptools;file='/private/var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-build-johanndiedrick/lxml/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-3NZjzY-record/install-record.txt --single-version-externally-managed:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

Building lxml version 3.2.3.

Building without Cython.

Using build configuration of libxslt 1.1.26

running install

running build

running build_py

copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.7-x86_64-2.7/lxml/includes

running build_ext

building 'lxml.etree' extension

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -I/private/var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-build-johanndiedrick/lxml/src/lxml/includes -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.7-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace

clang: warning: argument unused during compilation: '-flat_namespace'

In file included from src/lxml/lxml.etree.c:16:

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:10: fatal error: 'stdio.h' file not found

include <stdio.h>

     ^

1 error generated.

error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1


Command /usr/local/opt/python/bin/python2.7 -c "import setuptools;file='/private/var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-build-johanndiedrick/lxml/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-3NZjzY-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/lm/5bkc7gl14t37_2bx2q2b4qc40000gn/T/pip-build-johanndiedrick/lxml
Storing complete log in /Users/johanndiedrick/.pip/pip.log

Linking in /usr/local/bin fails for me, not others

Here’s what happens when I brew-install howdoi in bash:

/usr/local/Cellar > brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb
######################################################################## 100.0%
==> Downloading http://pypi.python.org/packages/source/h/howdoi/howdoi-0.2.tar.g
Already downloaded: /Library/Caches/Homebrew/howdoi-0.2.tar.gz
==> python setup.py install
/usr/local/Cellar/howdoi/0.2: 2 files, 8.0K, built in 2 seconds

However, no link is placed in /usr/local/bin. So then I try:

/usr/local/Cellar > brew link howdoi
Warning: Already linked: /usr/local/Cellar/howdoi/0.2

…and there's still no link. I brew-installed tree and it linked fine. I checked with an associate and he was able to install howdoi and have a link appear in /usr/local/bin even though his ownership and write permissions appear to match mine.

I did a brew cleanup and a howdoi uninstall before trying again. Same results.

I’m able to use howdoi through a $PATH amendment to include /usr/local/share/python/, but the lack of linking seems like a bug of some sort. I’m just not sure what sort.

Problem with Python3.2

According to PKG-INFO Python3.2 is supported, but it does not actually work:

File "howdoi.py", line 30
ANSWER_HEADER = u'--- Answer {0} ---\n{1}'
^
SyntaxError: invalid syntax

I am unsure if the PKG-INFO is incorrect or some change was introduced breakign Python3.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.