Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting a tip directly from command-line. #99

Open
nixypanda opened this issue Jun 22, 2016 · 2 comments
Open

getting a tip directly from command-line. #99

nixypanda opened this issue Jun 22, 2016 · 2 comments

Comments

@nixypanda
Copy link

Can this be turned into a command-line utility. Something like this.

import json
from pprint import pprint
from sys import argv
from difflib import SequenceMatcher

def similar(a, b):
    return SequenceMatcher(None, a, b).ratio()

if __name__ == '__main__':
    SEARCH = ' '.join(argv[1:])
    DATA = None

    with open('tips.json') as data_file:
        DATA = json.load(data_file)

    MAX = max(DATA, key=lambda x: similar(SEARCH.lower(), x['title'].lower()))
    print(MAX)

Maybe if we get a better string similarity heuristic it would be better something like FuzzyWuzzy. Kindly share your thoughts on it.

@hemanth
Copy link
Contributor

hemanth commented Jun 23, 2016

Feel free to do a PR.

@jdhitsolutions
Copy link

For PowerShell use this is pretty easy to put together into a simple function. http://jdhitsolutions.com/blog/powershell/5121/friday-fun-find-a-git-tip-with-powershell/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants