https://www.gatsbyjs.org/docs/adding-a-list-of-markdown-blog-posts/
https://codinghero.netlify.com/
個人在學習Linux過程當中的個人筆記,提供個人及有需要的人查閱,若有錯誤歡迎提供指正,謝謝。 This Blog recorded notes about my learning Linux and provides myself and others reference. If there are any incorrect information, welcome to leave a message to correct me, Thanks.
2019年10月23日 星期三
2019年10月22日 星期二
定時排程刪除超過一定天數的檔案
https://softwareengineering.stackexchange.com/questions/149824/automatically-delete-files-after-they-expire
https://superuser.com/questions/1072679/bash-what-does-means
http://linux.vbird.org/linux_basic/0430cron.php
find $search_path -atime +3 -exec rm {} \;
加到crontab裡面
# crontab -e
{}的意思就是find輸出的結果會帶到rm的參數,\;是確保command結束符號,可用+取代
https://superuser.com/questions/1072679/bash-what-does-means
http://linux.vbird.org/linux_basic/0430cron.php
find $search_path -atime +3 -exec rm {} \;
加到crontab裡面
# crontab -e
{}的意思就是find輸出的結果會帶到rm的參數,\;是確保command結束符號,可用+取代
2019年7月24日 星期三
pyenv-win 安裝與移除
https://github.com/pyenv-win/pyenv-win
1. Install
1. Install
pip install pyenv-win --target %USERPROFILE%/.pyenv
2. Add following to PATH enviroment variable
%USERPROFILE%\.pyenv\pyenv-win\bin;%USERPROFILE%\.pyenv\pyenv-win\shims;
3. Add installed path in file easy_install.pth to site-packages folder(ex: C:\Users\Jack_Lin\AppData\Local\Programs\Python\Python37-32\Lib\site-packages).
Need to add absolute path, ex:
C:\Users\Jack_Lin\.pyenv in file easy_install.pth
4. pip list to check pyenv-win is installed and recognize by pip
5. upgrade
pip install --upgrade pyenv-win
6. uninstall
pip uninstall pyenv-win
2019年6月14日 星期五
2019年5月20日 星期一
Scrapy學習筆記
若要整合Django和Scrapy,可利用DjangoItem,可節省定義Item的部分,讓Scrapy的Item定義自動去參照Django model,也可在Item增加欄位。
ItemLoader的部分,預設add_value後,postprocessor都會以list為最後輸出結果,可更感post processor為TakeFirst。
在Pipeline裡,若應用到DjangoItem,要先save後,在以Django model來操作 Foreign Key或是ManyToManyField部分。DjangoItem無法直接取得Django model內容。DjangoItem只是取去參考Django model,省去寫 field_xxx = scrapy.Field()而已。
ItemLoader的部分,預設add_value後,postprocessor都會以list為最後輸出結果,可更感post processor為TakeFirst。
在Pipeline裡,若應用到DjangoItem,要先save後,在以Django model來操作 Foreign Key或是ManyToManyField部分。DjangoItem無法直接取得Django model內容。DjangoItem只是取去參考Django model,省去寫 field_xxx = scrapy.Field()而已。
2019年4月24日 星期三
pandas Dataframe操作
import pandas as pd
df = pd.read_excel('b.xlsx', 'Acceptance')
df[df['Config 3'].notna()]
裡面的df['Config 3'].notna()是filter的方式,結果是列出所有Config13欄位不是na的 rows
Pandas的Series是縱向的,例如某個Column的值的列表
pandas兩個主要的data structure
DataFrame和Series
DataFrame就是Series的容器
Series就是純量的容器
df = pd.read_excel('b.xlsx', 'Acceptance')
df[df['Config 3'].notna()]
裡面的df['Config 3'].notna()是filter的方式,結果是列出所有Config13欄位不是na的 rows
Pandas的Series是縱向的,例如某個Column的值的列表
pandas兩個主要的data structure
DataFrame和Series
DataFrame就是Series的容器
Series就是純量的容器
Indexing / Selection
The basics of indexing are as follows:
Operation | Syntax | Result |
---|---|---|
Select column | df[col] | Series |
Select row by label | df.loc[label] | Series |
Select row by integer location | df.iloc[loc] | Series |
Slice rows | df[5:10] | DataFrame |
Select rows by boolean vector | df[bool_vec] | DataFrame |
如果要一個row一個row去做動作
df.iterrows()
2019年3月26日 星期二
2019年3月7日 星期四
Delopy Django project on Ubuntu 1804 with mod_wsgi
1. Install apache2 & postgresql
2. Install mod_wsgi
# sudo apt install libapache2-mod-wsgi-py3
3. Create a Python3 virtualenv
# mkvirtualenv -p $(which python3) django & psycopg2-binary
(django)# pip install django
(django)# pip install psycopg2-binary
4. Enter into project folder. /home/jack/Documents/Projects/myproject
5. Install Requirement python package
(django) # pip install -r requirements.txt
6. Note that the wsgi.py is put on /home/jack/Documents/Projects/myproject/myproject
7. Edit settings.py in ./myproject
Add ALLOWED_HOSTS = ['*',]
(This is risky)
Add STATIC_ROOT = '/home/jack/Documents/Projects/myproject/static'
8. Setup Postgresql database correctly & create a database in it.
9. Edit settings.py to meet the database you want to use.
10. Database Migrate & collectstatic
(django) # python manage.py migrate
(django) # python manage.py collectstatic
11. create a new conf in /etc/apache2/site-available myproject.conf with sudo
ServerName myproject
Alias /robots.txt /home/jack/Documents/Projects/myproject/static/static/robots.txt
Alias /favicon.ico /home/jack/Documents/Projects/myproject/static/favicon.ico
Alias /static/ /home/jack/Documents/Projects/myproject/static/
Require all granted
WSGIDaemonProcess django python-home=/home/jack/.virtualenvs/django/ python-path=/home/jack/Documents/Projects/myproject/
WSGIScriptAlias / /home/jack/Documents/Projects/myproject/myproject/wsgi.py
WSGIProcessGroup django
Require all granted
Reference:
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
2. Install mod_wsgi
# sudo apt install libapache2-mod-wsgi-py3
3. Create a Python3 virtualenv
# mkvirtualenv -p $(which python3) django & psycopg2-binary
(django)# pip install django
(django)# pip install psycopg2-binary
4. Enter into project folder. /home/jack/Documents/Projects/myproject
5. Install Requirement python package
(django) # pip install -r requirements.txt
6. Note that the wsgi.py is put on /home/jack/Documents/Projects/myproject/myproject
7. Edit settings.py in ./myproject
Add ALLOWED_HOSTS = ['*',]
(This is risky)
Add STATIC_ROOT = '/home/jack/Documents/Projects/myproject/static'
8. Setup Postgresql database correctly & create a database in it.
9. Edit settings.py to meet the database you want to use.
10. Database Migrate & collectstatic
(django) # python manage.py migrate
(django) # python manage.py collectstatic
11. create a new conf in /etc/apache2/site-available myproject.conf with sudo
ServerName myproject
Alias /robots.txt /home/jack/Documents/Projects/myproject/static/static/robots.txt
Alias /favicon.ico /home/jack/Documents/Projects/myproject/static/favicon.ico
Alias /static/ /home/jack/Documents/Projects/myproject/static/
Require all granted
WSGIDaemonProcess django python-home=/home/jack/.virtualenvs/django/ python-path=/home/jack/Documents/Projects/myproject/
WSGIScriptAlias / /home/jack/Documents/Projects/myproject/myproject/wsgi.py
WSGIProcessGroup django
Require all granted
12. Edit /etc/apache2/ports.conf, Add a line
Listen 4002
13. Enable the site & reload
# sudo a2ensite myproject
# sudo systemctl reload apache2
14. Allow port 4002 in Firewall
# sudo ufw allow 4002
Reference:
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
訂閱:
文章 (Atom)