2021年8月1日 星期日

Bitbucket 無法git push 的解決方法

如果git clone 一份bitbucket repo 下來,

發現要git push code時遭遇權限不足,如以下 : 

```

Unauthorized

fatal: Could not read from remote repository.


Please make sure you have the correct access rights

and the repository exists.

```


原因出在public ssh key 未添加,這裡紀錄一下從windows上加入key的方法: 

2020年6月28日 星期日

[note] 在github/heroku_git上打tag的方式

上commit做版本管理已經是種日常必備如呼吸般的動作。

但是有時候仍會需要做版本紀錄,一個存檔的感覺。

就可以利用打tag 的方式做一個小版本控管。

2020年6月20日 星期六

[Heroku] 重新建立DB schema的方式

在寫Flask操作DB 內容時,常發生一開始設計不足(e.g. 欄位不對,...,etc),需要整個資料庫重新設計大綱時,就必須要常常reset schema。


[Flask] SQLALCHEMY_TRACK_MODIFICATIONS error 處理

在導入postgresql至heroku的同時,使用Flask遭遇以下error:

builtins
.KeyError KeyError: 'SQLALCHEMY_TRACK_MODIFICATIONS'

2020年6月13日 星期六

[heroku][postgresql] postgresql online GUI

很方便的線上GUI介面操作postgresql

但是缺點是只有七天試用 (期待他未來可以免費)
https://heroku-data-explorer.herokuapp.com/#/

[heroku][postgresql] 使用CLI介面清空資料庫table所有資料內容

建立好heroku postgresql之後,
有時候需要直接清空資料庫,但又不想重新建立shema
或者重新migration

這時候就可以透過CLI直接清除資料庫


[note] psycopg2 無法安裝排解

在安裝套件時
sudo pip install psycopg2

安裝遭遇以下log:

    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-dBC6Co/psycopg2/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-dBC6Co/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/tmp/pip-install-dBC6Co/psycopg2/
    Complete output (27 lines):
    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

請直接安裝
sudo pip install psycopg2-binary即可解決





2019年11月21日 星期四

[note][MAC] dyld: Library not loaded 解決方式

在使用tig指令時,遇到以下問題:
----------------------------------
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/tig
  Reason: image not found
Abort trap: 6
----------------------------------

版本: MAC 10.14

透過以下方式可以解決
----------------------------------
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib
----------------------------------

2019年11月12日 星期二

[note] 在heroku平台找不到pytz套件的解決方式

在撰寫slack app時,
使用timezone套件,
----------------
import pytz
----------------
發佈至heroku時,遭遇以下log:
----------------
2019-11-12T16:34:01.371570+00:00 app[web.1]: import pytz
2019-11-12T16:34:01.371634+00:00 app[web.1]: ModuleNotFoundError: No module named 'pytz'
----------------

2019年11月11日 星期一

[note] 解決line bot 重複發送訊息兩次問題

在串接linebot with python

使用slack會發現主動傳訊息會發送兩次的狀況發生。

影響的api有

line_bot_api.push_message()
及
line_bot_api.broadcast()

只要是主動傳訊息的都會發生傳送兩次

那該如何解決呢?


2019年10月21日 星期一

[note] heroku 更改顯示時區 timezone

觀察log時常常發現 heroku 預設時間不是台灣時區

以下是更改時區的command (台灣)

2019年10月8日 星期二

[Note] ImportError: No module named pandas 排除

發現以下error時,代表有使用到pandas模組但是系統找不到此模組。

這裡紀錄在MAC OSX上安裝pandas模組的方法


[note] SyntaxError: Non-ASCII character '\xe8' in file 排除

在寫一些python測試code時,遭遇以下error

SyntaxError: Non-ASCII character '\xe8' in file

這裡記錄一下解決方法


2019年10月5日 星期六

[trouble shooting] brew doctor 命令失敗解決

今天再重新更新MAC OS
發現使用brew doctor 檢查套件是否安裝成功時,出現命令失敗

[note] 如何在HTML網頁檔案之中嵌入github 原始碼

這裡是示範如何在blogger or 一般網頁之中嵌入github source code

[Trouble shooting] AttributeError: 'module' object has no attribute 'time' 解決方式

今天嘗試寫一個python遭遇以下:


 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 95, in <module>
    _startTime = time.time()
AttributeError: 'module' object has no attribute 'time'

明明沒有用到time 模組,為什麼還會出現此訊息呢?


2019年10月2日 星期三

2019年9月30日 星期一

[note] Heroku R10 錯誤解決

在heroku部署計畫之中,

會遇到R10的錯誤

原因出自於:heroku無法指令port
會產生等待過久的timeout發生

因此,需要透過指令系統port來指派(由heroku平台端指派)

假設是node.js可以透過以下

.listen(process.env.PORT || 5000)
如果是python (flask)可以透過以下:
ort = int(os.environ.get("PORT", 5000))
app.run(debug=True, host='0.0.0.0', port=port)

參考:
1. Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
2. Heroku App crashes immediately with R10 and H10 errors


[share] sinatra中文文件

sinatra, 作為一個輕量級的ruby framework。

我認為是相當具有威力的。

只要不是大型網站,或者功能型網站。

其實基本上不需要有 ROR等這麼功能齊全的後端框架來實作。

實現簡單的網頁後端伺服器其實可以透過sinatra這種輕量框架來完成。

中文參考連結: https://ruby-china.org/topics/25648

[note] heroku 部署command


筆記一下建立一個新的app. 並部署在heroku平台的command