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

strapi v4版本建立与users_permissions联系的注意实现

在strapi v4中最好不要直接建立一个collection与users_permissions的联系。在strapi v4版本中建立了一个逻辑:如果一个用户没有权限对某个collection做'find'操作。那么该用户也无法间接的对该collection做任意操作。

在v4版本的@strapi/utils/lib/sanitize/visitors/remove-restricted-relations.js文件建立了一套逻辑。在所有间接写操作中,如果用户对被写的那个collection 没有'find'权限,那么这个间接写操作,将会被移除。

我们显然不希望用户可以对users_permissions这么重要集合有那么高的读权限。因此,如果我们非要建立一个集合和用户的关系时,可以仅仅保存用户id即可。不需要建立集合的联系。如果是考虑到性能的话,可以再建立一个集合,用来优化。

vim配置

vim的配置对于经常使用的人来说非常重要,针对于个人习惯我们通常都要配置vim。

配置位置

linux下vim配置文件一般是~/.vimrc

window下vim配置文件是C:/Program File X86/Vim/_vimrc

配置编码

配置编码尤其对于windows用户来说非常重要。我们常常需要配置utf-8。常见的配置方法如下:

set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

配置缩进

有时候为了便于编辑我们经常需要配置一个tab转化成几个空格啊这种问题。常见的配置命令如下:

set tabstop=2
set shiftwidth=2
set expandtab

配置undo和备份文件位置

一般情况下,vim会在文件编辑时将生成的备份文件和undo文件放在文件的同一目录位置。但有时候,这个属性会导致很多问题。例如有的系统会对源代码所在文件位置做检索之类和文件名匹配的操作。那些多出来的备份文件和undo文件等就会产生干扰。配置这些文件的位置命令如下:

set backupdir=~/.vimbackup
set undodir=~/.vimundo

这两个命令会把相应文件存放在~/.vimbackup和~/.vimundo下。要注意,这两个目录需要存在,否则就会无效。

windows下推荐的配置文件

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

vim的插件可以给vim添加很多新功能

以下这篇文档描述的非常经典

https://pragmaticpineapple.com/ultimate-vim-typescript-setup/

以下3个插件对于前端开发者很有用

计算几何学中几个典型的问题

多边形直骨架问题 straight skeleton problem

https://github.com/Botffy/polyskel/blob/master/doc/StraightSkeletonImplementation.pdf

凸多边形包围问题 convex hull problem

多边形相互关系问题

monotone 在曲线中的概念

在很多计算几何学的问题或者几何引擎的应用中都会monotone curve的概念。直接翻译成中文可以是“单调曲线”。但这样翻译有时候经常会误导九年义务教育的中国学者。这里的"单调"不是指的“单调递增”或者“单调递减”。"monotone curve"相关的定义可以参照下面的几句话:

A smooth plane curve containing no special points will be called a curve with monotone curvature, or a monotone curve. 来自这里

A continuous curve C in R 2 is called x-monotone, if every vertical line intersects it at a single point at most. 来自这里

2d arrangements 问题

对于一个空间内的所有的几何对象最安排和整理的算法。其基本思想是给一个空间内插入很多几何对象。例如点,曲线等。然后2d arrangements的算法就是用一套规则来安排整理和管理这些几何对象。这些安排的机制包括:

  1. 把所有非x-monotone的曲线分割成x-monotone的曲线线段
  2. 把所有互相相交的曲线都相互分割
  3. 给每一段曲线建立halfEdge机制
  4. 建立顶点和边,边与边,边与面,面与顶点等的关联关系

建立好这些数据结构或机制以后,基于这个几何安排,我们就可以做基于几何元素的各种检索应用,或者像可视性判断等基于几何性质的应用。

Delaunay triangulation 和Voronoi diagram的问题

Delaunay triangulationvoronoi diagram是一组点集成对存在两个图。其中简单地说delaunay triangulation是一种对点集做三角化的运算,这种三角化的运算能够最大化三角形集合中的最小夹角。而voronoi diagram能够根据点集对空间进行一次分割。每个点所确定的一块区域内所有的点到该点的距离比到其他任何一个点的距离都近。