add to ~/.zshrc
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unsetproxy="unset ALL_PROXY"
alias ip="curl -i http://httpbin.org/ip"
then restart termainl
# https://docs.djangoproject.com/en/2.0/topics/http/urls/ | |
# django的url正则匹配 | |
from django.urls import path, re_path | |
from . import views | |
urlpatterns = [ | |
path('articles/2003/', views.special_case_2003), |
$ docker pull mongo:3.0.15-wheezy | |
$ docker run --name mongo -itd -p 27017:27017 mongo:3.0.15-wheezy --auth | |
# 增加admin管理账号 | |
$ docker exec -it mongo mongo admin | |
> use admin | |
switched to db admin |
import | |
# 匹配3到6个数字 | |
re.findall('\d{3,6}', words) | |
# 匹配 reservation_grid$ctl06$lnkcancel | |
words= "javascript:__doPostBack('reservation_grid$ctl06$lnkcancel','')" | |
re.findall('\(\'(.*)\',\'',href) | |
-- get now | |
select DATE(NOW()); | |
-- date between | |
WHERE CONVERT(start_date, DATE) => DATE(NOW()) AND CONVERT(end_date, DATE) => DATE(NOW(); | |
-- 7天前 2017-10-25 | |
select convert(NOW(), DATE) - interval 7 day; | |
-- 今天 |
# https://docs.djangoproject.com/en/1.11/topics/migrations/ | |
# which is responsible for applying and unapplying migrations. | |
python manage.py migrate | |
# which is responsible for creating new migrations based on the changes you have made to your model | |
python manage.py makemigrations |
# Mark email as seen | |
mail.uid('store', uid, '+FLAGS', '\SEEN') | |
# Check if a Python list item contains a string inside another string | |
# If you only want to check for the presence of abc in any string in the list, you could try | |
some_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456'] | |
if any("abc" in s for s in some_list): | |
# whatever | |
# If you really want to get all the items containing abc, use | |
matching = [s for s in some_list if "abc" in s] |
# get current dir size! | |
$ du -sh | |
>>> 224M . | |
# get specific file (logs) size! | |
$ du -sh logs | |
>>> 2.7M logs | |
# get disk useage | |
$ df -h |
add to ~/.zshrc
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unsetproxy="unset ALL_PROXY"
alias ip="curl -i http://httpbin.org/ip"
then restart termainl
#include <file> | |
//This variant is used for system header files. It searches for a file named file in a standard list of system directories. | |
#include "file" | |
//This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. You can prepend directories to the list of quote directories with the -iquote option |