docker-desktop所占的空间移动到D盘

Docker Desktop now can use WSL 2 Backend. In this mode, you need to move the wsl data.

In my case (Windows10 with Docker Desktop) none of the above solutions helped me, but I found the solution; run these commands.

This command changes the docker directory to drive D: (don't forget to quit docker desktop first)

wsl --shutdown
wsl --export docker-desktop-data docker-desktop-data.tar
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data D:\docker-new-repo\ docker-desktop-data.tar --version 2

And now you can delete .tar file

There is a very good blog post explaining everything:

https://dev.to/kimcuonthenet/move-docker-desktop-data-distro-out-of-system-drive-4cg2

discourse论坛配置更高的存储空间

Here is what you need to do to allow more than 10mb for attachments upload.

  1. Connect to your server via SSH
  2. Navigate to and edit the .yml config file
cd /var/discourse/
nano containers/app.yml
  1. Scroll down where it says this:
params:
  ## Which Git revision should this container use? (default: tests-passed)
  1. Add upload_size: 20m below this. Be super careful with spaces. It should now look something like this:
params:
  ## Which Git revision should this container use? (default: tests-passed)
  version: tests-passed

  ## Maximum upload size (default: 10m)
  upload_size: 20m
  1. After making changes press Ctrl+X (to exit) and then Y to save
  2. From /var/discourse run:
./launcher rebuild app

Once rebuild is complete, navigate to /admin/site_settings/category/files and change the max attachment size kb to 20480 (20mb) or your desired number. At this point everything should work perfectly, you can go on and test your upload file size.

Cheers.

图论近似算法

结点的连通性

结点的连通性描述了结点直接连接的路劲数量。是对连通性的衡量指标

结点分组运算

给图中所有结点分组,按照连通和独立的条件给结点分组

聚类系数 clustering

图论中,集聚系数(也称群聚系数集群系数)是用来描述一个中的顶点之间结集成团的程度的系数。

图的匹配

对于一个给定的图G=(V,E),这幅图的一个匹配M是图G的一个子图(由原来的图的一部分顶点和一部分边构成的图),其中每两条边都不相邻(没有公共顶点)。在匹配图中,一个顶点连出的边数至多是一条。如果这个顶点连出一条边,就称这个顶点是已匹配的

顶点覆盖问题 Vertex cover

In graph theory, a vertex cover (sometimes node cover) of a graph is a set of vertices that includes at least one endpoint of every edge of the graph.

vim惯用配置

安装vim-plug

vim-plug可以帮助我们安装很多vim插件

安装需要的资源在这里: https://github.com/junegunn/vim-plug。安装vim-plug的本质就是 Download plug.vim and put it in the "autoload" directory.

注意安装完成后,需要给vim的配置文件(.vimrc/_vimrc)增加如下内容:

call plug#begin()
"这中间填入需要安装的插件,具体示例可以参考 https://github.com/junegunn/vim-plug

call plug#end()

安装 coc.nvim

coc.nvim插件是能够提供更好的自动补全功能的vim插件。在安装了vim-plug之后,可以简单的在vim配置文件的plug函数里面插入:

Plug 'neoclide/coc.nvim', {'branch': 'release'}

然后运行 :PlugInstall

安装完成后,要正常使用coc.nvim(否则可能出现能看到自动补全的关键字列表,却无法按回车健应用所选择的项目),还需要给vimrc文件中添加如下的配置:

" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300

" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes

" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1):
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>

function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')

" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup mygroup
  autocmd!
  " Setup formatexpr specified filetype(s).
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  " Update signature help on jump placeholder.
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac  <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf  <Plug>(coc-fix-current)

" Run the Code Lens action on the current line.
nmap <leader>cl  <Plug>(coc-codelens-action)

" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)

" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
  nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif

" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)

" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')

" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call     CocAction('fold', <f-args>)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocActionAsync('runCommand', 'editor.action.organizeImport')

" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a  :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e  :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s  :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j  :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k  :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p  :<C-u>CocListResume<CR>

安装 coc-tsserver

如果要些typescript代码。这个是coc体系下的插件,此插件能够更好的应用typescript的类型检错功能。

安装的时候,只需要在vim下运行 :CocInstall coc-tsserver

主要参考文献: https://pragmaticpineapple.com/ultimate-vim-typescript-setup/

安装js, ts, graph-ql等插件

在vimrc的plug函数里添加如下内容,并运行 :PlugInstall

Plug 'pangloss/vim-javascript'    " JavaScript support
Plug 'leafgarland/typescript-vim' " TypeScript syntax
Plug 'maxmellon/vim-jsx-pretty'   " JS and JSX syntax
Plug 'jparise/vim-graphql'        " GraphQL syntax

这些插件的主要价值是提供相应语言的语法高亮,自动缩进等功能。

安装 :CocInstall coc-json

支持对选中的json字符串美化

合理的配置颜色

在前面所有的配置完成后,有时候vim中的弹窗,各种高亮的颜色等搭配得并不让人舒服。我这里整理了自己的一套比较舒服的颜色配置。以下配置也是需要加入到vimrc文件中去的:

colorscheme pablo
highlight Pmenu guibg=lightgray gui=bold ctermbg=lightgray

如果想对弹窗的更多内容进行配置可以考虑以下项目:

hi Pmenu
hi PmenuSbar
hi PmenuSel
hi PmenuThumb

https://www.reddit.com/r/vim/comments/8ijdiu/configuring_pmenu/

颜色列表: https://codeyarns.com/tech/2011-07-29-vim-chart-of-color-names.html#gsc.tab=0

配置Pmenu的相关规则说明: https://stackoverflow.com/questions/21370243/change-the-color-of-autocomplpop

配置编码,缓存文件的存放位置,行号码等

set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set tabstop=2
set expandtab
set shiftwidth=2
set backupdir=~/.vimbackup//,/var/tmp//,/tmp//,.
set undodir=~/.vimundo
set directory=~/.vimswp
set number

以下给出所有的vimrc(vim 8.2)配置示例:

" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim

" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
  set diffexpr=MyDiff()
endif
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set tabstop=2
set expandtab
set shiftwidth=2
set backupdir=~/.vimbackup//,/var/tmp//,/tmp//,.
set undodir=~/.vimundo
set directory=~/.vimswp
let g:javascript_plugin_jsdoc=1
set number
colorscheme pablo
highlight Pmenu guibg=lightgray gui=bold ctermbg=lightgray


call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'

" Make sure you use single quotes

Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'pangloss/vim-javascript'    " JavaScript support
Plug 'leafgarland/typescript-vim' " TypeScript syntax
Plug 'maxmellon/vim-jsx-pretty'   " JS and JSX syntax
Plug 'jparise/vim-graphql'        " GraphQL syntax

" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:
"   filetype indent off   " Disable file-type-specific indentation
"   syntax off            " Disable syntax highlighting




" config for coc
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300

" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes

" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1):
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"

" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>

function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')

" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup mygroup
  autocmd!
  " Setup formatexpr specified filetype(s).
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  " Update signature help on jump placeholder.
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac  <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf  <Plug>(coc-fix-current)

" Run the Code Lens action on the current line.
nmap <leader>cl  <Plug>(coc-codelens-action)

" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)

" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
  nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif

" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)

" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')

" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call     CocAction('fold', <f-args>)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocActionAsync('runCommand', 'editor.action.organizeImport')

" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a  :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e  :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s  :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j  :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k  :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p  :<C-u>CocListResume<CR>

实体建模和表面建模

     当一提到计算机cad,作为一个工科出身的来说,首先想到的是solidworks,UG,proE,inventor,freecad,OpenSCAD等等。但是一个艺术学生,它首先想到的可能是maya,zbrush,blender等等。有时候我想对cad软件做分类的时候,总觉得要从使用人群上来分类。可是我又感觉这两种cad在结构机制上又有很大不同。今天详细查了一下,终于解决了自己的这个疑惑。
     所有的3D cad软件从机制上来说其实可以分三类:实体建模(Solid Modeling),表面建模(Surface  Modeling),和实体建模+表面建模。就是说实际上建模方式只有两种:实体建模和表面建模。工程师用的软件偏向于实体建模,而艺术生用的软件偏向于表面建模。
    实体建模的工具方式有三种:扫掠,立体布尔运算和表面围成。扫掠通常指的是将一个平面沿着一条指定曲线做扫掠操作,然后这个平面扫过的空间就成为了目标固体。布尔运算是对两个固体来求和,求差或者求交。表面围成的方法是指通过几个特殊的表面来生成固体,这些表面必须能够围住一个封闭的空间。
     而表面建模可以用一句话概括:添加或者修改点,让这些点能够约束一个表面。表面建模只关注表面的外形,不关注这些表面是否能够围成一个封闭的空间。表面建模的整个过程都像做一个泥娃娃,你可以给它添加泥巴,也可以拿下一些泥巴,还可以捏这些泥巴。而maya这些软件就是给你提供各种工具来玩这个泥娃娃。同样布尔操作也可以用在表面建模中,但是形成的意义有所不同。实体建模中的布尔运算是真正的立体求和,求差,求交;而表面模型的布尔操作就像是做不同的表面缝合操作。
     实体模型一定可以生成表面模型,而表面模型不一定能够生成实体模型,因此就有了很多软件专门用来修复表面模型。其实表面模型生成实体模型的过程就是前面提到过实体建模的第三种方法——表面围成法。
     总而言之,实体建模面向的是立体空间,而表面建模面向的是物体表面。

     参考资料:https://www.reddit.com/r/cad/comments/saey4/solid_modeling_vs_surface_modeling/
http://blenderartists.org/forum/showthread.php?118275-CAD-vs-modeling-software-%28explaining-the-differences%29

google浏览器跨域问题的一种可能性

莫名奇妙突然发生的跨域问题

关于跨域的配置,其实无论是nginx还是后台服务器,我们本来都已经配置好了。但在使用过程中,本来1个小时前还一切都好好的,突然怎么跨域问题又出现了呢?经过一系列调研,发现是google浏览器在“搞鬼”。

chrome的HSTS

chrome有一个hsts功能,它会对你访问过的域名做智能的安全登记。如果那边的域名支持https协议,那么等下次你再访问同一个域名时,它就会给你自动将http转化为https请求。在我们实际测试环境中,使用的是http://test.example.com。但如果我访问了https://www.example.com之后,chrome浏览器就会默认的把后面对http://xxx.example.com访问的请求都自动改为https://xxx.example.com了。

解决方案

  1. 打开这个页面 chrome://net-internals/#hsts
  2. 在  "Delete domain security policies" 的项目里,添加example.com, 然后点击“Delete”

参考文献

https://howchoo.com/chrome/stop-chrome-from-automatically-redirecting-https

以字符串长度来归类

import sys
def changdu(a):
    b1 = []
    b2 = []
    b3 = []

    for k in a:
        k1 = len(k)
        if(k1 <= 3):
            b1.append(k)
        elif(k1 <= 10):
            b2.append(k)
        elif(k1 > 10):
            b3.append(k)
    print('字符串长度小于或等于3的有',','.join(b1))
    print('字符串长度小于或等于10的有',','.join(b2))
    print('字符串长度大于10的有',','.join(b3))

  #  print('字符串长度小于或等于3的有',b1,'字符串长度小于或等于10的有',b2,'字符串长度大于10的有',b3)

a = sys.argv[1:]
changdu(a)
~                                              

求一个数字是否是一个平方数

# coding=utf-8
import sys
def pingfang(n):
    result = False
    for k in range(0, n + 1):
        if(n == k**2):
            result =True
            break
    if(result):
        print('这是一个平方数')
    else:
        print('这不是一个平方数')

#取命令行第1号参数。注意,第0号参数就是被执行的文件名。命令行执行示例 python zhishu.py 100,则这里a = '100'
a = sys.argv[1]
#这是做强制类型转化,因为a是字符串类型,而后面的函数只接受自然数为参数。'100' -> 100
a1 = int(a)
#执行函数
zhishuqiuhe(a1)
~                                                                                                                       ~