From 3e5641470afd3c1aea6273c47bc6fb9c326a8d79 Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:16:05 -0700 Subject: [PATCH 1/8] FIx srv.bin to work -- listens on 0.0.0.0 --- bin/srv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index e55fb46..ce646aa 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -6,7 +6,7 @@ Main server program. """ from __future__ import print_function -from gevent.wsgi import WSGIServer +from gevent.pywsgi import WSGIServer from gevent.monkey import patch_all patch_all() @@ -204,5 +204,5 @@ def answer(topic=None): return result return Response(result, mimetype='text/plain') -SRV = WSGIServer(("", 8002), app) # log=None) +SRV = WSGIServer(("0.0.0.0", 8002), app) # log=None) SRV.serve_forever() From 2a56f02751a6327171b4aa65f47c744f0ed20a5a Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:16:31 -0700 Subject: [PATCH 2/8] adapter_learnxiny updated to not use hardcoded path --- lib/adapter_learnxiny.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/adapter_learnxiny.py b/lib/adapter_learnxiny.py index 3fc459b..bcc38a7 100644 --- a/lib/adapter_learnxiny.py +++ b/lib/adapter_learnxiny.py @@ -5,6 +5,7 @@ from __future__ import print_function import os import re +from globals import MYDIR class LearnXYAdapter(object): @@ -12,7 +13,7 @@ class LearnXYAdapter(object): Parent class of all languages adapters """ - _learn_xy_path = "/home/igor/git/github.com/adambard/learnxinyminutes-docs" + _learn_xy_path = os.path.join(MYDIR, "cheatsheets/learnxinyminutes-docs") _replace_with = {} _filename = '' prefix = '' From 6862a7a1f95b9bc8875d4dca09f4baa1e7134584 Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:16:51 -0700 Subject: [PATCH 3/8] get_answer.py updated to not use hard coded path --- lib/get_answer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/get_answer.py b/lib/get_answer.py index 9bc129c..c73dfdf 100644 --- a/lib/get_answer.py +++ b/lib/get_answer.py @@ -311,7 +311,7 @@ def _get_answer_for_question(topic): else: topic = [topic] - cmd = ["/home/igor/cheat.sh/bin/get-answer-for-question"] + topic + cmd = [os.path.join(MYDIR, "bin/get-answer-for-question")] + topic proc = Popen(cmd, stdout=PIPE, stderr=PIPE) answer = proc.communicate()[0].decode('utf-8') return answer From fe5046d481f9a9c84fa19379b8e9b6c4947b2e7a Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:17:11 -0700 Subject: [PATCH 4/8] Replaced hardcoded paths with something kept local to the cheat.sh folder --- lib/globals.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/globals.py b/lib/globals.py index 5443e09..64c8952 100644 --- a/lib/globals.py +++ b/lib/globals.py @@ -18,10 +18,10 @@ TEMPLATES = os.path.join(MYDIR, 'share/templates') STATIC = os.path.join(MYDIR, 'share/static') PATH_VIM_ENVIRONMENT = os.path.join(MYDIR, 'share/vim') -PATH_TLDR_PAGES = "/home/igor/.tldr/cache/pages/*/*.md" -PATH_CHEAT_PAGES = "/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/*" -PATH_CHEAT_SHEETS = "/home/igor/cheat.sheets/sheets/" -PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/" +PATH_TLDR_PAGES = os.path.join(MYDIR, "cheatsheets/tldr/*/*.md") +PATH_CHEAT_PAGES = os.path.join(MYDIR, "cheatsheets/cheat/*") +PATH_CHEAT_SHEETS = os.path.join(MYDIR, "cheatsheets/sheets/") +PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/") COLOR_STYLES = sorted(list(get_all_styles())) From 65cf18ca95ab62ada1712b7c4eb3cd82ff15ce6b Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:17:21 -0700 Subject: [PATCH 5/8] panela_colors not using hardcoded path --- lib/panela/panela_colors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/panela/panela_colors.py b/lib/panela/panela_colors.py index 4c1eaa2..ad5cd76 100644 --- a/lib/panela/panela_colors.py +++ b/lib/panela/panela_colors.py @@ -3,6 +3,7 @@ import sys import colored import itertools +from globals import MYDIR """ @@ -632,8 +633,9 @@ class Template(object): def main(): "Only for experiments" + pagepath = os.join.path(MYDIR, "share/firstpage-v2.pnl") template = Template() - template.read("/home/igor/cheat.sh/share/firstpage-v2.pnl") + template.read(pagepath) template.apply_mask() sys.stdout.write(template.show()) From 9eaf9eaa00711e6930b617c104871eb90ab8ff40 Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:20:50 -0700 Subject: [PATCH 6/8] Less than ideal script to grab cheatsheets from different repos --- get-sheets.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 get-sheets.sh diff --git a/get-sheets.sh b/get-sheets.sh new file mode 100644 index 0000000..7145e54 --- /dev/null +++ b/get-sheets.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +## this doesn't error check, if it breaks and destroys things I'm sorry + +mkdir cheatsheets +cd cheatsheets +mkdir cheat tldr spool +git clone --recursive https://github.com/adambard/learnxinyminutes-docs +git clone --recursive https://github.com/chrisallenlane/cheat cheat-temp +mv cheat-temp/cheat/cheatsheets/* cheat +rm -rf cheat-temp +git clone --recursive http://github.com/tldr-pages/tldr tldr-temp +mv tldr-temp/pages/* tldr +rm -rf tldr-temp +git clone --recursive https://github.com/chubin/cheat.sheets.git +mv cheat.sheets/sheets . \ No newline at end of file From a441c4d7edad7392573280465d462d06ba91bbf7 Mon Sep 17 00:00:00 2001 From: Brandon Lopez Date: Fri, 27 Jul 2018 16:25:49 -0700 Subject: [PATCH 7/8] Added additional requirements --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 4308ef7..4e2da03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,6 @@ fuzzywuzzy redis colored langdetect +cffi +polyglot +colorama \ No newline at end of file From 90c1b97acf008abb3b9658b276535610970742a1 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 29 Jul 2018 22:31:01 +0200 Subject: [PATCH 8/8] Use OS packages --- lib/globals.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/globals.py b/lib/globals.py index 64c8952..4cbcaef 100644 --- a/lib/globals.py +++ b/lib/globals.py @@ -18,10 +18,17 @@ TEMPLATES = os.path.join(MYDIR, 'share/templates') STATIC = os.path.join(MYDIR, 'share/static') PATH_VIM_ENVIRONMENT = os.path.join(MYDIR, 'share/vim') -PATH_TLDR_PAGES = os.path.join(MYDIR, "cheatsheets/tldr/*/*.md") -PATH_CHEAT_PAGES = os.path.join(MYDIR, "cheatsheets/cheat/*") -PATH_CHEAT_SHEETS = os.path.join(MYDIR, "cheatsheets/sheets/") -PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/") +USE_OS_PACKAGES = True # change it False if you pull cheat sheets repositories from GitHub +if USE_OS_PACKAGES: + PATH_TLDR_PAGES = "/home/igor/.tldr/cache/pages/*/*.md" + PATH_CHEAT_PAGES = "/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/*" + PATH_CHEAT_SHEETS = "/home/igor/cheat.sheets/sheets/" + PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/" +else: + PATH_TLDR_PAGES = os.path.join(MYDIR, "cheatsheets/tldr/*/*.md") + PATH_CHEAT_PAGES = os.path.join(MYDIR, "cheatsheets/cheat/*") + PATH_CHEAT_SHEETS = os.path.join(MYDIR, "cheatsheets/sheets/") + PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/") COLOR_STYLES = sorted(list(get_all_styles()))