Skip to content

Commit

Permalink
Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Mar 10, 2024
1 parent cc9bb91 commit fac95bf
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 34 deletions.
38 changes: 19 additions & 19 deletions p/14/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,30 @@ <h2>函数列表和文件模糊搜索</h2>
</ul>
<div class="highlight highlight-source-viml"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>Lf_ShortcutF</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>&lt;c-p&gt;<span class="pl-pds">'</span></span><span class="pl-c"> <span class="pl-c">"</span> Ctrl + p 打开文件搜索</span>
<span class="pl-k">noremap</span> <span class="pl-ent"><span class="pl-e">&lt;c-n&gt;</span></span> <span class="pl-s">:LeaderfMru<span class="pl-e">&lt;cr&gt;</span> " Ctrl + n 打开MRU文件列表</span>
<span class="pl-s">noremap <span class="pl-e">&lt;m-p&gt;</span> :LeaderfFunction<span class="pl-e">&lt;cr&gt;</span> " Alt + p 打开函数列表</span></pre></div>
<span class="pl-s"></span><span class="pl-k">noremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-p&gt;</span></span> <span class="pl-s">:LeaderfFunction<span class="pl-e">&lt;cr&gt;</span> " Alt + p 打开函数列表</span></pre></div>
<h2>预览文件</h2>
<ul>
<li>使用插件 <a href="https://github.com/skywind3000/vim-preview">vim-preview</a></li>
<li>关闭预览窗口的快捷键是 <code class="notranslate">Ctrl + w z</code></li>
<li>设置其他快捷键</li>
</ul>
<div class="highlight highlight-source-viml"><pre class="notranslate"><span class="pl-k">noremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-u&gt;</span></span> <span class="pl-s">:PreviewScroll -1<span class="pl-e">&lt;cr&gt;</span> " Alt + u 往上滚动预览窗口</span>
<span class="pl-s">noremap <span class="pl-e">&lt;m-d&gt;</span> :PreviewScroll +1<span class="pl-e">&lt;cr&gt;</span> " Alt + d 往下滚动预览窗口</span>
<span class="pl-s">inoremap <span class="pl-e">&lt;m-u&gt;</span> <span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewScroll -1<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s">inoremap <span class="pl-e">&lt;m-d&gt;</span> <span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewScroll +1<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s">" 在quickfix窗口按 p 打开预览窗口(配合 grepper 插件很实用)</span>
<span class="pl-s">autocmd FileType qf nnoremap <span class="pl-e">&lt;silent&gt;&lt;buffer&gt;</span> p :PreviewQuickfix<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s">autocmd FileType qf nnoremap <span class="pl-e">&lt;silent&gt;&lt;buffer&gt;</span> P :PreviewClose<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s">noremap <span class="pl-e">&lt;m-n&gt;</span> :PreviewSignature!<span class="pl-e">&lt;cr&gt;</span> " Alt + n 提示函数声明</span>
<span class="pl-s">inoremap <span class="pl-e">&lt;m-n&gt;</span> <span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewSignature!<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s">noremap <span class="pl-e">&lt;leader&gt;</span>g :PreviewTag<span class="pl-e">&lt;cr&gt;</span> " leader + g " 打开单词tag的预览窗口</span></pre></div>
<span class="pl-s"></span><span class="pl-k">noremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-d&gt;</span></span> <span class="pl-s">:PreviewScroll +1<span class="pl-e">&lt;cr&gt;</span> " Alt + d 往下滚动预览窗口</span>
<span class="pl-s"></span><span class="pl-k">inoremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-u&gt;</span></span> <span class="pl-s"><span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewScroll -1<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s"></span><span class="pl-k">inoremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-d&gt;</span></span> <span class="pl-s"><span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewScroll +1<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s"></span><span class="pl-c"><span class="pl-c">"</span> 在quickfix窗口按 p 打开预览窗口(配合 grepper 插件很实用)</span>
<span class="pl-k">autocmd</span> <span class="pl-c1">FileType</span> <span class="pl-s">qf</span> <span class="pl-k">nnoremap</span> <span class="pl-k">&lt;silent&gt;</span><span class="pl-s"><span class="pl-e">&lt;buffer&gt;</span> p :PreviewQuickfix<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s"></span><span class="pl-k">autocmd</span> <span class="pl-c1">FileType</span> <span class="pl-s">qf</span> <span class="pl-k">nnoremap</span> <span class="pl-k">&lt;silent&gt;</span><span class="pl-s"><span class="pl-e">&lt;buffer&gt;</span> P :PreviewClose<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s"></span><span class="pl-k">noremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-n&gt;</span></span> <span class="pl-s">:PreviewSignature!<span class="pl-e">&lt;cr&gt;</span> " Alt + n 提示函数声明</span>
<span class="pl-s"></span><span class="pl-k">inoremap</span> <span class="pl-ent"><span class="pl-e">&lt;m-n&gt;</span></span> <span class="pl-s"><span class="pl-e">&lt;c-\&gt;&lt;c-o&gt;</span>:PreviewSignature!<span class="pl-e">&lt;cr&gt;</span></span>
<span class="pl-s"></span><span class="pl-k">noremap</span> <span class="pl-k">&lt;leader&gt;</span><span class="pl-s">g :PreviewTag<span class="pl-e">&lt;cr&gt;</span> " leader + g " 打开单词tag的预览窗口</span></pre></div>
<h2>输入提示</h2>
<ul>
<li>ycm 太卡,neovim 异步配置没起效果,平时也用不上语法补全,还是选用了 <a href="https://github.com/roxma/nvim-completion-manager">roxma/nvim-completion-manager</a></li>
<li>配置 <code class="notranslate">tab</code><code class="notranslate">shift + tab</code> 选中候选项</li>
</ul>
<div class="highlight highlight-source-viml"><pre class="notranslate"><span class="pl-k">inoremap</span> <span class="pl-k">&lt;expr&gt;</span> <span class="pl-ent"><span class="pl-e">&lt;Tab&gt;</span></span> <span class="pl-s">pumvisible() ? "\<span class="pl-e">&lt;C-n&gt;</span>" : "\<span class="pl-e">&lt;Tab&gt;</span>"</span>
<span class="pl-s">inoremap <span class="pl-e">&lt;expr&gt;</span> <span class="pl-e">&lt;S-Tab&gt;</span> pumvisible() ? "\<span class="pl-e">&lt;C-p&gt;</span>" : "\<span class="pl-e">&lt;S-Tab&gt;</span>"</span></pre></div>
<span class="pl-s"></span><span class="pl-k">inoremap</span> <span class="pl-k">&lt;expr&gt;</span> <span class="pl-ent"><span class="pl-e">&lt;S-Tab&gt;</span></span> <span class="pl-s">pumvisible() ? "\<span class="pl-e">&lt;C-p&gt;</span>" : "\<span class="pl-e">&lt;S-Tab&gt;</span>"</span></pre></div>
<h2>全局搜索</h2>
<ul>
<li>选用 <a href="https://github.com/mhinz/vim-grepper">mhinz/vim-grepper</a> 插件,没有选用 ack 的原因是,ack 没配置搜索选中字符的功能。</li>
Expand All @@ -116,14 +116,14 @@ <h2>全局搜索</h2>
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>root_dir</span> <span class="pl-k">=</span> <span class="pl-en">FindProjectRoot</span>(<span class="pl-s"><span class="pl-pds">'</span>.git<span class="pl-pds">'</span></span>)<span class="pl-c"> <span class="pl-c">"</span> 搜索 .git 为项目路径</span>
<span class="pl-k">autocmd</span> <span class="pl-c1">BufEnter</span> <span class="pl-s">*</span> <span class="pl-c1">silent</span><span class="pl-k">!</span> <span class="pl-c1">lcd</span> <span class="pl-smi"><span class="pl-k">g:</span>root_dir</span><span class="pl-c"> <span class="pl-c">"</span> 设置当前路径为项目路径</span>
<span class="pl-k">nmap</span> <span class="pl-ent">gs</span> <span class="pl-s"><span class="pl-e">&lt;plug&gt;</span>(GrepperOperator) " 选择字符后按 g + s 开始搜索(异步的)</span>
<span class="pl-s">xmap gs <span class="pl-e">&lt;plug&gt;</span>(GrepperOperator)</span>
<span class="pl-s">let g:grepper = {}</span>
<span class="pl-s">let g:grepper.ag = {}</span>
<span class="pl-s">let g:grepper.ag.grepprg = 'ag --vimgrep $* '.g:root_dir " 设置 ag 参数</span>
<span class="pl-s">let g:qfenter_keymap = {}</span>
<span class="pl-s">let g:qfenter_keymap.vopen = ['<span class="pl-e">&lt;C-v&gt;</span>'] " Ctrl + v 纵向分屏打开</span>
<span class="pl-s">let g:qfenter_keymap.hopen = ['<span class="pl-e">&lt;C-CR&gt;</span>', '<span class="pl-e">&lt;C-s&gt;</span>', '<span class="pl-e">&lt;C-x&gt;</span>'] " Enter 横向分屏打开</span>
<span class="pl-s">let g:qfenter_keymap.topen = ['t'] " 按 t 在新的标签页打开</span></pre></div>
<span class="pl-s"></span><span class="pl-k">xmap</span> <span class="pl-ent">gs</span> <span class="pl-s"><span class="pl-e">&lt;plug&gt;</span>(GrepperOperator)</span>
<span class="pl-s"></span><span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>grepper</span> <span class="pl-k">=</span> {}
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>grepper</span>.ag <span class="pl-k">=</span> {}
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>grepper</span>.ag.<span class="pl-c1">grepprg</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>ag --vimgrep $* <span class="pl-pds">'</span></span>.<span class="pl-smi"><span class="pl-k">g:</span>root_dir</span><span class="pl-c"> <span class="pl-c">"</span> 设置 ag 参数</span>
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>qfenter_keymap</span> <span class="pl-k">=</span> {}
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>qfenter_keymap</span>.vopen <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">'</span>&lt;C-v&gt;<span class="pl-pds">'</span></span>]<span class="pl-c"> <span class="pl-c">"</span> Ctrl + v 纵向分屏打开</span>
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>qfenter_keymap</span>.hopen <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">'</span>&lt;C-CR&gt;<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>&lt;C-s&gt;<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>&lt;C-x&gt;<span class="pl-pds">'</span></span>]<span class="pl-c"> <span class="pl-c">"</span> Enter 横向分屏打开</span>
<span class="pl-k">let</span> <span class="pl-smi"><span class="pl-k">g:</span>qfenter_keymap</span>.topen <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">'</span>t<span class="pl-pds">'</span></span>]<span class="pl-c"> <span class="pl-c">"</span> 按 t 在新的标签页打开</span></pre></div>
<h2>最后</h2>
<ul>
<li>查哪个插件启动慢的命令 <code class="notranslate">vim --startuptime /tmp/vim.log a.c</code></li>
Expand Down
4 changes: 2 additions & 2 deletions p/27/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ <h3>如何正确的退出服务?</h3>
skynet.<span class="pl-c1">ret</span>()
skynet.<span class="pl-c1">exit</span>()
<span class="pl-c"><span class="pl-c">--</span> exit() 之后的代码是不会执行的</span>
end</pre></div>
<span class="pl-k">end</span></pre></div>
<h3>负载均衡?</h3>
<p>用数组 <code class="notranslate">slave</code> 把服务的地址存起来,然后在每调用一次计算接口 <code class="notranslate">calculate</code> 就换下一个服务。</p>
<div class="highlight highlight-source-lua"><pre class="notranslate"><span class="pl-k">local</span> slave <span class="pl-k">=</span> {}
<span class="pl-k">local</span> balance <span class="pl-k">=</span> <span class="pl-c1">1</span>

<span class="pl-c"><span class="pl-c">--</span> 找一个 slave 帮忙做点复杂的计算</span>
function CMD.<span class="pl-c1">calculate</span>(a, b)
<span class="pl-k">function</span> <span class="pl-en">CMD.calculate</span>(<span class="pl-smi">a</span>, <span class="pl-smi">b</span>)
<span class="pl-k">local</span> s <span class="pl-k">=</span> slave[balance]
balance <span class="pl-k">=</span> balance <span class="pl-k">+</span> <span class="pl-c1">1</span>
<span class="pl-k">if</span> balance <span class="pl-k">&gt;</span> <span class="pl-k">#</span>slave <span class="pl-k">then</span>
Expand Down
4 changes: 2 additions & 2 deletions p/37/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<p>每个账号最新记录的版本号,采用 openresty 的 shared.DICT 存在内存中。每次有数据变化后,把版本加一。<br>
用心跳去检查各个客户端的数据版本号是否已过期,过期则更新版本号再推送数据。</p>
<div class="highlight highlight-source-lua"><pre class="notranslate"> <span class="pl-c"><span class="pl-c">--</span> update data version id</span>
local clip_change <span class="pl-k">=</span> ngx.<span class="pl-smi">shared</span>.<span class="pl-smi">clip_change</span>
<span class="pl-k">local</span> clip_change <span class="pl-k">=</span> ngx.<span class="pl-smi">shared</span>.<span class="pl-smi">clip_change</span>
<span class="pl-k">local</span> vid <span class="pl-k">=</span> clip_change:<span class="pl-c1">incr</span>(<span class="pl-c1">self</span>.<span class="pl-smi">uid</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>)
<span class="pl-c1">self</span>.<span class="pl-smi">vid</span> <span class="pl-k">=</span> vi</pre></div>
<p>使用 shared.DICT 而不是使用 lua-resty-lru 的原因是:这个数据需要在各个工作进程中共享, 因为不同的客户端连接的可能不是同一个进程。</p>
Expand Down Expand Up @@ -158,7 +158,7 @@
<span class="pl-k">local</span> fname <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>cacert.pem<span class="pl-pds">'</span></span>

<span class="pl-c"><span class="pl-c">--</span> 判断文件是否存在</span>
function _M.<span class="pl-c1">file_exists</span>(name)
<span class="pl-k">function</span> <span class="pl-en">_M.file_exists</span>(<span class="pl-smi">name</span>)
<span class="pl-k">local</span> f <span class="pl-k">=</span> <span class="pl-c1">io.open</span>(name, <span class="pl-s"><span class="pl-pds">'</span>r<span class="pl-pds">'</span></span>)
<span class="pl-k">if</span> f <span class="pl-k">~=</span> <span class="pl-c1">nil</span> <span class="pl-k">then</span>
<span class="pl-c1">io.close</span>(f)
Expand Down
4 changes: 2 additions & 2 deletions p/45/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</blockquote>
<p>这里我们根据行动目标的不同,把这个技能拆分两个操作。第一个操作是随机找到敌方2个英雄,第二个是对自己操作。伪代码如下:</p>
<div class="highlight highlight-source-lua"><pre class="notranslate"><span class="pl-c"><span class="pl-c">--</span> 随机 2 名敌方单位造成 90% 伤害</span>
local targets <span class="pl-k">=</span> <span class="pl-c1">random_target</span>(heros, OTHER_SIDE, <span class="pl-c1">2</span>)
<span class="pl-k">local</span> targets <span class="pl-k">=</span> <span class="pl-c1">random_target</span>(heros, OTHER_SIDE, <span class="pl-c1">2</span>)
<span class="pl-k">for</span> target <span class="pl-k">in</span> <span class="pl-c1">pairs</span>(targets) <span class="pl-k">do</span>
<span class="pl-k">local</span> hurt <span class="pl-k">=</span> <span class="pl-c1">0.9</span> <span class="pl-k">*</span> my.<span class="pl-smi">attr</span>.<span class="pl-smi">hurt</span>
target.<span class="pl-smi">attr</span>.<span class="pl-smi">hp</span> <span class="pl-k">=</span> target.<span class="pl-smi">attr</span>.<span class="pl-smi">hp</span> <span class="pl-k">-</span> hurt
Expand All @@ -59,7 +59,7 @@
my.<span class="pl-smi">attr</span>.<span class="pl-smi">hurt</span> <span class="pl-k">=</span> my.<span class="pl-smi">attr</span>.<span class="pl-smi">hurt</span> <span class="pl-k">*</span> <span class="pl-c1">1.15</span></pre></div>
<p>直接这样把代码写死的话,需求变化,代码就需要频繁的变。所有我们要抽出不变的东西写成代码,把变化的东西做成配置 Excel 表格。不变的是什么呢?行动流程是不变的,可以这样写行动流程:</p>
<div class="highlight highlight-source-lua"><pre class="notranslate"><span class="pl-c"><span class="pl-c">--</span> 每回合的逻辑</span>
for round<span class="pl-k">=</span><span class="pl-c1">1</span>,cfg.<span class="pl-smi">MAX_ROUND</span> <span class="pl-k">do</span>
<span class="pl-k">for</span> round<span class="pl-k">=</span><span class="pl-c1">1</span>,cfg.<span class="pl-smi">MAX_ROUND</span> <span class="pl-k">do</span>
<span class="pl-c"><span class="pl-c">--</span> 每个英雄轮流出手</span>
<span class="pl-k">for</span> heros <span class="pl-k">in</span> <span class="pl-c1">ipairs</span>(heros) <span class="pl-k">do</span>
<span class="pl-c"><span class="pl-c">--</span> 1. 处理行动前状态</span>
Expand Down
2 changes: 1 addition & 1 deletion p/7/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3>2. 最后采用了 GTK+ 的 dialog 实现</h3>
<li>设置 dialog 失去焦点时就销毁</li>
</ul>
<div class="highlight highlight-source-c++"><pre class="notranslate"><span class="pl-c"><span class="pl-c">//</span> desoty dialog when lost focus</span>
static <span class="pl-k">void</span> <span class="pl-en">dialogFocusOutCallback</span>(GtkWidget* widget, gpointer user_data)
<span class="pl-k">static</span> <span class="pl-k">void</span> <span class="pl-en">dialogFocusOutCallback</span>(GtkWidget* widget, gpointer user_data)
{
<span class="pl-c1">gtk_widget_destroy</span>(widget);
}
Expand Down
5 changes: 3 additions & 2 deletions p/76/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
<li>然后退出 virtual box</li>
<li>然后用管理员模式打开 cmd 窗口,执行下面的命令</li>
</ul>
<div class="highlight highlight-text-adblock"><pre class="notranslate">cd "c:\Program Files\Oracle\VirtualBox"
<pre lang="txt" class="notranslate"><code class="notranslate">cd "c:\Program Files\Oracle\VirtualBox"
VBoxManage modifyvm "macosx" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "macosx" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "macosx" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macosx" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "macosx" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macosx" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1</pre></div>
VBoxManage setextradata "macosx" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
</code></pre>
<p>再打开 virtual box ,启动进入,进入到语言选择界面就基本没环境问题了。</p>
<p>使用磁盘工具,把 100 G 的磁盘格式化,名称自行设置,[格式]设置为[Mac OS扩展(日志式)],方案为[GUID分区图],点击[抹掉]。</p>
<p>可以参考这个教程: <a href="https://zhuanlan.zhihu.com/p/337036027" rel="nofollow">https://zhuanlan.zhihu.com/p/337036027</a></p>
Expand Down
Loading

0 comments on commit fac95bf

Please sign in to comment.