├── files ├── CNAME ├── favicon.ico └── images │ ├── home.jpg │ ├── avatar.jpg │ ├── nikola.png │ ├── MiMax-USB-1-AboutPhone.png │ ├── MiMax-USB-8-ChooseMode.png │ ├── git-learning-notes-3parts.png │ ├── git-learning-notes-reset.png │ ├── MiMax-USB-4-5-DebuggingMode.png │ ├── MiMax-USB-3-DeveloperOptions.png │ ├── MiMax-USB-6-7-USBConfigInterface.png │ ├── MiMax-USB-2-UnlockDeveloperOptions.png │ ├── clothoid-approximation-coordinates.jpg │ ├── install-monodevelop-on-ubuntu-cmd.png │ ├── install-monodevelop-on-ubuntu-gui.png │ ├── custom-domain-settings-of-yandex-mail-hostrecords.png │ ├── custom-domain-settings-of-yandex-mail-mailsettings.png │ ├── sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png │ ├── sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png │ ├── alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png │ ├── alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png │ ├── sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png │ ├── sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png │ └── sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png ├── themes └── custom │ └── parent ├── galleries └── demo │ ├── exclude.meta │ ├── tesla2_lg.jpg │ ├── tesla4_lg.jpg │ ├── tesla_tower1_lg.jpg │ ├── tesla_conducts_lg.jpg │ ├── tesla_lightning1_lg.jpg │ ├── tesla_lightning2_lg.jpg │ └── index.txt ├── images ├── illus_001.jpg └── frontispiece.jpg ├── listings └── hello.py ├── pages ├── notes │ ├── index.rst │ ├── tool-tips.rst │ └── 2016-05-2016-07.rst ├── about.rst └── home.rst ├── README.txt ├── posts ├── notepad++-tips.rst ├── visual-studio-auto-formatting-shortcut.rst ├── chong-zhi-ubuntu-deng-lu-mi-ma.rst ├── install-textext-plugin-for-inkscape.rst ├── atom-markdown-settings.rst ├── arc-length-reparameterization.rst ├── org-mode-pdf-export-in-chinese.rst ├── lyx-settins-on-windows.rst ├── atom-latex-settings.rst ├── ijulia-installation-failed.rst ├── clothoid-approximation.rst ├── guan-yu-github-de-si-kao.rst ├── hunger-games-guan-hou-gan.rst ├── install-monodevelop-on-ubuntu.rst ├── xiao-mi-shou-ji-lian-jie-dian-nao.rst ├── mian-fei-yu-ming-you-xiang-xuan-ze.rst ├── matlab-3d-plot.rst ├── custom-domain-settings-of-yandex-mail.rst ├── angle-between-2-vectors.rst ├── charts.txt ├── sagemath-file-exchange-with-windows-via-virtualbox.rst ├── geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan.rst ├── org-mode-learning-notes.rst ├── wrap-angle-to-given-range.rst ├── git-learning-notes.rst ├── build-github-pages-with-cryogen.rst ├── yu-ming-xiang-guan-chang-shi.rst ├── alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji.rst ├── julia-packages.rst ├── org-to-rst-notes.rst ├── interesting-projects-in-google-summer-of-code-2017.rst ├── julia-notes.rst ├── spacemacs-learning-notes.rst ├── A-reStructuredText-Primer.rst ├── build-github-pages-with-nikola.rst └── julia-for-matrix-methods.rst ├── .gitignore ├── templates └── book.tmpl ├── .doit.db.bak └── .doit.db.dir /files/CNAME: -------------------------------------------------------------------------------- 1 | yongchen.org 2 | -------------------------------------------------------------------------------- /themes/custom/parent: -------------------------------------------------------------------------------- 1 | bootstrap3 -------------------------------------------------------------------------------- /galleries/demo/exclude.meta: -------------------------------------------------------------------------------- 1 | tesla2_lg.jpg 2 | -------------------------------------------------------------------------------- /files/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/favicon.ico -------------------------------------------------------------------------------- /files/images/home.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/home.jpg -------------------------------------------------------------------------------- /images/illus_001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/images/illus_001.jpg -------------------------------------------------------------------------------- /files/images/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/avatar.jpg -------------------------------------------------------------------------------- /files/images/nikola.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/nikola.png -------------------------------------------------------------------------------- /images/frontispiece.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/images/frontispiece.jpg -------------------------------------------------------------------------------- /galleries/demo/tesla2_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla2_lg.jpg -------------------------------------------------------------------------------- /galleries/demo/tesla4_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla4_lg.jpg -------------------------------------------------------------------------------- /galleries/demo/tesla_tower1_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla_tower1_lg.jpg -------------------------------------------------------------------------------- /galleries/demo/tesla_conducts_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla_conducts_lg.jpg -------------------------------------------------------------------------------- /files/images/MiMax-USB-1-AboutPhone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-1-AboutPhone.png -------------------------------------------------------------------------------- /files/images/MiMax-USB-8-ChooseMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-8-ChooseMode.png -------------------------------------------------------------------------------- /galleries/demo/tesla_lightning1_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla_lightning1_lg.jpg -------------------------------------------------------------------------------- /galleries/demo/tesla_lightning2_lg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/galleries/demo/tesla_lightning2_lg.jpg -------------------------------------------------------------------------------- /files/images/git-learning-notes-3parts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/git-learning-notes-3parts.png -------------------------------------------------------------------------------- /files/images/git-learning-notes-reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/git-learning-notes-reset.png -------------------------------------------------------------------------------- /files/images/MiMax-USB-4-5-DebuggingMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-4-5-DebuggingMode.png -------------------------------------------------------------------------------- /files/images/MiMax-USB-3-DeveloperOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-3-DeveloperOptions.png -------------------------------------------------------------------------------- /files/images/MiMax-USB-6-7-USBConfigInterface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-6-7-USBConfigInterface.png -------------------------------------------------------------------------------- /files/images/MiMax-USB-2-UnlockDeveloperOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/MiMax-USB-2-UnlockDeveloperOptions.png -------------------------------------------------------------------------------- /files/images/clothoid-approximation-coordinates.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/clothoid-approximation-coordinates.jpg -------------------------------------------------------------------------------- /files/images/install-monodevelop-on-ubuntu-cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/install-monodevelop-on-ubuntu-cmd.png -------------------------------------------------------------------------------- /files/images/install-monodevelop-on-ubuntu-gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/install-monodevelop-on-ubuntu-gui.png -------------------------------------------------------------------------------- /galleries/demo/index.txt: -------------------------------------------------------------------------------- 1 | .. title: Nikola Tesla 2 | 3 | Some public domain pictures of Nikola Tesla 4 | (copied from `here `_) 5 | -------------------------------------------------------------------------------- /files/images/custom-domain-settings-of-yandex-mail-hostrecords.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/custom-domain-settings-of-yandex-mail-hostrecords.png -------------------------------------------------------------------------------- /files/images/custom-domain-settings-of-yandex-mail-mailsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/custom-domain-settings-of-yandex-mail-mailsettings.png -------------------------------------------------------------------------------- /files/images/sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png -------------------------------------------------------------------------------- /files/images/sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png -------------------------------------------------------------------------------- /files/images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png -------------------------------------------------------------------------------- /files/images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png -------------------------------------------------------------------------------- /files/images/sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png -------------------------------------------------------------------------------- /files/images/sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png -------------------------------------------------------------------------------- /files/images/sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafe/nikola-blog/master/files/images/sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png -------------------------------------------------------------------------------- /listings/hello.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | 5 | 6 | def hello(name='world'): 7 | greeting = "hello " + name 8 | print(greeting) 9 | 10 | 11 | if __name__ == "__main__": 12 | hello(*sys.argv[1:]) 13 | -------------------------------------------------------------------------------- /pages/notes/index.rst: -------------------------------------------------------------------------------- 1 | .. title: Index 2 | .. slug: index 3 | .. date: 2016-04-26 22:24:50 UTC+08:00 4 | .. tags: 5 | .. category: 6 | .. link: 7 | .. description: 8 | .. type: 9 | .. author: YONG 10 | 11 | 12 | * :doc:`2016.05 - 2016.07 <2016-05-2016-07>` 13 | * :doc:`Tool Tips ` 14 | 15 | .. :doc:`May 2016 ` 16 | -------------------------------------------------------------------------------- /pages/about.rst: -------------------------------------------------------------------------------- 1 | .. title: About 2 | .. slug: about 3 | .. date: 2016-04-26 16:29:23 UTC+08:00 4 | .. tags: 5 | .. category: 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 12 | .. class:: col-md-2 img-circle img-responsive 13 | 14 | .. image:: /images/avatar.jpg 15 | :align: left 16 | 17 | .. class:: col-md-6 18 | 19 | 欢迎光临 ^_^ -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This folder contains the source used to generate a static site using Nikola. 2 | 3 | Installation and documentation at https://getnikola.com/ 4 | 5 | Configuration file for the site is ``conf.py``. 6 | 7 | To build the site:: 8 | 9 | nikola build 10 | 11 | To see it:: 12 | 13 | nikola serve -b 14 | 15 | To check all available commands:: 16 | 17 | nikola help 18 | -------------------------------------------------------------------------------- /posts/notepad++-tips.rst: -------------------------------------------------------------------------------- 1 | .. title: Notepad++ Tips 2 | .. slug: notepad++-tips 3 | .. date: 2016-04-25 12:23:01 UTC+08:00 4 | .. tags: text-editor 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Regular Expression 12 | ================== 13 | 14 | Replace all ``$something...$`` with ``\(something...\)``: Find what: 15 | ``\$(.*?)\$`` Replace with: ``\\\(\1\\\)`` 16 | -------------------------------------------------------------------------------- /pages/home.rst: -------------------------------------------------------------------------------- 1 | .. title: Home 2 | .. slug: index 3 | .. date: 2016-04-26 17:19:21 UTC+08:00 4 | .. tags: 5 | .. category: 6 | .. link: 7 | .. description: Home page 8 | .. type: text 9 | .. author: YONG 10 | 11 | 12 | .. class:: col-md-5 img-responsive 13 | 14 | .. image:: /images/home.jpg 15 | :align: left 16 | 17 | 18 | .. class:: col-md-6 19 | 20 | | Welcome to the homepage of YONG. 21 | | 22 | | This site is still under construction ... 23 | -------------------------------------------------------------------------------- /posts/visual-studio-auto-formatting-shortcut.rst: -------------------------------------------------------------------------------- 1 | .. title: Visual Studio Auto Formatting Shortcut 2 | .. slug: visual-studio-auto-formatting-shortcut 3 | .. date: 2016-04-26 01:04:11 UTC+08:00 4 | .. tags: visual-studio, cpp 5 | .. category: programming 6 | .. link: 7 | .. description: formatting c++ code with visual studio 8 | .. type: text 9 | .. author: YONG 10 | 11 | 12 | Visual Studio auto format (C++) shortcut: 13 | 14 | - To format a selection: ``CTRL + K + F`` 15 | - To format a document: ``CTRL + K + D`` 16 | 17 | See more in ``Edit`` -> ``Advanced`` menu 18 | 19 | -------------------------------------------------------------------------------- /posts/chong-zhi-ubuntu-deng-lu-mi-ma.rst: -------------------------------------------------------------------------------- 1 | .. title: 重置Ubuntu登录密码 2 | .. slug: chong-zhi-ubuntu-deng-lu-mi-ma 3 | .. date: 2016-08-18 12:22:35 UTC+08:00 4 | .. tags: ubuntu 5 | .. category: OS 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 经常在Windows上通过VirtualBox来使用Ubuntu, 很长一段时间没有登录, 居然把用户密码忘记了(或者是升级VirtualBox后的Bug?). 只能通过Grub重置密码了. 其本参照 https://help.ubuntu.com/community/LostPassword 这里的方法, 步骤如下: 12 | 13 | 1. 启动Ubuntu时长按Shift键进入Grub菜单 14 | 2. 选择recovery mode选项回车 15 | 3. 选择"root Drop to root shell prompt"选项 16 | 4. 在 ``~#`` 符号后输入 ``mount -rw -o remount /`` 使root盘获取读写权限. 如果略过此步执行下一步可能会提示"Authentication token manipulation error" 17 | 5. 在 ``~#`` 符号后输入 ``passwd [username]`` 按提示设置新的密码 18 | 6. 输入 ``reboot`` 重启. 19 | -------------------------------------------------------------------------------- /posts/install-textext-plugin-for-inkscape.rst: -------------------------------------------------------------------------------- 1 | .. title: Install Textext Plugin for Inkscape 2 | .. slug: install-textext-plugin-for-inkscape 3 | .. date: 2016-04-25 21:45:44 UTC+08:00 4 | .. tags: inkscape, latex 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Textext官网(http://pav.iki.fi/software/textext/)以及作者本人的bitbucket很久没有更新了(https://bitbucket.org/pv/textext/src). 12 | 针对Inkscape 0.91版本, 最新的textext资源在这里(https://bitbucket.org/pitgarbe/textext/src) 13 | 14 | .. TEASER_END 15 | 16 | Linux下可以直接下载 ``textext-0.5-linux.zip`` 安装包, 里面有说明文档, 对于windows, 其pdf说明文档该页面. 对于Linux/Win, 安装文档中要求的其它部件. 之后: 17 | 18 | Linux: 将压缩包里的 ``textext.py`` 文件替换成本页面最近更新的 ``textext.py``, 再执行 ``python setup.py`` 19 | 20 | Win: 使用exe安装之后, 将 ``textext.py`` 替换成本页面最近更新的 ``textext.py`` 文件. 21 | 22 | Done. 23 | -------------------------------------------------------------------------------- /posts/atom-markdown-settings.rst: -------------------------------------------------------------------------------- 1 | .. title: Atom Markdown Settings 2 | .. slug: atom-markdown-settings 3 | .. date: 2016-04-25 12:22:10 UTC+08:00 4 | .. tags: atom, markdown 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Markdown Packages: 12 | ================== 13 | 14 | - ``language-markdown`` 15 | - ``markdown-preview-plus`` 16 | - ``markdown-scroll-sync`` 17 | 18 | .. TEASER_END 19 | 20 | Note: 21 | ===== 22 | 23 | #. After installing ``markdown-preview-plus``, the built-in package 24 | ``markdown-preview`` should be disabled. 25 | #. Disable built-in package ``whitespace``: since it will remove 26 | trailing whitespaces automatically, while two whitespaces are 27 | necessary in markdown mode. Though you can disable this feature in 28 | the package settings, it is strongly recommended to disable the 29 | package because it also affects the performance of Atom in markdown 30 | mode. 31 | -------------------------------------------------------------------------------- /posts/arc-length-reparameterization.rst: -------------------------------------------------------------------------------- 1 | .. title: Arc Length Reparameterization 2 | .. slug: arc-length-reparameterization 3 | .. date: 2016-06-28 10:04:59 UTC+08:00 4 | .. tags: algorithm, mathjax 5 | .. category: math 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | reference: https://services.math.duke.edu/~wka/math103/curvature.pdf 12 | 13 | Suppose :math:`I` is an interval and :math:`\mathbf{r} : I \mapsto \mathbb{R}^n` is a curve in :math:`\mathbb{R}^n` whose speed is never zero. Suppose :math:`t_0 \in I` and let 14 | 15 | .. math:: 16 | 17 | \sigma (t) = \int_{t_0}^t \| \vec{r}' (\tau) \| d\tau 18 | 19 | .. TEASER_END 20 | 21 | Given a vector function :math:`\vec{r}(t)`, its arc length from :math:`t = a` to :math:`t = b` is 22 | 23 | .. math:: 24 | 25 | L = \int_a^b \| \vec{r}' (t)\| dt 26 | 27 | Replacing :math:`b` with :math:`u`, the arc length function is 28 | 29 | .. math:: 30 | 31 | s(u) = \int_a^u \| \vec{r}' (\tau) \| d\tau 32 | 33 | 34 | -------------------------------------------------------------------------------- /posts/org-mode-pdf-export-in-chinese.rst: -------------------------------------------------------------------------------- 1 | .. title: Org-Mode PDF Export in Chinese 2 | .. slug: org-mode-pdf-export-in-chinese 3 | .. date: 2016-04-25 12:24:11 UTC+08:00 4 | .. tags: org-mode, emacs 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Simple solution 12 | =============== 13 | 14 | Refer to http://www.xuebuyuan.com/2136832.html 15 | 16 | Add the following to ``dotspacemacs/user-config()`` block of 17 | ``.spacemacs`` file: 18 | 19 | .. TEASER_END 20 | 21 | .. code:: clojure 22 | 23 | (setq org-latex-pdf-process '("xelatex -interaction nonstopmode %f" 24 | "xelatex -interaction nonstopmode %f")) 25 | 26 | When your org file has Chinese characters, just put 27 | 28 | .. code:: 29 | 30 | #+LATEX_HEADER: \usepackage{xeCJK} 31 | #+LATEX_HEADER: \setCJKmainfont{SimSun} 32 | 33 | at the head of your ``.org`` file. 34 | 35 | Note 36 | ==== 37 | 38 | Other methods on the internet require lots of tweaks like style 39 | customization of code blocks, which are not needed here. 40 | 41 | -------------------------------------------------------------------------------- /posts/lyx-settins-on-windows.rst: -------------------------------------------------------------------------------- 1 | .. title: LyX Settins on Windows 2 | .. slug: lyx-settins-on-windows 3 | .. date: 2016-04-25 12:22:49 UTC+08:00 4 | .. tags: latex 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Main settings 12 | ============= 13 | 14 | Refer to 15 | http://andnot.farbox.com/post/ke-yan-bi-ji/lyxzhong-wen-pei-zhi-tips 16 | 17 | Document->Settings… 18 | 19 | .. TEASER_END 20 | 21 | - ->Document Class->Document class: Chinese Article (CTeX), ->Custom: 22 | UTF8 23 | 24 | - ->Language->Encoding->Other: Unicode (XeTeX) (utf8) 25 | 26 | - ->Output->Output Format->Default Output Format: PDF(XeTeX) 27 | 28 | - ->LaTeX Preamble: 29 | ``\DeclareRobustCommand\nobreakspace{\leavevmode\nobreak\ } % redefine nobreakspace to avoid XeTeX errors`` 30 | 31 | - ->PDF Properties: check Use Hyperrref Support, ->Bookmarks: check 32 | Generate Bookmarks (ToC), Numbered bookmarks, Open bookmark tree 33 | 34 | To aligh the section title in CTeX 35 | ================================== 36 | 37 | Document->Settings…->LaTeX Preamble: 38 | 39 | .. code:: latex 40 | 41 | \makeatletter 42 | 43 | \g@addto@macro{\CTEX@section@format}{\raggedright} 44 | 45 | \makeatother 46 | 47 | -------------------------------------------------------------------------------- /posts/atom-latex-settings.rst: -------------------------------------------------------------------------------- 1 | .. title: Atom LaTeX Settings 2 | .. slug: atom-latex-settings 3 | .. date: 2016-04-25 12:21:47 UTC+08:00 4 | .. tags: latex, atom 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Packages: 12 | ========= 13 | 14 | #. Install TeX Live (https://www.tug.org/texlive/) 15 | #. Install Atom 16 | 17 | .. TEASER_END 18 | 19 | #. Install Atom Packages 20 | 21 | - ``latex`` (compile latex) 22 | - ``language-lax`` (syntax highlighting) 23 | - ``latexer`` (autocmpletion) 24 | - ``latextools`` (more support) 25 | - ``minimap`` (preview of code) 26 | - ``open-recent`` (open recent files) 27 | - ``pdf-view`` (builtin pdf viewer) 28 | - ``file-icons`` 29 | - ``autocomplete-paths`` 30 | - ``spell-check`` 31 | 32 | #. Package Settings: 33 | 34 | - ``latex``: 35 | 36 | - Tex Path: ``C:\texlive\2015\bin\win32`` 37 | - Builder: latexmk 38 | - Always Open Result in Atom: Yes 39 | - (Other settings: keep default) 40 | 41 | - ``spell-check``: 42 | 43 | - Grammars: text.tex 44 | 45 | - ``pdf-view``: 46 | 47 | - Fit to width on open: Yes 48 | 49 | Important shortcuts: 50 | ==================== 51 | 52 | - ``Alt+Shift+S``: search for latex snippet 53 | - ``Alt+Ctrl+B``: compile 54 | - ``Alt+Ctrl+S``: sync 55 | - ``Alt+Ctrl+C``: clear 56 | 57 | -------------------------------------------------------------------------------- /posts/ijulia-installation-failed.rst: -------------------------------------------------------------------------------- 1 | .. title: IJulia Installation Failed 2 | .. slug: ijulia-installation-failed 3 | .. date: 2017-03-19 13:04:52 UTC+08:00 4 | .. tags: julia 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | 10 | "IJulia" is the Julia version of "Jupyter". It works with plotting packages like "Gadfly" and "PyPlot". 11 | It shows failure information related to "WinRPM" when installing "IJulia". 12 | 13 | Environment: Julia 0.5.1 x64 on Windows 10 14 | 15 | .. TEASER_END 16 | 17 | Output 18 | ================================= 19 | 20 | Output after running ``Pkg.add("IJulia")`` or ``Pkg.build("IJulia")``: 21 | 22 | :: 23 | 24 | INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_42.2/repodata/repomd.xml 25 | WARNING: Unknown download failure, error code: 2148270088 26 | WARNING: Retry 1/5 downloading: 27 | ... 28 | WARNING: Retry 5/5 downloading: https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_42.2/repodata/repomd.xml 29 | WARNING: received error 0 while downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_42.2/repodata/repomd.xml 30 | 31 | Solution 32 | ============== 33 | 34 | 1. Go to ``D:\home\.julia\v0.5\WinRPM\sources.list`` 35 | #. Delete ``https://cache.julialang.org/`` at the beginning of the two entries and save the changes. 36 | #. Run ``Pkg.build("IJulia")`` 37 | -------------------------------------------------------------------------------- /posts/clothoid-approximation.rst: -------------------------------------------------------------------------------- 1 | .. title: Clothoid Approximation 2 | .. slug: clothoid-approximation 3 | .. date: 2016-05-26 14:23:42 UTC+08:00 4 | .. tags: algorithm, clothoid, mathjax 5 | .. category: math 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 圆弧插值 12 | ============ 13 | 14 | 设basic clothoid上分布着多个点, 第 j 个圆弧穿过第 j 个与 j+1 个点. 它的半径由下式确定: 15 | 16 | .. TEASER_END 17 | 18 | .. math:: 19 | 20 | r_j = \kappa^{-1} = (\sigma (j+0.5) \Delta s)^{-1} 21 | 22 | 文中提到 :math:`\Delta s` 是 *sampling interval*, 那么 :math:`(j+0.5) \Delta s` 表示从起点开始到点 :math:`j+0.5` 的总长度, 可以判断文中采用的是 *uniform sampling*, 即 :math:`\Delta s` 是个定值. 23 | 24 | 从一个 basic clothoid 得到任意长度 s 处坐标的推导过程是这样的: 25 | 26 | |s coordinates| 27 | 28 | 即: 29 | 30 | .. math:: 31 | 32 | x(s)=x_j + 2 r_j \cos \left(\theta_j + \frac{\Delta s}{2 r_j}\right) \sin \frac{\Delta s}{2 r_j} 33 | 34 | .. math:: 35 | 36 | y(s)=y_j + 2 r_j \sin \left(\theta_j + \frac{\Delta s}{2 r_j}\right) \sin \frac{\Delta s}{2 r_j} 37 | 38 | 39 | 误差估计: 40 | ============ 41 | 42 | 固定 :math:`\sigma=1`, 然后 compare interpolation error for *3 values* of sampling interval :math:`\Delta s`, 也就是说只比较区间里的3个对应值的误差. 在作出误差图后总结到, 因为clothoid被划分为很多小段, 最大误差就出现在第一段的末端点, 即 :math:`j=0`. 此时, :math:`r_j=2(\sigma \Delta s)`, 且 :math:`\theta_j=0, \Delta s=\Delta s_L` (即为该段长度), 代入到上面的表达式求 :math:`x(s), y(s)`, 后面根据clothoid表达式特点推导出最大误差与 :math:`\Delta s, \sigma` 的关系, 即文中式(8). 43 | 44 | .. |s coordinates| image:: /images/clothoid-approximation-coordinates.jpg 45 | :width: 480 -------------------------------------------------------------------------------- /posts/guan-yu-github-de-si-kao.rst: -------------------------------------------------------------------------------- 1 | .. title: 关于GitHub的使用思考 2 | .. slug: guan-yu-github-de-shi-yong-si-kao 3 | .. date: 2016-08-23 11:41:45 UTC+08:00 4 | .. tags: github 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 之前一直对使用GitHub存放博客(静态网站)很痴迷, 后来又发现Gist的好处, 最近又开始频繁使用普通的Repo来存放一些东西. GitHub光是文字记录功能的产品不止这几样, 比如评论和Wiki等等. 这就让我开始思考, 到底哪些东西适合用对应的哪一项功能来完成或是存放. 12 | 13 | .. TEASER_END 14 | 15 | 先说GitHub Pages. 这个除了展示静态的网页(网站)之外并没有什么神奇的功能 - GitLab也可以, 只是在国内访问受限. 既然是网页, 除了文字图片等核心的东西之外, 还有不少与网页装饰相关的边角料. 而且更新也并不直观便捷, 需要使用Git上传. 所以每次写东西都是先放在自己硬盘里, 等攒上一些东西后一并更新. 我觉得这种展示方式是面向大众的, 适合表达一些自己的一些感想, 观点, 以及需要在必要时展示给别人的demo等等. 另外一种情况需要用到GitHub Pages, 即涉及到LaTeX数学公式的情况. GitHub不支持对README文本文档中的公式进行MathJax渲染, 因此需要GitHub Pages中实现(Nikola就支持). 另外GitHub Pages支持category, tags等功能, 也是比较方便的地方. 16 | 17 | 再说说Repository. 它是整个GitHub的核心, GitHub Pages虽然表面花哨, 其实也是基于Repo的. 为什么GitHub吸引我, 很大的一个原因就是它对各种文本文档的渲染支持, 比如 .md, .rst, .org 等. 正是由于这个原因, 很多方面可以直接代替GitHub Pages的功能. 比如一些工具设置步骤, 问题的解决方案等, 都可以写在 .org 文档里, GitHub直接就要以看到渲染后的结果, 不用Git客户端, 编辑也很方便快捷, 几乎算是"所见即所得". 而且比起GitHub Pages更简洁, 只用储存有用的干货, 与美观相关的修饰全都用不着. 缺点是目前不支持LaTeX公式渲染(但可以用反斜杠插入希腊字母), 因此涉及数学公式表达的还是得靠GitHub Pages. 现在越来越喜欢用Repo来管理和记录自己喜欢的一切东西, 比如日志, 目录, Task, List, 心得, 教程, 图片等等, 因为是Git, 所以自带历史版本信息, 比起传统的微博, QQ空间之类的要方便不少, 而且可以在任何时候用Git工具备份到自己本地电脑上, 着实好用. 以后Repo里就存放各种和技术相关的东西, 不再麻烦地使用GitHub Pages了. 18 | 19 | 备注: 个人偏好 .org 格式, 因为它风格统一, 不会有不同的标准. 而GitHub支持的 .md 与 .rst 可能与其它的标准不兼容. 而且 .org 支持语法高亮(.rst好像GitHub并不支持), 且其它功能如插入图片等都没有问题. 20 | 21 | Gist适合写一些代码小片断, 且免费用户也可以将Gist设为Secret. 缺点是当Gist一多, 又没有好的归类, 就不太容易找. 因此现在我更喜欢用Repo来专门存放修改各种code snippets. 22 | 23 | Wiki和评论也是很好的文档记录工具, 也有很多使用的trick(插入图片也可以用引用评论中图片的方式实现). 但因为不能直接用Git工具管理和备份, 因此我觉得并不如Repo实在, 所以自己用得就比较少. -------------------------------------------------------------------------------- /posts/hunger-games-guan-hou-gan.rst: -------------------------------------------------------------------------------- 1 | .. title: Hunger Games 观后感 2 | .. slug: hunger-games-guan-hou-gan 3 | .. date: 2016-05-01 20:11:55 UTC+08:00 4 | .. tags: 政治, 电影 5 | .. category: 评论 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 前天和同学聊歌曲时,无意间聊到年轻歌手 Lorde 和我喜欢的 "*Yellow Flicker Beat*”. 这首歌是第三部 *Hunger Games* 的片尾曲, 忽然想起自己除了当时和实验室的人一起去 Golden Village 糊里糊涂地看了第二部, 其它几部还没有看过. 一番搜索后发现这个系列的电影所幸已经完结, 那就可以痛快地看一遍了. 12 | 13 | .. TEASER_END 14 | 15 | 先放上一段我喜欢的剪辑 (已成为我最爱的MV): 16 | 17 | .. youtube:: QnoXecGpq6g 18 | 19 | 记得当时看第二部, 因为我并不知道影片的背景故事, 也不知道第一部发生了什么, 只是觉得名字很希奇古怪, 又是美国大片, 钱总不会白花. 当看到中途时觉得刺激程度让人失望, 情节设定有点类似自己很久之前看过的 *死亡飞车*. 现在当我几部放在一起看, 对故事的认识也更清楚, 瞬间就对这个系列有了好感. 20 | 21 | 昨夜一口气看完4部已经凌晨四点, 不过结局对我这种现实主义稍带悲观主义的人来说, 比较失望, 因为它太过于美好. 大概对于电影而言, 需要这么一个比较浪漫的结局来抚慰观众被饥饿游戏折磨的内心吧. 相对于现代人的世界观和价值观, 电影里设定的场景像是红色警戒中的苏联, 连那红色的旗帜和标志都有几分神似, 以及领导层的着装和建筑风格. 架构也是简单粗暴, 一个都城统治和奴役其余的分区. 最初我是觉得这设置很违背情理, 毕竟电影中各种酷炫的科技手段都出现了, 这么一个拥有辗压性技术实力的中央怎么会和其它几个分区还打得有来有回的. 比如13区什么的, 毁都毁了, 也不少几颗核弹让它消失得更彻底一些呀 (个人感觉其背景设定不如 *死亡飞车* 有条理). 反正不用去纠结这些背景设定的细节, 只用去感受作者/导演想要借这样一个框架表达的东西就行. 其实我是很惊讶这系列电影可以在某些国家(?)上映的. 现在的大多数国家里, 都没有电影中那样严格的区域隔离. 而在某些国家, 因为存在着先进的户口制度, 一个北京户口不比拥有电影中都城人身份逊色多少吧. 22 | 23 | 抛开社会背景不谈, 最能打动观众的或许便是每位贡品的入场式和道别仪式. 对于勇于赴死的人(古谓死士), 历来都是倍受尊敬的. 因为这种悲凉的气氛加上这荒诞的游戏, 让人顿生对这个世界和社会制度的无力感. 正是由于这种对比, 让观众(从现代人的三观出发)心中的反叛之火早就燃起了. 抗击专政, 打垮暴君, 作者显然顺应了观众一厢情愿的要求. 甚至给了大家一个还算能接受的美好结局. 然而人生残酷, 主角知道妹妹之死的过程是因为她和前独裁者的交谈, 而给予她这个交谈机会的, 正是后来票选的新总统. 游戏还在继续, 小人物在政治游戏中永远只是一只受人操纵的 **mockingjay**, 即便她万众瞩目. 电影结束, 这种无力感再次包围了我. 或许真的如电影那样, 只有回乡隐居后的主角才真正做回了自己. 现实中不是每个人都能有这样的选择的. 24 | 25 | 电影中的施惠国, 可以是一个国家, 也可以是一个你生活过, 或是工作过的却再也不想提及的地方. 电影让我回忆起之前工作过的实验室, 这样的经历虽然已经过去, 伤痛也会慢慢愈合, 然而无法改变的是记忆. 有同样经历的小伙伴说, 对科研当初的那份激情和向往, 已经永远地失去了. 而电影中主角在最后抱着孩子自言自语的那番话, 像是在替受难者道出心底的真实感受. 相信随着阅历的增长, 日后再品味这些片段, 或许又是另一番滋味. -------------------------------------------------------------------------------- /posts/install-monodevelop-on-ubuntu.rst: -------------------------------------------------------------------------------- 1 | .. title: Install MonoDevelop on Ubuntu 2 | .. slug: install-monodevelop-on-ubuntu 3 | .. date: 2016-04-26 01:17:23 UTC+08:00 4 | .. tags: cpp 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | MonoDevelop 12 | ----------- 13 | 14 | MonoDevelop不但可以用来写.Net程序,也可以用作C++的IDE,只是ubuntu软件中心的monodevelop版本非常陈旧,因此我们需要自己手动来安装(我使用的是 15 | Ubuntu 14.04 LTS, 安装之后的 monodevelop 版本为 5.10)。 16 | 17 | .. TEASER_END 18 | 19 | PPA 20 | ~~~ 21 | 22 | 我们首先尝试使用ppa安装,\ `MonoDevelop 23 | PPA `__\ ,在PPA页面搜索monodevelop,找到stable 24 | release版本,通过terminal安装得到提示:该PPA已不再支持:( 25 | 26 | via Official Site 27 | ~~~~~~~~~~~~~~~~~ 28 | 29 | 因此我们推荐按照官方安装流程,即:\ `Official 30 | Guide `__ 31 | 按照流程: 32 | 33 | 1. 依次完成 Add the Mono Project GPG signing key and the package 34 | repository, enable mod\_mono installation, enable libgdiplus 35 | installation 这三个部分。 36 | 37 | 2. 转到该页面 Usage 部分,安装 mono-devel. 可能会因为一些依赖的 package 38 | 无法安装而失败。通过 synaptic 安装需要的各个 package 发现失败原因是 39 | ubuntu 不提供 >= 1.31 版本的 libjpeg62-turbo 包。 40 | 41 | 解决方法: 直接去 Debian 网站下载最新版的 .deb 文件(已提供 42 | 1.4.1版本)安装: https://packages.debian.org/sid/libjpeg62-turbo, x64 43 | 系统选择 amd64 链接下载即可。 44 | 45 | 3. 完成上面这些只是安装了 mono 框架。接着安装 monodevelop 46 | 程序:\ http://www.monodevelop.com/download/linux/ 这里主要安装 47 | monodevelop, 其它的如 monodevelop-nunit 等组件可视情况安装。 48 | 49 | 4. 安装完成后,terminal 中输入 monodevelop 运行,创建一个 hello world 的 50 | C# 程序,验证安装成功。附程序界面和运行截图: 51 | 52 | |GUI| 53 | 54 | |CMD| 55 | 56 | .. |GUI| image:: /images/install-monodevelop-on-ubuntu-gui.png 57 | :width: 480 58 | 59 | .. |CMD| image:: /images/install-monodevelop-on-ubuntu-cmd.png 60 | :width: 480 61 | 62 | -------------------------------------------------------------------------------- /posts/xiao-mi-shou-ji-lian-jie-dian-nao.rst: -------------------------------------------------------------------------------- 1 | .. title: 小米手机连接电脑 2 | .. slug: xiao-mi-shou-ji-lian-jie-dian-nao 3 | .. date: 2017-02-09 14:51:43 UTC+08:00 4 | .. tags: 手机 5 | .. category: OS 6 | .. link: 7 | .. description: 8 | .. type: text 9 | 10 | 我们要将手机连接到电脑上,并用电脑访问手机上的文件,如复制、删除歌曲及图片文件等。 11 | 但小米助手目前几乎被官方放弃,只支持安卓5.0及以前的系统。 12 | 13 | 使用手机:小米Max,安卓版本:7.0, 国际版。 14 | 15 | 下面我们用安卓的USB调试模式连接。 16 | 17 | .. TEASER_END 18 | 19 | 步骤 20 | ===== 21 | 22 | 1. 若尚未开启USB调试功能,需要解锁开发者选项 23 | 24 | a) ``Settings`` > ``About phone`` (图中1) 25 | 26 | |About phone| 27 | 28 | b) 多次点击 ``MIUI version`` 一项 (图中2) 29 | 30 | |MIUI version| 31 | 32 | c) ``Settings`` > ``Additional settings`` > ``Developer options`` (图中3) 33 | 34 | |Developer options| 35 | 36 | d) 分别开启 ``Developer options`` 与 ``USB debugging`` 选项 (图中4与5) 37 | 38 | |USB debugging| 39 | 40 | 2. ``Developer options`` > ``Select USB Configuration`` > ``MTP (Media Transfer Protocol)`` 41 | (图中7) 这时插上电脑一般就可以当作U盘使用了。但有时还是发现在电脑上查看时,手机盘里什么内容都看不到的情况。 42 | 这时只要重新在 ``Select USB Configuration`` 中先切换到别的模式,如充电模式,再切回MTP模式就可以了。有时插上USB或切换模式后会在顶栏出现 43 | 提示 (图中6) 只要再确认一下MTP模式即可 (图中8)。这时就可以在电脑上看到文件了。 44 | 45 | |MTP mode| 46 | |Choose mode| 47 | 48 | .. |About Phone| image:: /images/MiMax-USB-1-AboutPhone.png 49 | :width: 480 50 | .. |MIUI version| image:: /images/MiMax-USB-2-UnlockDeveloperOptions.png 51 | :width: 480 52 | .. |Developer options| image:: /images/MiMax-USB-3-DeveloperOptions.png 53 | :width: 480 54 | .. |USB debugging| image:: /images/MiMax-USB-4-5-DebuggingMode.png 55 | :width: 480 56 | .. |MTP mode| image:: /images/MiMax-USB-6-7-USBConfigInterface.png 57 | :width: 480 58 | .. |Choose mode| image:: /images/MiMax-USB-8-ChooseMode.png 59 | :width: 480 60 | -------------------------------------------------------------------------------- /pages/notes/tool-tips.rst: -------------------------------------------------------------------------------- 1 | .. title: Tool Tips 2 | .. slug: tool-tips 3 | .. date: 2016-07-24 14:11:59 UTC+08:00 4 | .. tags: algorithm, software, web 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 中国可备案的域名后缀(gTLD) 12 | ===================================== 13 | 访问 http://www.miitbeian.gov.cn/publish/query/indexFirst.action 页面"域名类型"一栏可以查看可以备案的通用域名, 目前(2016.8.8)可备案的gTLD如下: 14 | com, net, org, edu, gov, biz, info, name, aero, arpa, asia, cat, coop, int, jobs, mil, mobi, museum, pro, tel, travel, wang, citic, ren, top, sohu, xin 15 | 16 | Capitalize The First Letter 17 | ======================================= 18 | 将一个句子里所有单词首字母大写, 使用Excel中的 ``PROPER()`` 函数即可. 19 | 20 | 视频只听声音不看画面(禁止画面播放) 21 | ====================================== 22 | 使用VLC, Video->Video Track->Disable, 并且 Tools->Preferences->Video->Disable "Enable Video" option. 这样就可以听视频了. 23 | 24 | 拼音转汉字(批量) 25 | ======================= 26 | 大多数输入法可以做到单个拼音转汉字. 批量转换可借助爱词霸翻译 http://fy.iciba.com/ 等在线转换, 这种方法可以用于区别域名中的自然双拼. 后来尝试过其它几个在线翻译, 发现还是Google翻译最好用. 只用选择Chinese->Chinese就可以了. 因为Google翻译后的结果会粘成一行, 为了使结果按行排列, 可以在每个拼音后加上斜杠 ``/`` 或反斜杠符号(或逗号等其它标点符号)再回车. 27 | 28 | Mathematica提高精度 29 | =========================== 30 | 一些算法如NMinimize, FindRoot都会受WorkingPrecision的影响. 可以在这些算法当中单独指定WorkingPrecision的值. 如果想要指定一个全局的工作精度值, 可以使用下面的方法(来自http://mathematica.stackexchange.com/questions/38114/how-to-set-the-working-precision-globally-minprecision-does-not-work): 31 | 32 | .. Code:: 33 | 34 | $PreRead = (# /. 35 | s_String /; 36 | StringMatchQ[s, NumberString] && 37 | Precision@ToExpression@s == MachinePrecision :> 38 | s <> "`50." &); 39 | 40 | 41 | 这样设置后, 之后的所有计算都会是指定的50位精度. 42 | 43 | 测试网站是否被墙 44 | ============================= 45 | 测试网站是否可以被中国用户访问, 可以使用360奇云测 http://ce.cloud.360.cn, 如果网速为0的地区就说明那个地方不能访问. 如果中国大部分地区都没有速度, 就极可能是被墙了. -------------------------------------------------------------------------------- /posts/mian-fei-yu-ming-you-xiang-xuan-ze.rst: -------------------------------------------------------------------------------- 1 | .. title: 免费域名邮箱选择 2 | .. slug: mian-fei-yu-ming-you-xiang-xuan-ze 3 | .. date: 2016-08-17 02:16:12 UTC+08:00 4 | .. tags: domain, email 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 几年前, Google和微软都还有免费的域名邮箱服务, 现在都已经转为收费了. 考察了以下几种免费的域名邮箱提供商: 12 | 13 | 1. 国内: QQ, 网易 14 | 2. 国外: zoho, yandex 15 | 16 | 先说我的选择: zoho. 接下来具体解释我遇到的情况. 17 | 18 | .. TEASER_END 19 | 20 | 1. QQ域名邮箱. 现在为了推广自家的企业邮箱, 已经不能从domain.mail.qq.com进入了, 需要从QQ邮箱的实验室功能页进入. 优点是与QQ邮箱绑定, 方便好用, 容量大. 缺点便是不适合做工作邮箱, 或者与国外邮件往来频繁的情况. 亲自做了测试, 使用zoho mail给QQ邮箱发送了两封邮件, 其中一封在延迟了一个多小时才收到, 另一封已过去了六七个小时还没有收到, 估计是丢失了(补充: 第二天过了十多个小时后收到了), 使用邮箱的自助查询也没有找到. 同样的zoho mail帐户, 给Gmail发邮件都是秒收. 以前我还是很相信腾讯的实力的, 自从几年前被人爆出腾讯拦截Valve发送的Dota2邀请邮件, 到后来一些用户抱怨使用QQ域名邮箱收不到国外邮件, 还有抱怨说每天发送两三封邮件后就开始疯狂地要求用户输入验证码. 还有使用 mail-tester.com 测试时, QQ域名邮箱得分也比较低, 甚至其IP还进了某些垃圾邮件组黑名单, 因此使用它作发送端时国外用户可能还会因系统拦截收不到邮件. 2016.08.18补充, 今天发现Github的通知邮件是直接被QQ邮箱系统拦截的, 再次证实QQ邮箱的不可靠. 以后也尽量不要使用QQ邮箱作为验证邮箱. 21 | 22 | 2. 网易域名邮箱. 说实话, 自从被爆出126/163邮箱过亿数据泄露后, 我就对这家公司的服务严重怀疑. 网易的公关能力真是了得, 这么大的事情居然大多数网民不知情. 当我从数据库中查到自己网易邮箱密码的时候脸都绿了, 从此一生黑. 幸好自己的网易邮箱一直被我用做注册各种垃圾网站接收垃各种广告邮件的垃圾桶. 23 | 24 | 3. zoho. 免费帐户容量5G, mail-tester 得分较高, 被当垃圾服务器拦截的可能性低, 适合正式工作使用. 25 | 26 | 4. yandex. 每个域名允许多至1000个邮箱. 之前一个域名绑定在这家俄罗斯服务商下, 觉得也没有什么不妥. 但事实上如果使用邮件客户端收信, 这家和腾讯一个尿性(社会主义好), 又是输验证码, 又是强迫用户绑定手机验证. 我讨厌一切绑定手机号的服务. 如果不使用客户端, 也不使用其它邮箱收取yandex的邮件, 只使用yandex本身的网页端的话, 还算是一个不错的选择(在mail-tester中也上了一家黑名单). 27 | 28 | 综上我选择了zoho. 但zoho也并非完美. 我使用时pop3收信功能一直出问题, 我设置的outlook.com收取功能一直报错(换了Gmail还是出错). 因为我是想给自己的outlook.com帐户添加一个send-and-receive account来管理zoho上的域名邮箱的, 结果不能收取. 后来又想使用zoho mail的转发功能, 发现它的转发功能也是个残废, 总之是不work. 折衷办法: 域名得到zoho验证后, 不要设置和zoho相关的MX记录. 只用在注册商(如Godaddy)设置邮箱转发功能, 所有转发邮箱帐户与zoho上设置的域名邮箱一致即可. 我把这些邮箱全部转发到自己的Outlook.com邮箱里, 并且创建了一个rule把所有接收方为域名邮箱的邮件自动归类到一个文件夹下. 再在Outlook.com邮箱里设置了一个send-only account用于代理发送. 只要是使用zoho的smtp服务器发送, 发送的邮件中是不会有"由xxx代发"的标记的. 这样设置后就约等效于使用微软提供的免费域名邮箱服务了. 同理也可以使用Gmail做相同的设置. -------------------------------------------------------------------------------- /posts/matlab-3d-plot.rst: -------------------------------------------------------------------------------- 1 | .. title: Matlab 3D Plot 2 | .. slug: matlab-3d-plot 3 | .. date: 2016-05-25 20:02:10 UTC+08:00 4 | .. tags: matlab 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 之前我一直是MMA的忠实用户, 因为它symbolic运算强大且精确. 也从来没有实际感受过它和其它计算系统之间的速度差别. 我之前有一组数据是连着跑了一天一夜, 因为MMA有着天然的内存泄漏问题, 为了防止它把我电脑的16G内存全吃掉后卡死, 我必须将它运行的中间结果都打印出来, 每次吃完内存后就重启MMA释放内存, 从中断的地方接着运行. 前天又想算一组误差数据, 本以为天亮后计算结果就会出来, 可是并没有, 当我到了实验室还仍然是Running的状态. 这让我愤怒地转向了Julia, 边自学边上阵, 大半天加一晚上把程序弄到了Julia里来, 到今天已经能正常地得出结果了. 12 | 13 | .. TEASER_END 14 | 15 | Julia使用感受: 很快, 真的很快, 真真真的太TM快了. MMA上一跑就要至少一天还没跑出结果的东西, Julia居然一分钟内就把结果给了我. 简真像加了特技一样. 不知道是不是因为MMA编程技术太烂的原因. 本来还搜索了Julia并行计算的内容, 想着怎么捣鼓一下, 结果完全没用上. 数据出来了, 不过几经周折发现Julia画图是个短板. 继续用回MMA, 40几M的数据文档一加载就是接近十分钟, 画完图整个MMA就跟死了一样. 好吧, 又是我不专业的锅. 没办法, Matlab走起. 终于扯到正题, 我本来只是想写点matlab 3d画图命令做备忘之用, 不留神一提笔就把整个事情的由来也唠叨了一回. 16 | 17 | 作图要求: 两个向量分别是x, y轴数据, 一个矩阵的内容为z数据. 18 | 19 | 尝试结论: 因为数据比较大且不规则, surf结果太丑, 没有好的配色, scatter3直接把电脑整假死了, mesh结果比较令人满意. 20 | 21 | 数据: 22 | 23 | .. code:: matlab 24 | 25 | L=0.05:0.05:50.0; 26 | sigma=0.05:0.05:pi/(0.05*0.05); 27 | value=dlmread('C:\\home\\Dropbox\\juliastuff\\result.txt'); 28 | % value(value==0)=NaN % omit 0 values 29 | mesh(sigma,L,value) 30 | xlabel('\sigma'),ylabel('L'),zlabel('\epsilon') 31 | axis([0.0 pi/(0.05*0.05) 0.0 50.0 0.0 8e-3]) 32 | 33 | 注: 34 | 35 | 1. 数据导入参考 `Import Numeric Data from Text Files `_ 36 | 2. matlab貌似矩阵是列主序的, 幸好L和sigma的长度不一样, mesh报错才发现. 参考 `Row-major order `_ 37 | 3. 3D 作图参考 `Plotting 3D Surfaces `_ 38 | 4. 在mesh命令之前, 因为本数据中0都表示无效, 可以用 value(value==0)=NaN 使最终的图里不显示0 39 | 5. 其它几种但此例中效果不理想的作图: surf(sigma,L,value), contour(sigma,L,value), 以及 scatter3: 40 | 41 | .. code:: matlab 42 | 43 | Lrep=repmat(L,1,25132); 44 | sigmarep=repmat(sigma,1,1000); 45 | valuerep=reshape(value',1,1000*25132); 46 | scatter3(Lrep,sigmarep,valuerep) 47 | 48 | 画图搞定, 继续搞Julia. 49 | 50 | -------------------------------------------------------------------------------- /posts/custom-domain-settings-of-yandex-mail.rst: -------------------------------------------------------------------------------- 1 | .. title: Custom Domain Settings of Yandex Mail 2 | .. slug: custom-domain-settings-of-yandex-mail 3 | .. date: 2016-05-06 14:04:20 UTC+08:00 4 | .. tags: domain 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | This post is talking about the steps needed to set up a custom domain mail account using Yandex Mail service. 12 | 13 | As far as I know, Outlook.com (Microsoft) and Google have stopped their free services for custom domain mails. After a search, I found Yandex mail. Yandex Mail provides unlimited mail accounts (by default 1000 but you can apply more) with unlimited storage space. Also, Yandex allows custom logo in the web interface. The most important thing is: all of these features are free to use. 14 | 15 | .. TEASER_END 16 | 17 | Note: Yandex is originated from Russia though, but luckily it has English interface for easy access. 18 | 19 | Here, I assume you already have your own domain prepared. Please follow these steps to use Yandex custom domain mail, **FOR FREE**: 20 | 21 | 1. log into your Yandex Mail, and go to https://domain.yandex.com/ to add your own domain, e.g., oxyz.org 22 | 2. Verify your domain according to the instructions of Yandex. If you are hosting your site using Github, the first option is the most convinient: just creating a ``.html`` file with specified string as content, and uploading to the Github server. It does not need to touch your DNS settings. BTW, this is my host records settings on *Namecheap.com*: 23 | 24 | .. image:: /images/custom-domain-settings-of-yandex-mail-hostrecords.png 25 | :width: 480 26 | 27 | 3. Mail server settings on your domain provider side (we just use *Namecheap.com* as an example, and please note that it may take several minutes to take effects): 28 | 29 | .. image:: /images/custom-domain-settings-of-yandex-mail-mailsettings.png 30 | :width: 480 31 | 32 | 4. After the success of verifications, you are free to create email accouts with your own custom domain, as many as you want. 33 | 5. Log into your new email by visiting http://mail.yandex.com/for/yourdomain.com 34 | 35 | All set. Just enjoy your own email address! 36 | 37 | -------------------------------------------------------------------------------- /posts/angle-between-2-vectors.rst: -------------------------------------------------------------------------------- 1 | .. title: Angle between 2 Vectors 2 | .. slug: angle-between-2-vectors 3 | .. date: 2016-04-26 01:34:15 UTC+08:00 4 | .. tags: algorithm 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 两向量夹角问题 12 | -------------- 13 | 14 | Given two vectors v1(x1,y1), v2(x2,y2) and they are not necessarily 15 | normalized, compute the angle beta between v1 and v2. 16 | 17 | .. TEASER_END 18 | 19 | 通常做法 20 | -------- 21 | 22 | A common way is using dot product (C++ version): 23 | 24 | .. code:: cpp 25 | 26 | beta = acos((x1 * x2 + y1 * y2) / sqrt((x1*x1 + y1*y1)*(x2*x2 + y2*y2))) 27 | 28 | The resulting beta is within [0, Pi]. It is equivalent to using 29 | ``VectorAngle[]`` function in *Mathmatica*. However, it seems 30 | inefficient due to the ``acos()`` and ``sqrt()`` function. Moreover, we 31 | lost the information of the sign of the angle. 32 | 33 | 改进 34 | ---- 35 | 36 | We can use ``atan2()`` function instead: 37 | 38 | .. code:: cpp 39 | 40 | beta = atan2(x1*y2 - y1*x2, x1*x2 + y1*y2) 41 | 42 | The obtained beta is in range [-Pi, Pi]. 43 | 44 | 完整代码 45 | -------- 46 | 47 | Source: `Vector 48 | Angle `__ 49 | 50 | .. code:: csharp 51 | 52 | /// 53 | /// AngleBetween - the angle between 2 vectors 54 | /// 55 | /// 56 | /// Returns the the angle in degrees between vector1 and vector2 57 | /// 58 | /// The first Vector 59 | /// The second Vector 60 | public static double AngleBetween(Vector vector1, Vector vector2) 61 | { 62 | double sin = vector1._x * vector2._y - vector2._x * vector1._y; 63 | double cos = vector1._x * vector2._x + vector1._y * vector2._y; 64 | return Math.Atan2(sin, cos) * (180 / Math.PI); 65 | } 66 | 67 | Since the ``atan2()`` function in C++ is the same with the C# version: 68 | ``atan2(y, x)``. Notice that in *Mathematica*, ``ArcTan[]`` can take 2 69 | arguments like ``atan2()``, but in a different order: ``ArcTan[x, y]``. 70 | 71 | -------------------------------------------------------------------------------- /posts/charts.txt: -------------------------------------------------------------------------------- 1 | .. link: 2 | .. description: 3 | .. tags: 4 | .. date: 2013-08-27 18:20:55 UTC-03:00 5 | .. title: Charts 6 | .. slug: charts 7 | 8 | If you are using reStructuredText and install pygal, Nikola has support for rather nice charts 9 | with little effort, and i's even semi-interactive (hover your pointer over the legend!): 10 | 11 | .. code:: rest 12 | 13 | .. chart:: StackedLine 14 | :title: 'Browser usage evolution (in %)' 15 | :fill: True 16 | :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012'] 17 | :width: 600 18 | :height: 400 19 | :explicit_size: True 20 | :style: BlueStyle 21 | 22 | ('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) 23 | ('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1]) 24 | ('Firefox', [None, None, None, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1]) 25 | ('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3]) 26 | 27 | .. raw:: html 28 | 29 |
30 | 31 | .. chart:: StackedLine 32 | :title: 'Browser usage evolution (in %)' 33 | :fill: True 34 | :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012'] 35 | :width: 600 36 | :height: 400 37 | :explicit_size: True 38 | :style: BlueStyle 39 | 40 | ('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) 41 | ('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1]) 42 | ('Firefox', [None, None, None, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1]) 43 | ('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3]) 44 | 45 | .. raw:: html 46 | 47 |
48 | 49 | 50 | Here's how it works: 51 | 52 | * Next to the directive, use the `chart type you want `_ 53 | * Any option you can set in a chart? Use it like ``:title:`` in this example. Syntax on 54 | the value is just like in the pygal examples. 55 | * For each data series do it like the line that says ``Firefox`` in this example. The first element 56 | is the label, then comes the data. 57 | 58 | Easy, right? Please explore `the pygal site `_ for more information, and just 59 | take this example and tweak stuff. 60 | -------------------------------------------------------------------------------- /posts/sagemath-file-exchange-with-windows-via-virtualbox.rst: -------------------------------------------------------------------------------- 1 | .. title: SageMath File Exchange with Windows via VirtualBox 2 | .. slug: sagemath-file-exchange-with-windows-via-virtualbox 3 | .. date: 2016-04-25 21:09:20 UTC+08:00 4 | .. tags: sage 5 | .. category: programming 6 | .. link: 7 | .. description: Sage notebooks, images can be stored in Windows 8 | .. type: text 9 | .. author: YONG 10 | 11 | 12 | SageMath Windows安装 13 | -------------------- 14 | 15 | 在win环境下SageMath以ova虚拟机应用的形式安装: `SageMath for 16 | Windows `__ 在使用Virtual 17 | Box安装时将系统选择为自己比较熟悉的Ubuntu x64版本, 并按照 `SageMath 18 | Installation `__ 19 | 中的步骤添加好共享文件夹后reset状态 (比如 C:/home/SageProjects). 20 | 21 | .. TEASER_END 22 | 23 | - 提示: 我们可以将和linux相关的所有文件都放在win下 C:/home 中, 24 | 并将此路径起名为“home”的环境变量.7.0版本默认进入 jupyter 界面, 25 | 26 | iPython Notebook (Jupyter) 27 | -------------------------- 28 | 29 | 个人感觉ipython也比sage原生的notebook模式好用, 因为它支持 30 | markdown+latex, 比sage的notebook界面更简洁, 31 | 并且它存储的文件位置在虚拟机上很直观, 很容易找到, 并不像之前那么隐蔽. 32 | 点击上方 jupyter 图标后, 显示所有文件夹和文件. 33 | 我们可以创建一个文件夹用于文件共享, 名字随意, 比如这里叫 Downloads: 34 | 35 | |Jupyter Notebook| 36 | 37 | 路径配置 38 | ~~~~~~~~ 39 | 40 | 这时按\ ``右Ctrl+F1``\ (默认``右Ctrl``\ 为host鍵)进入shell, 41 | 用户名和密码都是sage, 42 | 将我们之前设定的文件夹\ ``C:/home/SageProjects``\ 添加进来, 43 | 使用以下命令(参考\ https://help.ubuntu.com/community/VirtualBox/SharedFolders): 44 | 45 | .. code:: bash 46 | 47 | sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) SageProjects ~/Downloads 48 | 49 | 如下图: 50 | 51 | |Directory Setting| 52 | 53 | 设置完毕后按\ ``右Ctrl+F7``\ (F2~F7之间的一个, 54 | 一般是\ ``F7``)返回jupyter界面, 55 | 这时我们只要进入Downloads文件夹创建notebook,执行运算, 保存结果等操作. 56 | 所有产生的文件都会在这个文件夹下, 也会自动出现在win上的共享文件夹 57 | ``C:/home/SageProjects`` 下面, 58 | 如创建sagemath7.0类型名为testNoteBook的文件, 59 | 我们在里面做了计算并使用了plot, 且使用save函数将plot结果输出为pdf: 60 | 61 | |Plot Example| 62 | 63 | |Plot Example File| 64 | 65 | 这些文件同时也出现在了win系统的SageProjects共享文件夹中: 66 | 67 | |Win Folder| 68 | 69 | Duang~ 70 | ~~~~~~ 71 | 72 | 这样就可以直接对sagemath虚拟机产生的文件进行操作了. 73 | 这种做法的一个小缺点就是每次开启虚拟机后都要\ ``右Ctrl+F1``\ 后用那串命令加载这个文件夹. 74 | 75 | .. |Jupyter Notebook| image:: /images/sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png 76 | :width: 480 77 | .. |Directory Setting| image:: /images/sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png 78 | :width: 480 79 | .. |Plot Example| image:: /images/sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png 80 | :width: 480 81 | .. |Plot Example File| image:: /images/sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png 82 | :width: 480 83 | .. |Win Folder| image:: /images/sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png 84 | :width: 480 85 | -------------------------------------------------------------------------------- /posts/geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan.rst: -------------------------------------------------------------------------------- 1 | .. title: 更真实自然的红楼梦: 黛玉传 2 | .. slug: geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan 3 | .. date: 2016-07-09 19:23:43 UTC+08:00 4 | .. tags: 电视, 文学 5 | .. category: 评论 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 拍红楼梦, 说红楼剧, 想绕过87版, 很难. 就和重拍西游记, 三国一样. 12 | 13 | 作为观众, 我们的情绪也是纠结的: 既希望新剧能忠于经典(大部分人心目中的经典形象基本是87版铬下的), 又希望有新意和超越. 这二者之间本就有冲突, 平衡把握得要好才能让大部分观众满意. 既不能过度保守弄个九分相似的复刻版, 又不能一味创新弄出不伦不类的东西, 例如铜钱头. 14 | 15 | .. TEASER_END 16 | 17 | "黛玉传"在我看来, 在这两个矛盾的分寸拿捏得还算不错. 布景和87版一脉相承, 并不显突兀; 选角也比较合适, 没有过多现代雷剧痕迹; 服装虽不考究但也算符合情节; 情节大致遵循原著且有合理的细节发挥和改动(87版也是对原著有所改动的); 台词虽不那么雅致, 但也算改得自然得体. 18 | 19 | 个人以为"黛玉传"值得一说的几个方面. 20 | 21 | 布景: 很有87红楼的味道, 个人比较喜欢. 而且视频并没有过分后期处理, 更显得普实有古典气息. 我并不喜欢过于造作和雕琢的场景, 例如张艺谋的"英雄"电影那样的场景, 也不喜欢后期处理之后过于鲜艳的色彩, 例如2014版的"神雕侠侣". 我就喜欢有着实实在在生活气息的布景, 有点让人回忆起八九十年代以前一些中国家庭里残留的中式家俱和布置. 当然片子里的布景还达不到精致的程度, 比如庭院回廊等. 一些电脑制作的场景也比较粗糙让人出戏, 比如开片时的场景, 以及大观园的远镜头制作. 其实我很希望以后有人能拍一部更精致的红楼梦, 只是那样需要更高的成本. 22 | 23 | 剧情: 24 | 25 | 关于结局: 我最喜欢和欣赏的一点. 我不算很资深的红迷, 以前受各大红学砖家的影响, 也是一直对后四十回耿耿于怀的. 大多所谓红学学者都认定后四十回是续作, 且众口一辞言之水平不如前八十回. 当我当初读到"苦绛珠魂归离恨天"一回, 哭得死去活来, 最初还一直觉得曹公无敌, 惊叹于一面锣鼓喧天, 一面香消魂断这种强烈反差描写, 后来缓过神来发觉这正是发生在后四十回里的. 后来也有观点认为后四十回"续作"之说子虚乌有, 即后四十回作者也为曹雪芹. 故一些出版社只标注曹雪芹为作者. 我个人而言在对不同版本和说法做了一下小小的调研并结合自己读书的心得, 倾向认为一百二十回出自一人之手. 一来续写出相同味道的红楼梦, 很难, 林语堂已作过这样的评论. 很多对不上的谶语线索, 个人认为只是因为写作上的失误没有照顾周到. 毕竟前八十回即便多次增删还有不少小错误. 毕竟写书不比机械设计, 理应出现的东西却往往因作者精力有限不会恰好出现在那里, 尤其是如此恢弘的长篇小说, 作者不光要考虑行文的合理性, 还要不断地设置草蛇灰线, 还要搜罗诗词歌赋, 原作者说增删十载, 于我这种笨人即使给个一百年也完不成一半. 二来后四十回并不比前八十回差(个人认为), 甚至我印象最深的情节全出自后四十回. 对于那些觉得后四十回差的人, 我唯有一条回应, 你是否能找出一个设计得有焚诗断情更好更让读者悲痛, 却仍然保持诗意的死法? 其文字之悲苦, 行文之老道, 恐怕除了作者本人早早设计好, 没有哪个续写者能写出这样感人肺腑的场景来. 最近浏览了一些雷人的续本(包括各种冒充的版本和真本), 有的虽然经过作者穿凿附会, 所有结局都与前面线索能对上, 可要么情节雷人荒诞, 要么文笔幼稚不堪. 反正读下来这些狗尾的艺术感染力较此四十回都差得太远. 很多人觉得后四十回不够大悲, 不是"白茫茫大地真干净". 一来个人感觉全悲的结局反而显得幼稚造作, 虽如《雷雨》般结局让人一时震撼的哑口无言, 可这样的结局并非曹雪芹前八十回那样悠然叙事的风格. 所有人都死, 宝玉出家 -- 这样的结局初看震撼, 却只有悲而无憾. 反而现在这样的悲而不喜, 似断非断, 遗憾犹存, 难以言表的结局更像是曹公一贯的写作风格, 也更像红楼梦这种史诗级巨著, 而不是雷雨这样的话剧风格. 或许这才是曹雪芹心中"白茫茫大地真干净"的境界, 让你悲痛, 却不绝望, 就是让读者体会伤心只能黯然流泪却无法失声恸哭的无力感. 退一步讲, 即使后四十回是别人续写, 但能达到这样的效果, 若是曹公有知亦会含笑九泉. 如果丢掉这后四十回, 个人觉得前八十回便索然无味了的, 哪怕拼上一些伪作的续本, 也是让整部作品艺术性一落千丈. 26 | 27 | 当然, "黛玉传"没有拘泥于原书的结局, 编剧用自己的理解为我们呈现了另一种合理的结局. 它沿用了书中精彩的部分, 如掉包计和黛玉之死的情节, 并改成十足的悲剧以更适合电视剧播出效果. 美中不足之处便是最后几集结尾过于仓促, 本来"黛玉传"前期对一些细节的刻画是很不错的, 反而在最后几集里, 因为给的篇幅太少, 只能用来描述大的故事脉落, 少了一些细节刻画和必要交待, 让观众的情感来不及跟上节奏(即电视剧的节奏在结尾几集时一改之前的节奏, 忽然变快, 让观众难以适应). 当然值得称道的是该交待的也交待清楚了, 一些情节改动个人非常喜欢, 比如两次抄家, 凤姐的结局(很好地对应了"一从二令三人木,哭向金陵事更哀"的判词), 宝黛掉包场景中也去掉了书中让宝玉丢了玉再让和尚突然归还的设定. 且结局中演员的表演都很到位, 宝玉听到妙玉为己失身的长叹, 李纨性格的转变来衬托世事无常等等. 个人觉得这些改动都很值得肯定, 易于感染观众. 28 | 29 | 台词: 很多人觉得太过于口语化, 其实个人以为反而是一大进步. 过于书面化的台词会让人觉得"作", 就不够自然, 观众很难有代入感. 也有人说台词有些琼瑶化, 大概还是因为剧组并没有在台词改动方面过于用心. 希望下一个红楼剧组能联合一些红学家打造出雅俗共赏的台词来. 30 | 31 | 灯光和化妆是这部剧的缺点, 灯光没有达到自然光和烛光的效果, 虽说使得场景明亮易于拍摄, 但容易让人出戏, 影响一些情感的表达, 如黛玉焚诗断痴情一段, 虽然已具其形却无其实. 在我看来最好能让光线更昏暗些, 摇曳的烛光, 漆黑的夜, 瓢泼大雨, 竹林呜咽, 黛玉形容枯槁, 这才能达到更好的感染力. 过于明亮的现代光源让观众难以融入感情. 32 | 33 | 除此之外, 我觉得宝玉, 凤姐演员很到位, 林妹妹也算不上差, 当然可能有更好的选择. 只是希望以后的红楼剧能多探索, 选角上符合书中品味即可, 不要被87版的印象束缚. 34 | 35 | 总而言之, 这部剧显得更真实自然, 一些改动也值得肯定, 也有一些美中不足. 36 | -------------------------------------------------------------------------------- /posts/org-mode-learning-notes.rst: -------------------------------------------------------------------------------- 1 | .. title: Org-Mode Learning Notes 2 | .. slug: org-mode-learning-notes 3 | .. date: 2016-04-25 12:23:26 UTC+08:00 4 | .. tags: emacs, org-mode 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Org-mode basics 12 | =============== 13 | 14 | - http://orgmode.org/worg/org-tutorials/org4beginners.html 15 | - http://orgmode.org/worg/index.html 16 | - http://orgmode.org/worg/org-tutorials/orgtutorial_dto.html 17 | 18 | .. TEASER_END 19 | 20 | Introduction 21 | ------------ 22 | 23 | Applications: notes, mindmaps, TODO lists, calendar, day planner, object 24 | schedules... 25 | 26 | Lists and Notes 27 | ~~~~~~~~~~~~~~~ 28 | 29 | shortcuts 30 | ^^^^^^^^^ 31 | 32 | - ``tab / shift-Tab``: (un)fold 33 | - ``M-left/right``: promote or demote a headline 34 | - ``M-up/down``: move a headline up or down 35 | - ``M-RET``: insert a new headline 36 | 37 | Plain lists: 38 | ^^^^^^^^^^^^ 39 | 40 | - **Unordered lists** start with ``-,+,*`` (when using ``*`` as a 41 | bullet, lines must be indented or they will be seen as top -level 42 | headlines). 43 | - **Ordered lists** start with a number and a dot. 44 | - **Descriptions** use ``::`` (a blank space is still needed, like 45 | ``- Sean Austin ::``) 46 | 47 | Notes: 48 | ^^^^^^ 49 | 50 | - ``*bold*`` 51 | - ``/italic/`` 52 | - ``_underlined_`` 53 | - ``=code=`` 54 | - ``~verbatim~`` 55 | - ``+strikethrough+`` 56 | 57 | todo 58 | ~~~~ 59 | 60 | shortcuts 61 | ^^^^^^^^^ 62 | 63 | - ``M-shift-RET``: add TODO (call ``org-insert-todo-heading``) 64 | - ``shift-left/right``: cycle workflow 65 | - ``SPC m T``: show todo tree in current document (org-show-todo-tree). 66 | It will show only your current todos and folding the rest away. 67 | - ``C-c a``: agenda (The word **agenda** means *things to be done*) 68 | - ``C-c C-s``: pop up the calendar 69 | - ``C-c [``: add document to the list of agenda files. 70 | - ``C-c ]``: remove document from the list of agenda files 71 | - ``C-c .``: add date 72 | - ``C-u C-c .``: add time and date 73 | - ``C-c C-t``: close task (call ``org-todo``) 74 | 75 | Appointments and deadlines 76 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | 78 | It works in this way: 1. Add a new heading called "Call Fred" 79 | (``M-RET Call Fred``) 2. At the end press ``C-c .`` (if you want to add 80 | a time, use ``C-u C-c .`` instead), which will give the *date chooser* 81 | at the bottom of the screen 3. Type something by hand or use 82 | ``shift-left/right`` to change the date 4. Go to the agenda ``C-c a`` 83 | and press ``a``, you get an agenda entry 5. Use ``C-c [`` to add file to 84 | the agenda, and use ``C-c a a/t`` to view the agenda or list the todos 85 | 86 | Help 87 | ==== 88 | 89 | - ``C-h i``: call the info browser, and use ``tab`` to jump from 90 | hyperlink 91 | - It should be preferred to use ``Org`` menu to convert org file to tex 92 | then pdf file, which looks better than the pdf file generated 93 | directly from ``Pandoc`` menu. 94 | -------------------------------------------------------------------------------- /posts/wrap-angle-to-given-range.rst: -------------------------------------------------------------------------------- 1 | .. title: Wrap Angle to Given Range 2 | .. slug: wrap-angle-to-given-range 3 | .. date: 2016-07-20 13:30:46 UTC+08:00 4 | .. tags: julia, cpp, algorithm 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 问题: 如何将任一个角度值映射到给定范围, 比如[-pi, pi)? 12 | 13 | 方案: 参考 http://stackoverflow.com/questions/4633177/c-how-to-wrap-a-float-to-the-interval-pi-pi 14 | 15 | stackoverflow原文给出了cpp实现: 16 | 17 | .. TEASER_END 18 | 19 | .. code:: cpp 20 | :number-lines: 21 | 22 | static const double _PI= 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348; 23 | static const double _TWO_PI= 6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696; 24 | 25 | // Floating-point modulo 26 | // The result (the remainder) has same sign as the divisor. 27 | // Similar to matlab's mod(); Not similar to fmod() - Mod(-3,4)= 1 fmod(-3,4)= -3 28 | template 29 | T Mod(T x, T y) 30 | { 31 | static_assert(!std::numeric_limits::is_exact , "Mod: floating-point type expected"); 32 | 33 | if (0. == y) 34 | return x; 35 | 36 | double m= x - y * floor(x/y); 37 | 38 | // handle boundary cases resulted from floating-point cut off: 39 | 40 | if (y > 0) // modulo range: [0..y) 41 | { 42 | if (m>=y) // Mod(-1e-16 , 360. ): m= 360. 43 | return 0; 44 | 45 | if (m<0 ) 46 | { 47 | if (y+m == y) 48 | return 0 ; // just in case... 49 | else 50 | return y+m; // Mod(106.81415022205296 , _TWO_PI ): m= -1.421e-14 51 | } 52 | } 53 | else // modulo range: (y..0] 54 | { 55 | if (m<=y) // Mod(1e-16 , -360. ): m= -360. 56 | return 0; 57 | 58 | if (m>0 ) 59 | { 60 | if (y+m == y) 61 | return 0 ; // just in case... 62 | else 63 | return y+m; // Mod(-106.81415022205296, -_TWO_PI): m= 1.421e-14 64 | } 65 | } 66 | 67 | return m; 68 | } 69 | 70 | // wrap [rad] angle to [-PI..PI) 71 | inline double WrapPosNegPI(double fAng) 72 | { 73 | return Mod(fAng + _PI, _TWO_PI) - _PI; 74 | } 75 | 76 | // wrap [rad] angle to [0..TWO_PI) 77 | inline double WrapTwoPI(double fAng) 78 | { 79 | return Mod(fAng, _TWO_PI); 80 | } 81 | 82 | // wrap [deg] angle to [-180..180) 83 | inline double WrapPosNeg180(double fAng) 84 | { 85 | return Mod(fAng + 180., 360.) - 180.; 86 | } 87 | 88 | // wrap [deg] angle to [0..360) 89 | inline double Wrap360(double fAng) 90 | { 91 | return Mod(fAng ,360.); 92 | } 93 | 94 | 95 | 注意: 1. 上面代码中定义了一个类似matlab中mod()的函数. 在Julia里就有mod()函数, 而且与matlab效果一致. 2. 上面的代码中实现了映射到[-pi, pi), 如果需要映射到(-pi, pi], 用Julia实现即: ``mod(theta+pi, -2pi)+pi``, cpp实现如下: 96 | 97 | .. code:: cpp 98 | :number-lines: 99 | 100 | // wrap [rad] angle to (-PI..PI] 101 | inline double WrapPosNegPI(double fAng) 102 | { 103 | return Mod(fAng + _PI, -_TWO_PI) + _PI; 104 | } -------------------------------------------------------------------------------- /posts/git-learning-notes.rst: -------------------------------------------------------------------------------- 1 | .. title: Git Learning Notes 2 | .. slug: git-learning-notes 3 | .. date: 2016-04-25 16:07:58 UTC+08:00 4 | .. tags: git, github 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Git Project 12 | =========== 13 | 14 | A git project can be thought of as having three parts in Figure 15 | *git-parts*: 16 | 17 | - A **Working Directory**: creating, editing, deleting and organizing 18 | files 19 | - A **Staging Directory**: list changes 20 | - A **Repository**: Git permanently stores changes as different 21 | *versions*. 22 | 23 | .. TEASER_END 24 | 25 | .. figure:: /images/git-learning-notes-3parts.png 26 | :alt: git-parts 27 | :width: 480 28 | 29 | 3 parts of a Git project 30 | 31 | Basic 32 | ===== 33 | 34 | - ``git init`` 35 | - ``git status`` 36 | - ``git add filename1, filename2, ...`` 37 | - ``git diff filename.txt`` 38 | - ``git commit -m`` “some message” 39 | - ``git log`` 40 | 41 | Backtrack 42 | ========= 43 | 44 | - ``git show HEAD``: see the most recently made commit 45 | - ``git checkout HEAD filename``: restore the file in your working 46 | directory to look exactly as it did when you last made a commit 47 | - ``git reset HEAD filename``: unstages file changes in the staging 48 | area. This command is used when you want to exclude a specific file 49 | before committing (it has been added to staging area though) 50 | - ``git reset SHA(first 7 characters of the SHA of a previous commit)``: 51 | reset to a previous commit in your commit history. You will lost the 52 | gray commits in Figure *git-reset*. 53 | 54 | .. figure:: /images/git-learning-notes-reset.png 55 | :alt: git-reset 56 | :width: 480 57 | 58 | git reset diagram 59 | 60 | Branching 61 | ========= 62 | 63 | - ``git branch``: check what branch you are currently on. The branch 64 | with an asterisk is the branch you’re on 65 | - ``git branch branchname``: create a branch 66 | - ``git checkout branchname``: switch to a branch 67 | - ``git merge branchname``: if u want to merge a branch *fencing*, you 68 | need to switch to *master* first 69 | 70 | Merge conflict will happen if you made commits on separate branches 71 | that alter the same line in conflicting ways. After merge, we can fix 72 | the merge conflict by hand and then ``add`` and ``commit`` again. 73 | 74 | - ``git branch -d branchname`` delete a branch 75 | 76 | Remotes, Pulling, and Pushing 77 | ============================= 78 | 79 | The remote address is referred to as **origin** by git. 80 | 81 | - ``git clone remote_location clone_name``: get your own replica (named 82 | clone-name) of a remote project 83 | - ``git remote -v``: see a list of git projects’ remotes 84 | - ``git fetch``: fetch any new changes at the remote side (it does not 85 | merge changes from remote into your local repository. It brings those 86 | changes onto what’s called a remote branch.) 87 | - ``git merge origin/master`` merge with remote 88 | 89 | The typical workflow for git collaborations: 90 | 91 | #. Fetch and merge changes from the remote 92 | #. Create a branch to work on a new project feature 93 | #. Develop the feature on your branch and commit your work 94 | #. Fetch and merge from the remote again (in case new commits were 95 | made while you were working) 96 | #. Push your branch up to the remote for review 97 | 98 | - ``git push origin your-branch-name``: push your branch up to the 99 | remote, ``origin``. 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Demo for Bagguette 2 | /bower_components/baguettebox.js/demo/* 3 | 4 | *.db 5 | *~ 6 | *.diff 7 | *.patch 8 | tmp/ 9 | cache/ 10 | output/ 11 | 12 | # GitHub token 13 | .pypt/gh-token 14 | 15 | #  16 | .DS_Store 17 | 18 | # All of .idea should be ignored 19 | .idea/ 20 | .vscode/ 21 | node_modules 22 | 23 | # Created by https://www.gitignore.io/api/pydev,python,pycharm,vim 24 | 25 | ### PyCharm ### 26 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 27 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 28 | 29 | # User-specific stuff: 30 | .idea/**/workspace.xml 31 | .idea/**/tasks.xml 32 | .idea/dictionaries 33 | 34 | # Sensitive or high-churn files: 35 | .idea/**/dataSources/ 36 | .idea/**/dataSources.ids 37 | .idea/**/dataSources.xml 38 | .idea/**/dataSources.local.xml 39 | .idea/**/sqlDataSources.xml 40 | .idea/**/dynamic.xml 41 | .idea/**/uiDesigner.xml 42 | 43 | # Gradle: 44 | .idea/**/gradle.xml 45 | .idea/**/libraries 46 | 47 | # CMake 48 | cmake-build-debug/ 49 | 50 | # Mongo Explorer plugin: 51 | .idea/**/mongoSettings.xml 52 | 53 | ## File-based project format: 54 | *.iws 55 | 56 | ## Plugin-specific files: 57 | 58 | # IntelliJ 59 | /out/ 60 | 61 | # mpeltonen/sbt-idea plugin 62 | .idea_modules/ 63 | 64 | # JIRA plugin 65 | atlassian-ide-plugin.xml 66 | 67 | # Cursive Clojure plugin 68 | .idea/replstate.xml 69 | 70 | # Crashlytics plugin (for Android Studio and IntelliJ) 71 | com_crashlytics_export_strings.xml 72 | crashlytics.properties 73 | crashlytics-build.properties 74 | fabric.properties 75 | 76 | ### PyCharm Patch ### 77 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 78 | 79 | # *.iml 80 | # modules.xml 81 | # .idea/misc.xml 82 | # *.ipr 83 | 84 | # Sonarlint plugin 85 | .idea/sonarlint 86 | 87 | ### pydev ### 88 | .pydevproject 89 | 90 | ### Python ### 91 | # Byte-compiled / optimized / DLL files 92 | __pycache__/ 93 | *.py[cod] 94 | *$py.class 95 | 96 | # C extensions 97 | *.so 98 | 99 | # Distribution / packaging 100 | /build 101 | /dist 102 | *.egg-info/ 103 | .installed.cfg 104 | *.egg 105 | 106 | # PyInstaller 107 | # Usually these files are written by a python script from a template 108 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 109 | *.manifest 110 | *.spec 111 | 112 | # Installer logs 113 | pip-log.txt 114 | pip-delete-this-directory.txt 115 | 116 | # Unit test / coverage reports 117 | htmlcov/ 118 | .tox/ 119 | .coverage 120 | .coverage.* 121 | .cache 122 | nosetests.xml 123 | coverage.xml 124 | *,cover 125 | .hypothesis/ 126 | 127 | # Translations 128 | *.mo 129 | *.pot 130 | 131 | # Django stuff: 132 | *.log 133 | local_settings.py 134 | 135 | # Flask stuff: 136 | instance/ 137 | .webassets-cache 138 | 139 | # Scrapy stuff: 140 | .scrapy 141 | 142 | # Sphinx documentation 143 | docs/_build/ 144 | 145 | # PyBuilder 146 | target/ 147 | 148 | # Jupyter Notebook 149 | .ipynb_checkpoints 150 | 151 | # pyenv 152 | .python-version 153 | 154 | # celery beat schedule file 155 | celerybeat-schedule 156 | 157 | # SageMath parsed files 158 | *.sage.py 159 | 160 | # dotenv 161 | .env 162 | 163 | # virtualenv 164 | .venv 165 | venv/ 166 | ENV/ 167 | 168 | # Spyder project settings 169 | .spyderproject 170 | .spyproject 171 | 172 | # Rope project settings 173 | .ropeproject 174 | 175 | # mkdocs documentation 176 | /site 177 | 178 | ### Vim ### 179 | # swap 180 | [._]*.s[a-v][a-z] 181 | [._]*.sw[a-p] 182 | [._]s[a-v][a-z] 183 | [._]sw[a-p] 184 | # session 185 | Session.vim 186 | # temporary 187 | .netrwhist 188 | *~ 189 | 190 | # End of https://www.gitignore.io/api/pydev,python,pycharm,vim 191 | -------------------------------------------------------------------------------- /posts/build-github-pages-with-cryogen.rst: -------------------------------------------------------------------------------- 1 | .. title: Build Github Pages with Cryogen 2 | .. slug: build-github-pages-with-cryogen 3 | .. date: 2016-04-25 12:22:27 UTC+08:00 4 | .. tags: clojure, github, web 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Why Cryogen? 12 | ============ 13 | 14 | Cryogen是用Clojure写的一个static site generator. 它的优点在于: 15 | markdown支持良好(包括Clojure语法高亮, 也支持AsciiDoc), 支持RSS, toc, 16 | Disqus, Sitemap, 可以使用tags, 移动网页友好, 易上手等. 17 | 最主要是我自己比较喜欢Clojure, 因此就没有考虑使用其它框架. 18 | 19 | .. TEASER_END 20 | 21 | 创建过程 22 | ======== 23 | 24 | 首先参考Cryogen官方指导熟悉创建新页面的流程和设置: `Getting 25 | Started `__ 26 | 27 | 下来准备在Github上搭建一个静态博客: 28 | 29 | - 在Github上创建两个空的repo, 名字分别叫 ``cryogen-blog`` 和 30 | ``defnil.github.io``, 其中 ``defnil`` 是我Github的用户ID, 31 | 使用时需要换成你自己的ID. 注意不要包含readme或gitignore等文件. 32 | 33 | - 打开命令行, ``cd`` 到你想要创建项目的位置, 如 ``C:/home``, 34 | 下面语句将创建一个 ``C:/home/my-blog`` 的项目: 35 | 36 | .. code:: shell 37 | 38 | cd C:/home 39 | lein new cryogen my-blog 40 | 41 | - 运行server, 它会在发任何变化后重新编译 42 | 43 | .. code:: shell 44 | 45 | cd my-blog 46 | lein ring server 47 | 48 | - 编辑配置文件 ``my-blog/resources/templates/config.edn``, 49 | 修改以下几项, 其余可以保持默认值: 50 | 51 | - :site-url “https://defnil.github.io” 52 | - :blog-prefix “” 53 | - :site-title “My Awesome Blog” 54 | - :author “defnil” 55 | - :description “Nothing yet” 56 | 57 | - 打开一个新的terminal, 运行: 58 | 59 | .. code:: shell 60 | 61 | cd C:/home/my-blog 62 | git init 63 | git add . 64 | git commit -m "first commit" 65 | git remote add origin git@github.com:defnil/cryogen-blog.git 66 | git push -u origin master 67 | 68 | - 上面这些命令只是push到 ``cryogen-blog`` 这个repo里, 并没有创建blog. 69 | 因此再运行下面命令将博客内容push到我们的blog site里, 即 70 | ``defnil.github.io`` 这个repo. 71 | 72 | .. code:: shell 73 | 74 | cd resources/public 75 | git init 76 | git add . 77 | git commit -m "first blog commit" 78 | git remote add origin git@github.com:defnil/defnil.github.io.git 79 | git push -u origin master 80 | 81 | - 如果顺利的话, 现在使用流览器访问 ``defnil.github.io`` 82 | 就会出现建好的blog了. 83 | 84 | 编辑blog 85 | ======== 86 | 87 | 关于如何写post请查看 `Writing 88 | Posts `__, 89 | 发布前可以通过访问 ``localhost:3000`` 查看效果. 90 | 91 | 发布更新 92 | ======== 93 | 94 | 每次更新blog后, 运行以下命令: 95 | 96 | .. code:: shell 97 | 98 | cd C:/home/my-blog 99 | lein ring server 100 | git add . && git commit -am "WIP" && git push 101 | cd resources/public && git add . && git commit -am "WIP" && git push && cd ../../ 102 | 103 | MathJax 支持 104 | ============ 105 | 106 | 将下面代码 107 | 108 | .. code:: html 109 | 110 | 114 | 117 | 118 | 直接嵌入到模板文件中, 比如如果使用的是blue主题(默认主题), 则修改 119 | ``templates/themes/blue/html/base.html`` 内容, 将上面内容放在该文件 120 | ``head`` 部分即可. 参考 121 | `issue59 `__ 122 | 123 | Read More 124 | ========= 125 | 126 | - `Referred 127 | Post `__ 128 | - To setup custom domain name with namecheap check this 129 | `link `__. 130 | - If you do add custom domain name make sure you add CNAME to 131 | :keep-files otherwise it’ll get deleted. 132 | 133 | -------------------------------------------------------------------------------- /templates/book.tmpl: -------------------------------------------------------------------------------- 1 | ## -*- coding: utf-8 -*- 2 | <%namespace name="helper" file="post_helper.tmpl"/> 3 | <%namespace name="pheader" file="post_header.tmpl"/> 4 | <%namespace name="comments" file="comments_helper.tmpl"/> 5 | <%inherit file="post.tmpl"/> 6 | 7 | <%block name="extra_head"> 8 | ${parent.extra_head()} 9 | 10 | 77 | 78 | 79 | <%block name="content"> 80 |
81 |
82 |
83 |
84 |

${post.title()}

85 | ${post.text()} 86 |
87 |
88 |
89 |
90 | 91 | 92 | <%block name="extra_js"> 93 | 94 | 117 | 118 | -------------------------------------------------------------------------------- /posts/yu-ming-xiang-guan-chang-shi.rst: -------------------------------------------------------------------------------- 1 | .. title: 域名相关常识 2 | .. slug: yu-ming-xiang-guan-chang-shi 3 | .. date: 2016-05-16 12:52:40 UTC+08:00 4 | .. tags: domain 5 | .. category: notes 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 介绍 12 | ===== 13 | 14 | 自己只是打算建一个 Github Page 绑定到个人域名, 在注册域名的过程中慢慢了解了该行业的一些状况. 大多是基本常识, 还有一些个人看法, 属于个人笔记性质. 15 | 16 | .. TEASER_END 17 | 18 | 相关基本概念 19 | ============ 20 | 21 | 域名 22 | ####### 23 | 24 | 一个网站就像是一部可以打电话的手机, 域名就是那个手机号. 而网站的搭建过程就像是买手机. 25 | 好的手机号可以卖到很贵的价钱, 好的域名也同样非常贵. 从而导致不少人从事倒卖域名的生意, 甚至有的域名会以天价出售. 26 | 这里所说的域名指顶级域名 (TLDs: top-level domains). 更多信息可以参考维基百科"域名"词条. 27 | 28 | gTLD 和 ccTLD: 29 | ############### 30 | 31 | - gTLD (generic top-level domains 通用顶级域名) 在我看来可以分为两种: 一种是老的通用顶级域名, 32 | 如 .com, .net, .org, 这几个域名后缀是第一批启用的常用域名 (1985年), 因此接受程度也最广泛, 大众则对 .com 最为熟悉. 33 | 后来还陆续启用了一些接受度也还可以的通用域名, 如 .info, .biz 等. 34 | 另一种 gTLD 是再后来通过的一些域名后缀, 如 .top, .wang, .xyz, 等等, 称之为 new gTLD. 绝大多数 gTLD 都是三个字母或更多. 35 | 36 | - ccTLD (country code top-level domains 国家域名) 由两个字母构成, 标识着各个国家和一些地区, 如 .cn, .jp, .tw, .hk 等. 37 | 38 | ICANN 推出不同的域名后棳的最初目的是为了满足不同类型网站的需要. 当初设定 .com 目标群体是公司, .org 为非营利组织, 39 | 但在后来取消了对绝大多数 gTLD 的注册限制, 比如现在个人也可以使用 .com 或 .org 做为自己的博客, 营利性的公司也可以使用 .org 等. 40 | 41 | 关于域名炒作 42 | ############ 43 | 44 | 在国外域名买卖网站上, 有两个词, 一个叫 Chip (Chinese premium), 域名中都是由中国人比较偏爱的声母字母构成, 即: 45 | 除过 a, e, i, o, u 以及 v 以外的其它字母. 另一个词便是 western premium, 字母质量可以分为三类, 46 | 西方人看来, 第一档 premium letters, 包括 A, B, C, D, E, F, G, H, I, L, M, N, O, P, R, S, T. 47 | 第二档 average letters, 包括 J, K, U, V, W, Y. 最后一档 Q, X, Z. 这两种叫法尤其在短域名中比较常见. 48 | 49 | 当前域名炒作有下面这几种风气: 50 | 51 | .com 域名过度炒作: .com 的资源是有限的, 好的域名更少. 中国现下楼市股市都不景气的情况下, 一些资本开始进入域名投资行业. 52 | 随之带动一大批普通民众(小白)跟风进入. 导致很多域名都被注册一空, 当前而言, .com 中, 所有5位以内的数字, 所有4位以内的字母都已经被注空. 53 | 这些域名价钱也一路攀升, 当然这其中也有国外炒家的功劳. 因为中国炒家对声母的执著, 现在连5声母域名也开始被批量注册. 54 | 55 | 点评: 从一个建网站的人来看, 这些被屯在投资人手里的很多域名是没有价值的. 五声母域名更是纯属搞笑, 我不觉得用五个声母做网址用户就容易记往. 56 | 至于一些人甚至脑筋都动到6, 7位数字上去了. 截至 2015 年 12 月, 中国网站数量为 426.7 万个,年增长 26.3%,为历年来增速最高, 57 | 来源 `中国互联网站发展状况及其安全报告2016 `_. 其中 .com 使用了 350 万个, 58 | 而投机者手里的 .com 持有量远不止这个数字. 相当大一部分域名都只会在域名市场流通而不会被 end user 使用. 59 | 因此域名市场本身的泡沫远不是手机号码可以相比的. 60 | 61 | .net, .org 在中国的边缘化: 这两个域名在中国接受度普遍不高, 因此价值比 .com 低出不少. 这一现象在国外也比较类似, 但没有中国这么严重. 62 | 即使如此, .net 的4字母域名也早已被中国炒家全部扫空了. 而比它们更惨的 .info 因为早期的垃圾网站较多, 导致口碑一直受损. .biz 则在中国水土不服, 63 | 使用者更是少之又少. 64 | 65 | 新域名的不明朗: 一个新域名的出名通常都与一些注册商的宣传有关. 比如在国外的 .xyz 和中国的 .wang. 这些域名都很难一直持续受到关注, 66 | 一是因为长时间的推广成本较高, 二来 ICANN 每年都在不停地推出更多新域名方便用户(和捞钱), 从而冲击之前的新域名市场. 67 | 68 | 国家域名的炒作: 因为新域名越出越多, 且多为3字母或更长的后缀, 数量稳定且后缀更短的国家域名就受到很多网站的亲睐. 69 | 比如从前几年开始慢慢走入大家视线的 .me, 其主要还是用于个人网站, 国内则有一些初创企业使用. 国外互联网初创企业则更偏好 .io 域名, 最近也比较流行. 70 | 其它一些常见国家域名, 比如众所周知被炒作了很久的 .co, 在国外也被当作商业网站来使用, 以及名气稍低些的 .cc 域名. 国内域名市场甚至炒过 .cm 域名, 71 | 可谓凡是和字母 c 沾上点光就可以炒一炒. 针对国家域名的投资, 主要还是和时间段有关. 有的域名火上一段时间后可能因为缺少商家的持续宣传便从大众视线中消失. 72 | 有一些则会慢慢浮出水面, 比如近期国内有人关注和炒作 .ee, .gg 这样的叠字后缀, 但真正应用于通用网站的还是不多见. 73 | 74 | 关于购买国家域名的一些注意事项: 75 | 76 | 1. 自由度: 77 | 78 | 事实上并非所有的国家域名都可以自由持有. 比如 .us 虽然注册容易, 但事实上官方是要求持有者具备一定身份要求 (美国公民等等), 79 | 因此对于普通网民, 即使持有很好的域名, 但如果被举报或是审请仲裁, 所有者极有可能失去持有资格. 没有使用限制的 ccTLD 可以参考 `Wikipedia `_. 事实上维基的这个列表也不尽正确, 因为有一些还是有注册要求的, 比如表中的 .ca 注册是需要加拿大相关身份的, 参见 `这里 `_. 比较自由和常见的就是 cc, co, ch, in, io, la, li, me, nu, tv, ws 这些后缀. 80 | 81 | 2. 目标群体: 82 | 83 | 默认情况下, 不同的 ccTLD 网站会被 Google 展现给不同地区的受众: `参考 `_. 在 Google 的这份列表里, 专门提到 以下几种国家域名是被默认作为全球受众的, 像 gTLD 一样收录. 即: .ad .as .bz .cc .cd .co .dj .fm .io .la .me .ms .nu .sc .sr .su .tv .tk .ws 这些国家域名. 如果你使用了一个不在此列表中的国家域名, 也可以专门向 Google 提交和设置你的网站区域选项. 84 | 85 | 3. 域名安全性: 86 | 87 | 因为政治因素, 一些国家域名并不稳定. 有一些 ccTLD 已经被删除, 如 .cs, .dd, .zr, 也有一些正在逐步淘汰, 如 .tp, .su. 所以这些 ccTLD 尽量不要去使用和注册. 可以参考维基"域名"词条中关于国家地区代码顶级域名中的描述. 88 | 89 | 域名后缀的选择 90 | ============== 91 | 92 | 域名后缀并没有什么严格的选择标准, 以个人观点, 如果是公司, 最好选择 .com, 受众广, 易推广. 虽然在只考虑国内受众的情况下可以使用 .cn, 但政策风险仍然是有的, 个人觉得能不使用就尽量不使用. 如果是做个人网站或博客, 名字优先, 后缀其次. 你可以尽量找一个可以注册到自己喜欢的名字的后缀, 毕竟个人网站, 非常见后缀体现出的个性化反而不是什么坏事, 比如常用的 .org 和个性化的 .me, 以及程序员们喜欢的 .io 都挺不错. 如果你名字中有li, wang, la, nu 等发音的字, 可以采用这些域名进一步体现个性 (使用前请先确认该国家域名的 registration requirements). 93 | -------------------------------------------------------------------------------- /posts/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji.rst: -------------------------------------------------------------------------------- 1 | .. title: Alexa 前100万网站域名后缀统计 2 | .. slug: alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji 3 | .. date: 2016-05-29 01:18:51 UTC+08:00 4 | .. tags: web, domain 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 记得前两天看到一篇 `文章 `_, 讲了 ``.io`` 域名在 Alexa 网站排名中的一些事情. 我就很想知道在 Alexa 这个榜单里, 各种 domain extension 都占了多大的份额, 想看看最流行的这些网站的建设者都喜欢用哪些主流和非主流的域名后缀. 12 | 13 | .. TEASER_END 14 | 15 | 第一步, 数据. Alexa 网站提供世界排名前100万的网站 `榜单 `_, 但这个 ``.csv`` 格式的榜单是每日更新的, 数据是根据近一个月的访问量而定. 16 | 17 | 第二步, 排序. 主要还是依靠 Excel. 先将数据另存为 ``.xlsx`` 格式, 如下图: 18 | 19 | |Sample list| 20 | 21 | 原始数据只有A列和B列. 我们将后缀提取出来, 放在C列. 这里我们在C1中输入 ``=RIGHT(B1,LEN(B1)-SEARCH(".",B1))``, 就会将B列中的网址按第一个 ``.`` 做分割, 保留后面的域名后缀部分. 因为列很长, 所以用鼠标拖动的办法不是很好用, 因此可以使用下面的方法可以为整列应用公式, (出处: `superuser `_): 22 | 23 | 1. Copy your formula ``Ctrl + C`` 24 | 2. press ``↓`` 25 | 3. ``Ctrl + Shift + ↓`` selects to the last nonblank cell 26 | 4. paste ``Ctrl + V`` 27 | 28 | 然后是统计C列的频率, 呈现在E, F列里. 操作: 29 | 30 | 1. 先将B列中所有内容复制到E列,然后选中E列,在 ``数据`` 标签中点击 ``删除重复项``, 在弹出窗口中选择 ``以当前选定区域排序`` 按钮, 最后确定即可. 31 | 2. 在F1中输入 ``=COUNTIFS(C:C,E1)``, 并用上面的方法将这个公式应用到整个对应的F列 32 | 33 | 有了F列的数据, 就可以按F列进行排序了. 这份2016年5月27日的100万个网址里, 共计使用了2040种不同的后缀(``.org.cn`` 与 ``.cn`` 属不同后缀). 前100种如下: 34 | 35 | .. code:: 36 | 37 | com 478452 38 | net 52342 39 | ru 47759 40 | org 45897 41 | de 23015 42 | jp 15089 43 | co.uk 12931 44 | ir 12750 45 | com.br 12367 46 | it 12028 47 | in 10255 48 | fr 10237 49 | info 10152 50 | pl 9293 51 | co.jp 8115 52 | nl 7295 53 | es 6446 54 | cn 6141 55 | com.au 5750 56 | gr 4901 57 | cz 4712 58 | co.kr 4704 59 | co 4442 60 | eu 4151 61 | tv 3978 62 | ca 3937 63 | me 3639 64 | ro 3499 65 | edu 3398 66 | se 3298 67 | biz 3270 68 | com.cn 3178 69 | tumblr.com 3158 70 | blogspot.com 3050 71 | hu 2897 72 | co.za 2880 73 | com.tr 2693 74 | tmall.com 2665 75 | com.tw 2565 76 | be 2510 77 | ch 2474 78 | io 2325 79 | wordpress.com 2300 80 | com.ua 2239 81 | dk 2200 82 | xyz 2174 83 | at 2087 84 | no 1988 85 | us 1978 86 | sk 1914 87 | com.ar 1913 88 | fi 1815 89 | co.in 1806 90 | com.mx 1790 91 | cc 1733 92 | vn 1638 93 | by 1573 94 | livejournal.com 1441 95 | gov.cn 1395 96 | kz 1387 97 | cl 1374 98 | co.il 1347 99 | pt 1310 100 | ua 1268 101 | org.uk 1244 102 | top 1217 103 | blogspot.co.id 1207 104 | or.jp 1192 105 | gov 1191 106 | ie 1142 107 | bg 1135 108 | kr 1113 109 | lt 1089 110 | su 1047 111 | co.id 1031 112 | gov.in 988 113 | blogspot.in 988 114 | mx 953 115 | club 937 116 | az 848 117 | xn--p1ai 812 118 | ac.in 791 119 | co.nz 768 120 | com.my 722 121 | pk 722 122 | nic.in 719 123 | edu.cn 705 124 | tw 698 125 | hr 696 126 | ne.jp 683 127 | pro 683 128 | or.kr 674 129 | org.br 671 130 | mobi 657 131 | lv 656 132 | com.sg 642 133 | ae 634 134 | pw 632 135 | com.hk 627 136 | ac.jp 611 137 | 138 | 排前面的几种 com, net, ru, org, de 都不出人所料, 都超过了2万个. 为画图方便, 我们在下面的统计图中把这前5个略去, 看一下这前100个后缀的分布情况: 139 | 140 | |Domain share| 141 | 142 | 有一些现象也比较值得注意, 比如 ``.biz`` 后缀越来越边缘化, 已排到了31名, 落后很多国别域名. 在注册商们的大力推广(忽悠)下, ``.co`` 也的确越来越受到认可, 排在了23名. 其它近些年比较受初创企业欢迎的域名后缀也都表现不错, ``.tv`` 25名, ``.me`` 27名, ``.io`` 42名, 而曾经被注册商大力忽悠的 ``.cc`` 55名, 忽悠中的 ``.pw`` 98名, 以及几年前一些国外初创企业偏好的 ``.ly`` 253名. 一些 new gTLD 也慢慢受到认可, 比如 ``.xyz`` 46名, ``.top`` 66名, ``.club`` 79名, ``.pro`` 91名, ``.tech`` 102名, 等等. 这份排名在注册非 ``.com`` 域名后缀时也有一定的参考意义. 143 | 144 | .. |Sample list| image:: /images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png 145 | :width: 480 146 | .. |Domain share| image:: /images/alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png 147 | :width: 480 -------------------------------------------------------------------------------- /posts/julia-packages.rst: -------------------------------------------------------------------------------- 1 | .. title: Julia Packages 2 | .. slug: julia-packages 3 | .. date: 2017-03-18 09:05:10 UTC+08:00 4 | .. tags: julia 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | 10 | .. sectnum:: 11 | 12 | .. contents:: 13 | 14 | .. TEASER_END 15 | 16 | Commands 17 | ================== 18 | 19 | - ``Pkg.update()`` Update the package database 20 | - ``Pkg.status()`` List the information of all installed packages 21 | - ``Pkg.resolve()`` Let Julia resolve package dependencies automatically 22 | - ``Pkg.add("HDF5")`` Install package ``HDF5`` 23 | - ``using HDF5`` Include the package ``HDF5`` in the current file 24 | 25 | 26 | Packages I Am Using 27 | ====================== 28 | 29 | BenchmarkTools 30 | ------------------- 31 | 32 | A benchmarking framework for the Julia language `GitHub `__ 33 | 34 | - ``@btime sin(1)`` Print the minimum time and memory allocation before returning the value of the expression ``sin(1)`` 35 | - ``@belapsed sin(1)`` Simplified version of ``@time``, only print the minimum time (unit: second) 36 | - ``@benchmark sin(1)`` Full version of ``@btime``, print all the information of the benchmarking 37 | 38 | HDF5 39 | --------- 40 | 41 | Saving and loading data in the HDF5 file format `GitHub `__ 42 | 43 | - ``h5write("filename.h5", "/nameA", A)`` Write array ``A`` to a dataset named "nameA" inside the root group. Use "mygroup/nameA" to write data inside "mygroup" 44 | - ``B = h5read("filename.h5", "/nameA")`` Read dataset "nameA" and set the value to ``B``. 45 | 46 | .. code:: julia 47 | 48 | if isfile("filename.h5") # if the file already exists, delete it 49 | rm("filename.h5") 50 | end 51 | h5write("filename.h5", "/nameA", A) # write 52 | B = h5read("filename.h5", "/nameA") # read 53 | 54 | PyPlot 55 | ------------- 56 | 57 | Plotting for Julia based on matplotlib.pyplot `GitHub `__ 58 | 59 | - ``plot(Xdata, Ydata, ".")`` 60 | - ``plot(Xdata, Ydata, color="red", linewidth=2.0, linestyle="--")`` 61 | - ``title("A sinusoidally modulated sinusoid")`` 62 | 63 | 64 | Useful Packages 65 | ===================== 66 | 67 | `JuliaPro `__ provides a list of commonly used packages: 68 | 69 | General programming 70 | ----------------------- 71 | 72 | - DataStructures `GitHub `__ 73 | - LightGraphs `GitHub `__ 74 | 75 | General Math 76 | ---------------- 77 | 78 | - Calculus `GitHub `__ 79 | - DataFrames `GitHub `__ 80 | - StatsBase `GitHub `__ 81 | - Distributions `GitHub `__ 82 | - HypothesisTests `GitHub `__ 83 | - GLM `GitHub `__ 84 | 85 | Optimization 86 | ---------------- 87 | 88 | - JuMP `GitHub `__ 89 | - Optim `GitHub `__ 90 | - Roots `GitHub `__ 91 | 92 | Databases 93 | ------------- 94 | 95 | - ODBC `GitHub `__ 96 | - JDBC `GitHub `__ 97 | 98 | Building UIs and Visualization 99 | ---------------------------------- 100 | 101 | - Gadfly `GitHub `__ 102 | - PyPlot `GitHub `__ 103 | - Interact `GitHub `__ 104 | 105 | Deep Learning and Machine Learning 106 | --------------------------------------- 107 | 108 | - Mocha `GitHub `__ 109 | - MXNet `GitHub `__ 110 | - Knet `GitHub `__ 111 | - Clustering `GitHub `__ 112 | - DecisionTree `GitHub `__ 113 | 114 | Interoperability with other languages 115 | ----------------------------------------- 116 | 117 | - RCall `GitHub `__ 118 | - JavaCall `GitHub `__ 119 | - PyCall `GitHub `__ 120 | 121 | File and data formats 122 | -------------------------- 123 | 124 | - JSON `GitHub `__ 125 | - HDF5 `GitHub `__ 126 | - JLD `GitHub `__ 127 | 128 | Economics and Finance 129 | ------------------------- 130 | 131 | - QuantEcon `GitHub `__ 132 | -------------------------------------------------------------------------------- /posts/org-to-rst-notes.rst: -------------------------------------------------------------------------------- 1 | .. title: Org to rst Notes 2 | .. slug: org-to-rst-notes 3 | .. date: 2016-04-25 18:43:39 UTC+08:00 4 | .. tags: org-mode, web 5 | .. category: tools 6 | .. link: 7 | .. description: convert .org to .rst files for Nikola with Pandoc 8 | .. type: text 9 | .. author: YONG 10 | 11 | I’m using ``Nikola`` for site generating, which supports various types 12 | of input formats: ``.rst`` natively, ``.md`` partially, ``.org`` via 13 | ``orgmode`` plug-in, .., etc. No one seems perfect for me: 14 | 15 | .. TEASER_END 16 | 17 | - ``.rst`` worse readability than other two, also has the worst syntax 18 | among the three for writing too 19 | - ``.md`` easy to use but there are no **standard** rules to follow: 20 | different parsers deliver different (even inconsistent) rendering 21 | styles 22 | - ``.org`` uniform standard and easy to write, but no perfect parser 23 | exists. Also it is bound to ``Emacs``, which makes it not handful 24 | sometimes. 25 | 26 | Before deciding to use ``.rst`` as my primary format for ``Nikola``, I 27 | tried several ways: 28 | 29 | #. Use ``.md`` 30 | 31 | Since I’m used to editing markdown files in ``Atom``, which is more 32 | lightweight than ``Emacs`` IMO. What makes me annoyed is that the 33 | rendering styles from ``Atom`` and ``Nikolas`` are not the same, 34 | especially when it comes to code blocks within lists. Following 35 | `this `__, it 36 | says markdown supports multiple paragraphs inside list items: 37 | 38 | List items may consist of multiple paragraphs. Each subsequent 39 | paragraph in a list item must be indented by either 4 spaces or 40 | one tab: 41 | 42 | #. This is a list item with two paragraphs. Lorem ipsum dolor sit 43 | amet, consectetuer adipiscing elit. Aliquam hendrerit mi 44 | posuere lectus. 45 | 46 | Vestibulum enim wisi, viverra nec, fringilla in, laoreet 47 | vitae, risus. Donec sit amet nisl. Aliquam semper ipsum sit 48 | amet velit. 49 | 50 | #. Suspendisse id sem consectetuer libero luctus adipiscing. 51 | 52 | There are two issues: 53 | 54 | #. Code blocks are not recognized anymore if you put indented code 55 | blocks after list items. Instead, they are treated as block quotes 56 | by ``Nikola``. Thus no syntax highlight for these blocks, and even 57 | worse, the source code in the blocks is concatenated without any 58 | line breaks. 59 | 60 | #. If you put an indented paragraph after an indented code block, the 61 | texts in the paragraph are also transformed into block quotes. 62 | 63 | IMO, this is due to Markdown’s bad design or non-uniform standards of 64 | different parsers (or bugs). Because sometimes texts after 4 65 | successive blank spaces are directly treated as block quotes or code 66 | blocks. This makes it ambiguous to separate them from paragraphs in 67 | lists, and things become more tricky if you have a nested list. 68 | 69 | But for ``.org`` format, the rule is clear: just align your contents 70 | with the list they belong to, no matter what style of your contents 71 | are: they can be plain texts or even code blocks. 72 | 73 | #. Use ``.org`` 74 | 75 | It seems reasonable to use ``.org`` files for web page generating 76 | thanks to the ``orgmode`` plug-in provided by ``Nikola``. It seems a 77 | promising solution, but wait! Once you picked a nice theme, and built 78 | your site, you found there might have a lot of things to tweak: You 79 | need to add ``.css`` files to your theme for code highlighting to 80 | make your site look pleasing. Also you need to be careful with the 81 | special syntax used by ``org-mode`` of ``Emacs``. I found there are a 82 | lot of weird errors on the published web page using the ``orgmode`` 83 | plug-in. Anyway, it works but brings you lots of troubles if you are 84 | careless. Also, the plug-in works by calling the publish related 85 | functions of ``Emacs``, which makes it slower if you are holding a 86 | large website. 87 | 88 | #. Use ``.rst`` 89 | 90 | Yeah, finally it comes to the natively supported format. At first I 91 | am quite reluctant to choose this option because I don’t want to 92 | learn a new markup language since I have known ``Markdown`` and 93 | ``Org-mode``. But later on, I found a workaround: I edit all the 94 | stuff within ``Emacs`` using ``.org`` format, and use ``Pandoc`` to 95 | convert all the ``.org`` files to ``.rst`` files for web page 96 | generation. At the beginning, I was wondering whether ``Pandoc`` will 97 | give me satisfactory results – it turns out not that bad, though not 98 | perfect. I believe this can be attributed to the unified standards of 99 | both ``.org`` and ``.rst`` formats, which make the parser less 100 | error-prone. Overall, the converted file have few errors from my own 101 | experience. Also by writing a simple script, I can convert all 102 | existing files to ``.rst`` files with ``Pandoc`` in batch. Thus I 103 | don’t need to worry the formats when I’m writing in ``org-mode`` from 104 | now on. 105 | 106 | Several points to note after converting: 107 | 108 | - Images in ``.org`` files are like ``./images/pic.png``, while in 109 | resulted ``.rst`` files you need to change them to 110 | ``/images/pic.png`` manually. 111 | - Literal examples (``BEGIN_EXAMPE``) in ``.org`` files are converted 112 | to ``.. code:: example``, which cannot be recognized by ``Pygments``. 113 | So just change them to ``.. code::`` manually. 114 | -------------------------------------------------------------------------------- /pages/notes/2016-05-2016-07.rst: -------------------------------------------------------------------------------- 1 | .. title: 2016.05 - 2016.07 2 | .. slug: 2016-05-2016-07 3 | .. date: 2016-05-09 14:05:50 UTC+08:00 4 | .. tags: 5 | .. category: micro 6 | .. link: 7 | .. description: 8 | .. type: micro 9 | .. author: YONG 10 | 11 | 2016-09-13 22:17 12 | 13 | 今天又从朋友圈看到一篇文章, 类似之前的"寒门再难出贵子", 也讲了BBC拍摄的那个反映阶层固化的超长跨度的纪录片. 文中表达了很重要的一点, 就是越有钱的人赚钱越快, 所谓马太效应. 这个和Dota游戏非常像, 越有钱(装备越好)的人, 打钱(farm)效率会更高. 另一个思想, 就是财富是靠积累的. 靠一个人, 一代代的积累. 其实细想来人生中可贵的东西绝大多数都是要积累的, 经验, 名誉, 以及智慧, 都是靠平时的涓滴积累而成. 积累对应英文accumulate, 累加, 有一些靠近积分的意思了, 也的确有化零为整之义. 很多人经历得多, 人本身却没有长进, 便是疏于积累, 让这些"涓滴"从手心白白流走了. 又想起一句老掉牙的话, 好记性不如烂笔头(十年前的我是对这句话不屑一顾的), 很多东西, 比如此刻的想法, 又比如昨夜的一个梦, 都在当前生动无比, 可两三天后, 一个月后, 十年后, 大概绝大多数都不会再记得了. 所以我要从现在起勉励和强迫自己勤"写", 以此来尽量补救这个健忘的大脑. 说到梦, 前两天忽然梦见在大学的自习室(三教)写作业. 细想来自己已经有好多年没有泡过自习室了, 真是遗憾. 14 | 15 | ---- 16 | 17 | 2016-09-08 02:41 18 | 19 | 晚上看了唐人街探案, 的确没有让人失望. 就像有网友评论的那样, 多条线索齐头并进, 有疯狂的石头的感觉. 20 | 21 | ---- 22 | 23 | 2016-08-24 23:32 24 | 25 | 最近非常非常痴迷GitHub, 用于管理记录自己的工作和生活, 简直太好用. 最喜欢的是它对org文档的渲染支持, 无论是写起来还是看起来都很舒心. 而且用它来记录东西的时候, 发现自己也没有像以前那么散漫, 那么容易浪费时间了. 26 | 27 | ---- 28 | 29 | 2016-08-22 02:01 30 | 31 | 清理了一回宿舍, 筋疲力尽. 如果没记错的话, 这是我住这里之后第一次手动清理自己的宿舍桌面和杂物. 桌上乱七八糟的东西堆成了山, 从里面竟然找回了6支笔! 连桌下面到处都是蜘蛛网, 我也居然能在这样的环境里住了两年:( 32 | 33 | ---- 34 | 35 | 2016-08-18 18:13 36 | 37 | 今天Github帐号因为被当成机器人了, 封禁了半天, 所幸联系Github员工问题得到了解决. 但的确发现很不安全, 一旦被系统封禁, 连Github Pages也无法正常访问. 大概是因为我复制了一段长的代码到Gist, 就被系统识别为机器人了. 另, Gist的确好用, 还可以用来做任务规划, 因为可以track变化, 很给力好吧:D 可惜今天才发现它的妙用. (19日补充: 已弃用Gist, 因为没有好的归类. 还是放在Repo里查阅着比较方便. 特地做了一个tasks的repo用来规划自己每天的行动) 38 | 39 | ---- 40 | 41 | 2016-08-10 13:53 42 | 43 | 昨晚本来想看Ti6, 1点的时候喝了罐红牛, 后来接近3点的时候准备睡觉却一直不能入睡, 早上快6点的时候才睡, 8点半起来(以为9点半会有group meeting, 结果是已经改到了下午4点). 直到现在还是迷迷糊糊的. 得知OG被TNC淘汰, 看了两场比赛的录像, OG打得并不算太差, 只能说TNC的bp和发挥都太好. 现在正在看第二场, TNC小黑+VS双光环, 哈斯卡输出能进一步提高. 小黑主要是以肉装保命为主, 双刀冰眼蝴蝶大推推, 并没有像最近其他战队流行的出电锤A杖. 又想起今年2月TNC巅峰联赛被MVP打出超级兵后上互拆翻盘. 另外LGD被淘汰倒也不是太意外. 44 | 45 | ---- 46 | 47 | 2016-08-09 01:49 48 | 49 | 再次折腾了一次, 把之前用的 oxyz.org 换成现在的 yongchen.org. 后者是前段时间看到有人drop后马上注册的. 这个年头两个字的名字就是比较蛋疼, .com的双拼想都不用想, .net和.org要看人品了. 更不要指望能注册一个单拼做自己网站了. 虽说各种新后缀也有可能, 总归看着别扭, 别人也难记住. 而且下午用脚本扫了一遍Github的用户名, 终于发现一个好记的单词还没有被注册, 即cafe. 以后就主要使用这个帐户了. 删除了之前电脑里的SSH Key等, 添加了现在的这个帐户. 相信如果有空可以直接做一个 cafe.github.io 的网页不绑定任何其它域名也很容易带来流量, 罢了罢了, 以后再说吧. 今天看到知乎上有人讨论独立博客是否还有前途, 有人回答得很好, 写博客只是为培养自己不断学习的习惯, 并不在乎所谓前途不前途. 另一宗, 独立博客从不用担心什么敏感词, 更不用担心sb管理员, 即所谓自由. 50 | 51 | ---- 52 | 53 | 2016-05-24 00:29 54 | 55 | 刚刚做了一个梦. 本来定好睡两个小时跑步, 结果睡了四个小时. 忘记了手机闹钟是否响过, 还是自己在睡梦中把它关了. 梦里自己先后在美国和坡县, 就像真实的一样. 梦醒后我如此惆怅, 因为不像以前其它的梦, 也不同于现实, 今天的梦的格调分外明快, 大概也是我在梦里笑得最多的一次. 梦里在美国和2b一起玩轮滑, 后来2b说要来坡县转转, 于是在机场接他的回来的路上, 我们在人群中穿梭着(但事实上我的轮滑技术还停留在本科时的初学阶段, 不知道梦里为什么如此娴熟XD), 开心地大喊大叫. 大概是对合肥有着太特殊的感情, 梦里的坡县却是合肥的地图. 正当我打算带着2b逛肥科时(梦里的自己想到的居然是大肥科, 唉), 路上这个傻x却坚持让我戴他的耳机, 因为我之前告诉他我自己的耳机刚坏掉. 但是我忽然发现我却连手机都忘记拿了. 万分焦急中, 梦就醒了, 哈哈哈(笑哭了), 真是羡慕梦里的自己, 心态好年轻~ 56 | 57 | ---- 58 | 59 | 2016-05-18 15:22 60 | 61 | 前天把所有域名都挂到Github, 因为不想使用免费的domain parking服务, 有的有广告, 有的页面巨难看 (虽然park.io的还看得过去). 这些天遇到些让人不太愉快的事情. 其中一件是我的一个域名的CNAME被占用, 没有办法正常跳转到我的Github页面, 总会指向另一个用户建的Github页面, 然而该用户基本上是僵尸用户, 也找不到他可用的联系方式. 与Github客服沟通了两天了, 现在还没有解决. 很多人没有一点公德心, 自己域名到期失效后也不去清理自己一些相关的设置, 给其他用户带来麻烦. 本来想把这个域名绑定到Gitlab或是lofter, 但前者国内不能访问, 后者定制性极差, 后来还是选择沟通Github客服. 但愿今天他们能有空帮我解决这个问题. 另一件糟心的事就是之前在gandi.net使用支付宝购买域名时交易失败, 支付宝却扣了钱, 而联系gandi.net人员他们确认没收到钱, 让我和Alipay的人交涉要求refund. 于是昨晚联系支付宝, 来回换了三个客服, 皮球被踢了一圈后, 我便说你们来回这么推托, 都说不知道, 那这笔钱凭空消失了吗. 最后一个客服再次把皮球踢向了支付宝国外服务团队(我用的是内地版的支付宝, 并没有使用国际版支付宝), 说把我的情况提交给他们了, 6天内答复. 好吧, 希望能有个答复吧. 62 | 63 | ---- 64 | 65 | 2016-05-09 17:35 66 | 67 | 先前快盘被转手给迅雷时, 我就基本上放弃使用它了. 最近快盘, 微盘等网络硬盘纷纷关停. 现在很少中国公司有公共责任感了, 68 | 恶性竞争时不管后续体验拼命吹牛骗取用户关注, 发现盈利困难时就甩手不干弃用户于不顾了. 花了不少时间把微盘以前存的内容都搬到了Google 69 | Drive. 至于其它几家网盘, 基本也没什么可以信任的. 扫描用户文件就像翻看自己的一样, 毫不尊重用户. 真不知道以后文件该存哪里了, 70 | 难道又要回到移动硬盘的年代? 或许以后真要用的时候, 购买Office365是个不错的选择. 71 | 72 | ---- 73 | 74 | 2016-05-09 14:05 75 | 76 | 今天专门做了一个页面用于放置各种吐槽类的东西, 相当于个人微博. 所有文字放在一个文件里, 又方便于归档, 77 | 用无格式的纯文档来写微博也是一种别样的体验. 78 | 79 | ---- 80 | 81 | 2016-05-02 16:55 82 | 83 | 这次百度再次成为众矢之的, 是长久以来作恶太多迟早的事情. 网友们评价这次"魏则西事件"中百度就是在吃人血馒头. 84 | 这种事情也不是一次两次了, 在中国发生这样的事情貌似除了网民们愤慨上一阵, 后面也就风平浪静了. 李老板照样赚着这样的昧心钱, 85 | 站在李老板后面的当然还有赵老爷. 现今网络上关紧大门, 国内寡头大搞垄断, 李老板们只要奉迎好上面, 自不用管下面的死活. 86 | 关起门来一起吃这人血馒头. 87 | 88 | 我原在想, 难道施惠国都城的人用百度也是特供版吗? 后来一拍脑门, 自己真是傻, 都城的人自然是不会被自己筑的墙挡住的. 89 | 这道高筑的墙, 以前牺牲了贱民们的便利, 现在终于有无名的贱民死在这墙角. 墙越筑越高, 贱民们在墙内就越别想瞧外面的世界. 90 | 都城的人民看着墙内的贱民们挣扎着生存, 仿佛是在享受着一场 Hunger Game. 91 | 92 | **魏则西事件** 还在持续发酵, 伟大的搬砖技师暨先秦著名思想家(误)Linus曾经曰过: "Talk is cheap, 93 | show me the money"(大误). 晚上跑步时想起白天有微博用户将一份莆田系医院的不完全名单放在 ``Github`` 上 94 | (点击 `这里 `_). 95 | 希望通过大家齐心合力帮助身边的人一起识别骗子医院, 减少悲剧. 这里也请大家在有精力的情况下将自己家乡的, 96 | 或是自己知道的漏网之鱼补充到这份名单上来(可登录Github提交). 97 | 98 | .. .. raw:: html 99 | :url: https://github.com/langhua9527/BlackheartedHospital/blob/master/README.md 100 | 101 | ---- 102 | 103 | 2016-05-02 11:07 104 | 105 | 时不时我总会对一成不变的 *Firefox* 界面感到厌倦, 而每次搜索其主题总是发现所谓主题是给标题栏上面添加了个背景图片, 106 | 仅此而已. 有时为缓解这种烦闷的外观我会暂时使用一会其它流览器, 比如 *Vivaldi* 或是 *Yandex* Browser. 107 | 怀念多年以前使用的火狐深黑色主题, 现今却让人遗憾不已. 今天搜索了下关键字 "Firefox Dark Theme", 108 | 却意外地发现了两件事情: 一个是现在的 *Firefox* 还是支持高度定制化的主题的, 109 | 只是隐藏的比较深, 它们被归在 "Complete Themes" 中, 而且这一分类下可用的主题的确所剩不多了. 110 | 另一个是淘到了一个叫做 "Simple White X" 的主题, 这只朴素的狐狸与Windows下的Modern UI更搭了. 111 | 112 | One more thing: 刚发现其实还可以能过 `userstyles.org `_ 113 | 来获得一些 *Stylish* 支持的主题. 114 | 妈的, *Firefox* 这多么好的个性化功能Mozilla却不去宣传, 非要向傻X的 *Chrome* 风格无限逼近. 115 | 116 | ---- 117 | 118 | 2016-04-26 22:24 119 | 120 | *更新: 已启用 oxyz.org, 原 vona.me 不再使用* 121 | 122 | 花了几天时间折腾, 从摸索Github Pages的使用到昨晚第一次拥有了属于自己的域名, 加上今天做了一些小修小补, 123 | 就用作放个人杂物的地方了, 以后应该不会有大的变动, 勉强算是1.0版本吧. 124 | 125 | Changelog: 126 | 127 | - 确定了框架和主题, 使用了Nikola, bootstrap3, Superhero, 一并表示感谢 128 | - 绑定了域名vona.me 129 | - 增加了Home和About页面, 内容待后期完善 130 | - 去掉了Author, Thumbnail等无关的功能 131 | - 添加了disqus评论, 支持匿名评论 132 | - 其它小改动 133 | -------------------------------------------------------------------------------- /posts/interesting-projects-in-google-summer-of-code-2017.rst: -------------------------------------------------------------------------------- 1 | .. title: Interesting Projects in Google Summer of Code 2017 2 | .. slug: interesting-projects-in-google-summer-of-code-2017 3 | .. date: 2017-03-20 00:30:58 UTC+08:00 4 | .. tags: algorithm, julia, project 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | 10 | "Google Summer of Code 2017" Projects: https://summerofcode.withgoogle.com/organizations/ 11 | 12 | I just picked some interesting ones from these projects: 13 | 14 | .. TEASER_END 15 | 16 | Machine learning 17 | ==================== 18 | 19 | aimacode 20 | ----------- 21 | 22 | `GitHub `__ 23 | 24 | This project provides implementations of the pseudocode algorithms in the textbook "Artificial Intelligence: A Modern Approach," along with tutorial examples of algorithm usage. 25 | 26 | Apertium 27 | ----------- 28 | 29 | `GitHub `__ 30 | 31 | Apertium is a free/open-source platform for rule-based machine translation and language technology which is aimed providing support for lesser-resourced and marginalised languages. 32 | 33 | CLiPS 34 | ------- 35 | 36 | `Link `__ 37 | 38 | Language technology research (fundamental & applied) on text analytics and text mining topics such as sentiment analysis, computational stylometry and cybersecurity applications. 39 | 40 | CloudCV 41 | --------- 42 | 43 | `Link `__ 44 | 45 | CloudCV is a young open source platform to make AI research reproducible by making it easy for researchers to build, compare and share state-of-the-art AI algorithms with everyone. 46 | 47 | 48 | CMU Sphinx 49 | ------------- 50 | 51 | `Link `__ 52 | 53 | The CMU Sphinx project is a leading automatic speech recognition project in the open source world. 54 | 55 | 56 | mlpack 57 | ------------- 58 | 59 | `GitHub `__ 60 | 61 | mlpack is a C++ machine learning library with emphasis on scalability, speed, and ease-of-use. 62 | 63 | 64 | Open Detection 65 | -------------------- 66 | 67 | `Link `__ 68 | 69 | Open Detection is a open source project for object detection and recognition. 70 | 71 | Shogun Machine Learning Toolbox 72 | ------------------------------------- 73 | 74 | `Link `__ 75 | 76 | The Shogun Machine learning toolbox provides a wide range of unified and efficient Machine Learning methods. Written in C++, automagic interfaces to Python, Octave, R, Java, etc. 77 | 78 | 79 | ViSP 80 | -------- 81 | 82 | `Link `__ 83 | 84 | ViSP library includes state of the art computer vision, visual tracking and visual servoing algorithms that could be used in robotics or augmented reality applications. 85 | 86 | 87 | 88 | Apps and languages 89 | ====================== 90 | 91 | Amahi 92 | ----------- 93 | 94 | `GitHub `__ 95 | 96 | Amahi is a "Home Server" distribution. It's based around Applications, Storage and Networking, with a nice web user interface and mobile apps for remote streaming/sharing. 97 | 98 | BeeWare 99 | ------------- 100 | 101 | `GitHub `__ 102 | 103 | Want to write an app in Python for your laptop, iPhone, Android, tablet, set top box, or watch? BeeWare has all the tools you'll need. 104 | 105 | 106 | NumFOCUS 107 | --------------- 108 | 109 | `Link `__ 110 | 111 | NumFOCUS supports and promotes world-class, innovative, open source scientific software. 112 | 113 | STE||AR Group 114 | ---------------- 115 | 116 | `Link `__ 117 | 118 | HPX is shaking up HPC through a unique combination of C++ language development and parallelism research. Join the STE||AR Group this summer to help push the bar on what's possible. 119 | 120 | The ns-3 Network Simulator Project 121 | --------------------------------------- 122 | 123 | `Link `__ 124 | 125 | ns-3 allows users to develop and experiment with models of computer networks. Our user community is primarily academic researchers conducting performance evaluation of networks. 126 | 127 | Zenodo 128 | ------------- 129 | 130 | `Link `__ 131 | 132 | Zenodo is a free and open digital archive built by CERN and OpenAIRE, enabling researchers to share and preserve research output in any size, format and from all fields of research 133 | 134 | 135 | 136 | Computer Graphics 137 | ======================= 138 | 139 | appleseedhq 140 | -------------- 141 | 142 | `GitHub `__ 143 | 144 | appleseed is a modern, open source, physically-based global illumination rendering engine designed for animation and visual effects. 145 | 146 | 147 | Tiled 148 | ---------- 149 | 150 | `GitHub `__ 151 | 152 | Tiled is a general purpose 2D level editor, a tool helping to create games and interactive media content. 153 | 154 | 155 | Robotics 156 | ============ 157 | 158 | ArduPilot 159 | ------------ 160 | 161 | `GitHub `__ 162 | 163 | Ardupilot is the most advanced, full-featured and reliable autopilot available, uniquely capable of controlling airplanes, multirotors, helicopters, rovers, boats and submarines. 164 | 165 | 166 | JdeRobot - Universidad Rey Juan Carlos 167 | ------------------------------------------- 168 | 169 | `GitHub `__ 170 | 171 | JdeRobot is a software development suite for robotics and computer vision applications. It is ROS compatible, uses Python and C++, includes tools and a framework to teach robotics 172 | 173 | Mobile Robot Programming Toolkit (MRPT) 174 | -------------------------------------------- 175 | 176 | `GitHub `__ 177 | 178 | Mobile Robot Programming Toolkit: empowering C++ development in robotics 179 | -------------------------------------------------------------------------------- /posts/julia-notes.rst: -------------------------------------------------------------------------------- 1 | .. title: Julia Notes 2 | .. slug: julia-notes 3 | .. date: 2016-05-24 12:22:41 UTC+08:00 4 | .. tags: julia 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | 安装 12 | ====== 13 | 14 | 1. 下载并安装64-bit Julia (command line version), 可选择自定义的安装路径. 15 | 2. 新建环境变量 ``JULIA_HOME``, 并指向 ``Julia`` 的 ``\bin`` 目录. 16 | 3. 在 ``PATH`` 环境变量下添加 ``%JULIA_HOME%``. 17 | 18 | .. TEASER_END 19 | 20 | REPL 基础 21 | ========== 22 | 23 | 系统命令 24 | 25 | =================== =========================================== 26 | ans 上一次计算结果 27 | ? help mode, 等同于 help(xxx) 28 | apropos("quit") 搜索和quit相关的命令 29 | methods(filter) 查看filter函数详细信息 30 | ; shell mode 31 | whos() 查看全局变量信息 32 | @which sin(3) 查看sin(3)命令中调用了哪些method 33 | edit("filename") 编辑文档 34 | less("filename") 显示文档 35 | clipboard("stuff") 将"stuff"拷贝到系统剪贴板 36 | clipboard() 将剪贴板当前内容拷至当前REPL 37 | dump() 显示一个Julia object相关信息 38 | names() 显示某个module的所有exported names 39 | workspace() 替换top-level module(Main), 并清除workspace 40 | =================== =========================================== 41 | 42 | 按键 43 | 44 | =================== =========================================== 45 | Up/Down 显示之前输入的命令 46 | Ctrl-R/Ctrl-S 搜索之前输出的内容 47 | =================== =========================================== 48 | 49 | 语法 50 | 51 | =========================== =========================================== 52 | ``+(2,3,4)`` 等同于 ``2+3+4`` 53 | ``pi``, ``golden``, ``e`` 系统预定义常量 54 | ``666//999`` ``//`` 用于rational number 55 | ``y\x`` ``\`` 为reverse division, ``x/y=y\x`` 56 | ``+=``, ``-=``, ... 这些符号也是允许的 57 | ``[2,4].*[10,20]`` element-wise operation 58 | ``a,b=5,3`` assign multiple variables, 返回类型: tuple 59 | ``\sqrt`` 转换成LaTeX字符 60 | =========================== =========================================== 61 | 62 | 数制 63 | 64 | ================ ==================================================== 65 | bits(20.0) shows the literal binary representation of a number 66 | hex(), oct() to hex or oct 67 | base(16, 266) to a string in given base 68 | ================ ==================================================== 69 | 70 | Arrays and Tuples 71 | ================== 72 | 73 | Julia arrays are "column-major" (列主序). This means that you read down the columns: 74 | 75 | .. code:: shell 76 | 77 | 1 3 78 | 2 4 79 | 80 | * Column-major order: Fortran, R, Matlab, GNU Octave, BLAS, LAPACK, OpenGL/OpenGL ES, Julia 81 | * ROW-major order: C/C++, Mathematica, Pascal, Python, C#/CLI/.Net, Direct3D 82 | 83 | Simple arrays 84 | ~~~~~~~~~~~~~~~ 85 | 86 | ======================== ========================================================= 87 | s=[1, 2.0, 3] 创建一个array, 类型为Float64 88 | trifuns=[sin, cos, tan] 一个函数array 89 | array=Array(Int64,5,2) 创建一个array, 并指定类型与大小, 等同于Array{Int64}(5,2) 90 | [1, "2", sin, 3.0] 同一个array可以包含不同类型 91 | typeof(ans) 查看数据类型 92 | Int64[1,2,3,4,5] 创建一个某种类型的array 93 | Int64[] 创建一个空的Int64型array, 其它类型还包括String, Float64等 94 | ======================== ========================================================= 95 | 96 | Row vectors 97 | ~~~~~~~~~~~~~~~~~~~~~~~ 98 | 99 | ======================== ========================================================= 100 | [1 2 3 4] 1x4 Int64 array (row vector) 101 | [1 2 3; 5 6 7] 2x3 Int64 matrix 102 | ======================== ========================================================= 103 | 104 | 在julia中, column vector是一维矩阵, 而row vector是二维矩阵, 大概julia也是偏好列向量的计算系统. 比如: 105 | 106 | .. code:: shell 107 | 108 | julia> [1,2,3] 109 | 3-element Array{Int64,1}: 110 | 1 111 | 2 112 | 3 113 | 114 | julia> [1 2 3] 115 | 1x3 Array{Int64,2}: 116 | 1 2 3 117 | 118 | 可以看出, 列向量是Array{Int64,1}类型而行向量是Array{Int64,2} 119 | 120 | Range objects 121 | ~~~~~~~~~~~~~~ 122 | 123 | ``1:10`` 等同于 ``range(1,10)``, 用途: 124 | 125 | 1. 生成列向量. 比如 ``[1:10]``, 或 ``collect(1:10)`` 126 | 2. loop表达式: ``for n in 1:10 print(n) end`` 127 | 128 | ``[0:10:100]`` 从0到100(包括100), 步长10. 亦可用于浮点类型. 129 | 130 | ``linspace(1,100,12)`` 从1到100, 12步, 即会产生12个数. 另一个类似函数是 ``logspace()``, 即它的 logarithmic 版本. 131 | 132 | Matrix 133 | ~~~~~~~~~ 134 | 135 | 创建 136 | ###### 137 | 138 | 创建一个2x3矩阵, 可使用: 139 | 140 | 1. ``[1 2 3; 4 5 6]`` (按行创建), 141 | 2. 按列创建: ``[[1, 2, 3] [4,5,6]]`` 142 | 3. ``Array(Int64, 3,2)`` 创建一个二维矩阵 143 | 4. ``reshape([1,2,3,4,5,6], 2, 3)``, 即将一个简单数组或矩阵变为想要形状. 144 | 145 | ``b=similar(a)`` 拷贝矩阵a给b(只拷形式作初始化用, 不拷数据) 146 | 147 | 初始化 148 | ###### 149 | 150 | 1. ``collect(0:10:100)`` 创建列向量并赋值 151 | 2. 使用 zeros, ones, trues, flases, fill, fill!, rand, randn, eye, diagm 等函数. 152 | 3. 创建简单的向量后使用 reshape 转换成多维矩阵. 153 | 4. Comprehensions, 如 ``[r*c for r in 1:5, c in 1:5]`` 154 | 155 | 元素indexing 156 | ############# 157 | 158 | 1. 元素索引格式为 a[5], a[2,3] 这样的形式, 或者 getindex(a, 1, 3) 159 | 2. 行索引: a[1, :] (单行), 或者 a[1:2, :] (多行) 160 | 3. 列索引: a[:,2] (单列), a[:, 1:2] (多列), a[:] 会将整个矩阵返回成一个列向量. 161 | 4. 对于二维数列(矩阵)a, indexing的时候可以有第三个分量, 试了以后貌似只能是1, 其它值都会出错. 即 a[:,2:6,1] 相当于 a[:,2:6]. 以后尽量不要用这种方式. 162 | 163 | Tips 164 | ====== 165 | 166 | ==================================================== ===================================================================================== 167 | 操作 说明 168 | ---------------------------------------------------- ------------------------------------------------------------------------------------- 169 | convert(Float64, i) 将 i 转换为Float64类型. 170 | function parse(type, num, base=10) default arguments 171 | include("filename.jl") 包含另一个文件 172 | repeat([4,2], outer=[3,1]) 得到一个6x1的2D array, 即[4,2,4,2,4,2] 173 | readdlm("matrixdata.txt") 读取一个数据文件并保存为矩阵, 一般文件名都用ASCIIString类型 174 | ==================================================== ===================================================================================== 175 | 176 | Other Tips 177 | ============== 178 | 179 | * Julia在windows下升级到最新版本只能通过下载新的exe文件安装, 覆盖安装之后再用 ``Pkg.update()`` 更新包. 另外 cmder 替换windows本身的cmd已经足够好用, 试了下并不喜欢Julia官网推荐的基于Atom的集成环境Juno IDE. 180 | * ``for i in 1:k`` 如果 ``k`` 小于1, 循环将不会被执行. 181 | * ``atan2(y,x)`` 结果会落在 (-pi, pi] 内, 而且Julia定义了 ``atan2(0,0)`` 等于 ``0``. 注意范围内不包括 ``-pi``, 可以验证 ``atan2(0,-1)`` 结果为 ``pi``. 182 | * ``2pi`` 表示 ``6.283185307179586``, 类似地, 一些常量和数字可以缩写在一起. 183 | * 可以使用 ``length()`` 获取一维array的大小, 对于二维数组, 会得到总元素个数. 想要得到多维数组的dimension信息, 需要使用 ``size()`` 184 | * ``isfile(path)`` 检测文件是否存在. ``rm(path)`` 可用于删除文件 185 | * ``@show()`` 可以接受多个参数, 用于debug时打印出中间变量到console, 非常方便. 186 | * ``@time`` macro加在执行命令的前面用于测试运行时间. 第一次调用时运行时间会稍长, 之后的调用会比较短. 因此以之后的为准. 187 | * ``0^0`` 在 Julia 中被定义为1, 在Mathematica中会报错(只能说MMA比较2, 经常涉及到Bernstein的定义都要用个Switch来考虑一下特殊情况). 188 | -------------------------------------------------------------------------------- /posts/spacemacs-learning-notes.rst: -------------------------------------------------------------------------------- 1 | .. title: Spacemacs Learning Notes 2 | .. slug: spacemacs-learning-notes 3 | .. date: 2016-04-25 12:23:49 UTC+08:00 4 | .. tags: emacs 5 | .. category: tools 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Emacs Tutorial (Official) 12 | ========================= 13 | 14 | - ``C``: Ctrl 15 | - ``M``: Alt (Meta) 16 | - ``RET``: Enter (Return) 17 | 18 | .. TEASER_END 19 | 20 | Shortcuts 21 | --------- 22 | 23 | - ``C-x C-c``: exit 24 | - ``C-z``: run emacs in background 25 | - 26 | - ``C-/``: undo 27 | - ``C-g``: stop command 28 | - ``C-g C-/``: redo 29 | - ``C-u 4 C-x Tab``: indent selected region by 4 spaces. Use a negtive 30 | number will do un-indent. 31 | - 32 | - ``C/M-v``: move forward/backward one screenful 33 | - ``C-l``: move the text around the cursor to the center of the screen 34 | - ``C/M-f``: move forward a character/word 35 | - ``C/M-b``: move backward a character/word 36 | - ``C-n``: move to next line 37 | - ``C-p``: move to previous line 38 | - ``C/M-a``: move to beginning of line/sentence 39 | - ``C/M-e``: move to end of line/sentence 40 | - ``M-<``: move to beginning of whole text 41 | - ``M->``: move to end of whole text 42 | - ``C-u 8 C-f``: move forward 8 characters 43 | - ``M-g M-g``: go to line 44 | - 45 | - ``C-x 0``: delete window 46 | - ``C-x 1``: one window (kill other windows) 47 | - ``C-x 2``: split window vertically 48 | - ``C-x 3``: split window horizontally 49 | - ``C-h c C-f``: display brief description of the C - f command 50 | - ``C-h k C-f``: display documentation on the C - f command 51 | - ``C/M-d``: delete the next character/word (deleted contents cannot be 52 | yanked) 53 | - ``C/M-k``: kill to end of line/sentence 54 | - ``C-w``: kill selected text 55 | - ``C-y``: yank (paste) killed text 56 | - ``M-y``: bring privously killed text 57 | - ``C-@``: mark for selection 58 | - 59 | - ``C-x C-s``: save current buffer to its file 60 | - ``C-x s``: save all buffers to their files 61 | - ``C-x C-f``: find file 62 | - ``C-x C-b``: list buffers 63 | - ``C-x b``: switch to a buffer 64 | - ``C-x f``: margin 65 | - 66 | - ``M-x repl s``: replace string 67 | - ``M-x recover-file``: recover an auto-saved edition 68 | - ``M-x xx-mode``: switch to (toggle) xx mode 69 | - ``C-h m``: view current mode 70 | - ``C-h a xx``: list all the commands whose names contain xx 71 | - 72 | - ``C-s/r``: search forward/backward 73 | - ``C-x 2``: split screen to 2 windows 74 | - ``C-M-v``: scroll the other window 75 | - ``C-x o``: focus on the other window 76 | - ``M-x make-frame``: create a new frame (window) 77 | - ``M-x delete-frame``: delete selected frame (window) 78 | 79 | Spacemacs First Impressions 80 | =========================== 81 | 82 | - http://spacemacs.org/doc/QUICK_START 83 | - https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org 84 | (The most important one) 85 | - http://jr0cket.co.uk/2015/08/spacemacs-first-impressions-from-an-emacs-driven-developer.html 86 | 87 | Shortcuts 88 | --------- 89 | 90 | - ``SPC``: referred to as the leader key. ``M-m`` in emacs style and 91 | space bar in vim style. It can be changed by setting the variable 92 | ``dotspacemacs-emacs-leader-key`` in emacs mode or 93 | ``dotspacemacs-leader-key`` in vim mode in the file ``~/.spacemacs``. 94 | - ``~``: referred to as the major-mode leader key: ``SPC m``. 95 | - ``SPC ?`` Search for specific keybindings 96 | - ``SPC f e h``: access documentation 97 | - ``C-x RET f``: see/change the file encoding 98 | 99 | Describe functions for help info 100 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | 102 | - ``SPC h d f``: describe-functions 103 | - ``SPC h d k``: describe-key 104 | - ``SPC h d m``: describe-mode 105 | - ``SPC h d v``: describe-variable 106 | 107 | Use ``.spacemacs`` instead of ``init.el`` for configuration 108 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 109 | 110 | ``.spacemacs`` keybindings: 111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 112 | 113 | - ``M-m f e d``: open the ~/.spacemacs file 114 | - ``M-m f e R``: reload the configuration from ~/.spacemacs 115 | 116 | Misc 117 | ~~~~ 118 | 119 | - ``SPC f t``: toggle NeoTree 120 | - ``SPC T h``: select a theme 121 | - ``SPC c l/L``: comment/uncomment 122 | 123 | ``.spacemacs`` has 3 sections: 124 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 125 | 126 | - ``dotspacemacs/init`` configuration applied when Spacemacs first 127 | starts, eg evil or holy mode(emacs), themes, fonts, full screen, 128 | recent files, etc 129 | - ``dotspacemacs/layers`` add features to spacemacs using layers, a 130 | layer can contain elisp and packages from Melpa/Elpa 131 | - ``dotspacemacs/user-config`` additional layer configuration or your 132 | own customisations. Adding ``(menu-bar-mode 1)`` here will bring menu 133 | bar back after initialization. 134 | 135 | keybindings and commands organizer: Helm ``M-m`` 136 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 137 | 138 | - ``a`` applications 139 | - ``b`` buffers 140 | - ``c`` compile/comments 141 | - ``C`` capture/colors 142 | - ``e`` errors 143 | - ``f`` files 144 | - ``g`` git/version control 145 | - ``S`` spelling 146 | - ``T`` themes 147 | 148 | numbered buffers 149 | ~~~~~~~~~~~~~~~~ 150 | 151 | Jump to any buffer using ``M-m`` and buffer number, e.g., ``M-m 3`` 152 | jumps to buffer number 153 | 154 | adding layers 155 | ~~~~~~~~~~~~~ 156 | 157 | - Open ``~/.spacemacs`` and add the layers to 158 | ``dotspacemacs-configuration-layers``. We can uncomment some useful 159 | layers listed there. 160 | - ``M-m f e h``: list all layers 161 | - ``M-m configuration-layer/create-layer`` create your own layer 162 | 163 | other configurations 164 | ~~~~~~~~~~~~~~~~~~~~ 165 | 166 | ``dotspacemacs/config`` 167 | ^^^^^^^^^^^^^^^^^^^^^^^ 168 | 169 | - change font: 170 | 171 | .. code:: clojure 172 | 173 | dotspacemacs-default-font '("Ubuntu Mono" 174 | :size 16 175 | :weight normal 176 | :width normal 177 | :powerline-scale 1.1) 178 | 179 | - set key bindings: 180 | 181 | .. code:: clojure 182 | 183 | (define-key global-map (kbd "C-+") 'text-scale-increase) 184 | (define-key global-map (kbd "C--") 'text-scale-decrease) 185 | 186 | **\*\*\*** ``dotspacemacs/init`` 187 | 188 | - full screen mode at startup 189 | 190 | .. code:: clojure 191 | 192 | dotspacemacs-fullscreen-at-startup t 193 | 194 | - Markdown preview install ``pandoc``, then add ``pandoc`` layer to 195 | ``dotspacemacs-configuration-layers`` in ``~/.spacemacs``. 196 | Additionally, add 197 | 198 | .. code:: clojure 199 | 200 | (add-hook 'markdown-mode-hook 'pandoc-mode) 201 | 202 | to the ``user-config`` to enable pandoc-mode when opening markdown 203 | files (see http://joostkremers.github.io/pandoc-mode/). Use menu 204 | ``Pandoc->Create PDF`` to export ``.pdf`` file. To export ``.html`` 205 | file, go to menu and set ``Pandoc->Output Format->HTML`` and 206 | ``Pandoc->Files->Output File->Create Output Filename``. Then click 207 | ``Pandoc->Run Pandoc``, the ``.html`` file is generated. To export to 208 | other file formats, just follow the previous steps and change 209 | ``Pandoc->Output Forma`` to the object file format like ``docx``, 210 | ``LaTeX``, etc. 211 | 212 | -------------------------------------------------------------------------------- /posts/A-reStructuredText-Primer.rst: -------------------------------------------------------------------------------- 1 | .. title: A reStructuredText Primer 2 | .. slug: quickstart 3 | .. date: 2012-03-30 23:00:00 UTC-03:00 4 | .. tags: 5 | .. link: 6 | .. description: 7 | 8 | A ReStructuredText Primer 9 | ========================= 10 | 11 | :Author: Richard Jones 12 | :Version: $Revision: 5801 $ 13 | :Copyright: This document has been placed in the public domain. 14 | 15 | .. class:: alert alert-info pull-left 16 | 17 | .. contents:: 18 | 19 | 20 | The text below contains links that look like "(quickref__)". These 21 | are relative links that point to the `Quick reStructuredText`_ user 22 | reference. If these links don't work, please refer to the `master 23 | quick reference`_ document. 24 | 25 | __ 26 | .. _Quick reStructuredText: quickref.html 27 | .. _master quick reference: 28 | http://docutils.sourceforge.net/docs/user/rst/quickref.html 29 | 30 | .. Note:: This document is an informal introduction to 31 | reStructuredText. The `What Next?`_ section below has links to 32 | further resources, including a formal reference. 33 | 34 | 35 | Structure 36 | --------- 37 | 38 | From the outset, let me say that "Structured Text" is probably a bit 39 | of a misnomer. It's more like "Relaxed Text" that uses certain 40 | consistent patterns. These patterns are interpreted by a HTML 41 | converter to produce "Very Structured Text" that can be used by a web 42 | browser. 43 | 44 | The most basic pattern recognised is a **paragraph** (quickref__). 45 | That's a chunk of text that is separated by blank lines (one is 46 | enough). Paragraphs must have the same indentation -- that is, line 47 | up at their left edge. Paragraphs that start indented will result in 48 | indented quote paragraphs. For example:: 49 | 50 | This is a paragraph. It's quite 51 | short. 52 | 53 | This paragraph will result in an indented block of 54 | text, typically used for quoting other text. 55 | 56 | This is another one. 57 | 58 | Results in: 59 | 60 | This is a paragraph. It's quite 61 | short. 62 | 63 | This paragraph will result in an indented block of 64 | text, typically used for quoting other text. 65 | 66 | This is another one. 67 | 68 | __ quickref.html#paragraphs 69 | 70 | 71 | Text styles 72 | ----------- 73 | 74 | (quickref__) 75 | 76 | __ quickref.html#inline-markup 77 | 78 | Inside paragraphs and other bodies of text, you may additionally mark 79 | text for *italics* with "``*italics*``" or **bold** with 80 | "``**bold**``". This is called "inline markup". 81 | 82 | If you want something to appear as a fixed-space literal, use 83 | "````double back-quotes````". Note that no further fiddling is done 84 | inside the double back-quotes -- so asterisks "``*``" etc. are left 85 | alone. 86 | 87 | If you find that you want to use one of the "special" characters in 88 | text, it will generally be OK -- reStructuredText is pretty smart. 89 | For example, this lone asterisk * is handled just fine, as is the 90 | asterisk in this equation: 5*6=30. If you actually 91 | want text \*surrounded by asterisks* to **not** be italicised, then 92 | you need to indicate that the asterisk is not special. You do this by 93 | placing a backslash just before it, like so "``\*``" (quickref__), or 94 | by enclosing it in double back-quotes (inline literals), like this:: 95 | 96 | ``*`` 97 | 98 | __ quickref.html#escaping 99 | 100 | .. Tip:: Think of inline markup as a form of (parentheses) and use it 101 | the same way: immediately before and after the text being marked 102 | up. Inline markup by itself (surrounded by whitespace) or in the 103 | middle of a word won't be recognized. See the `markup spec`__ for 104 | full details. 105 | 106 | __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup 107 | 108 | 109 | Lists 110 | ----- 111 | 112 | Lists of items come in three main flavours: **enumerated**, 113 | **bulleted** and **definitions**. In all list cases, you may have as 114 | many paragraphs, sublists, etc. as you want, as long as the left-hand 115 | side of the paragraph or whatever aligns with the first line of text 116 | in the list item. 117 | 118 | Lists must always start a new paragraph -- that is, they must appear 119 | after a blank line. 120 | 121 | **enumerated** lists (numbers, letters or roman numerals; quickref__) 122 | __ quickref.html#enumerated-lists 123 | 124 | Start a line off with a number or letter followed by a period ".", 125 | right bracket ")" or surrounded by brackets "( )" -- whatever you're 126 | comfortable with. All of the following forms are recognised:: 127 | 128 | 1. numbers 129 | 130 | A. upper-case letters 131 | and it goes over many lines 132 | 133 | with two paragraphs and all! 134 | 135 | a. lower-case letters 136 | 137 | 3. with a sub-list starting at a different number 138 | 4. make sure the numbers are in the correct sequence though! 139 | 140 | I. upper-case roman numerals 141 | 142 | i. lower-case roman numerals 143 | 144 | (1) numbers again 145 | 146 | 1) and again 147 | 148 | Results in (note: the different enumerated list styles are not 149 | always supported by every web browser, so you may not get the full 150 | effect here): 151 | 152 | 1. numbers 153 | 154 | A. upper-case letters 155 | and it goes over many lines 156 | 157 | with two paragraphs and all! 158 | 159 | a. lower-case letters 160 | 161 | 3. with a sub-list starting at a different number 162 | 4. make sure the numbers are in the correct sequence though! 163 | 164 | I. upper-case roman numerals 165 | 166 | i. lower-case roman numerals 167 | 168 | (1) numbers again 169 | 170 | 1) and again 171 | 172 | **bulleted** lists (quickref__) 173 | __ quickref.html#bullet-lists 174 | 175 | Just like enumerated lists, start the line off with a bullet point 176 | character - either "-", "+" or "*":: 177 | 178 | * a bullet point using "*" 179 | 180 | - a sub-list using "-" 181 | 182 | + yet another sub-list 183 | 184 | - another item 185 | 186 | Results in: 187 | 188 | * a bullet point using "*" 189 | 190 | - a sub-list using "-" 191 | 192 | + yet another sub-list 193 | 194 | - another item 195 | 196 | **definition** lists (quickref__) 197 | __ quickref.html#definition-lists 198 | 199 | Unlike the other two, the definition lists consist of a term, and 200 | the definition of that term. The format of a definition list is:: 201 | 202 | what 203 | Definition lists associate a term with a definition. 204 | 205 | *how* 206 | The term is a one-line phrase, and the definition is one or more 207 | paragraphs or body elements, indented relative to the term. 208 | Blank lines are not allowed between term and definition. 209 | 210 | Results in: 211 | 212 | what 213 | Definition lists associate a term with a definition. 214 | 215 | *how* 216 | The term is a one-line phrase, and the definition is one or more 217 | paragraphs or body elements, indented relative to the term. 218 | Blank lines are not allowed between term and definition. 219 | 220 | 221 | Preformatting (code samples) 222 | ---------------------------- 223 | (quickref__) 224 | 225 | __ quickref.html#literal-blocks 226 | 227 | To just include a chunk of preformatted, never-to-be-fiddled-with 228 | text, finish the prior paragraph with "``::``". The preformatted 229 | block is finished when the text falls back to the same indentation 230 | level as a paragraph prior to the preformatted block. For example:: 231 | 232 | An example:: 233 | 234 | Whitespace, newlines, blank lines, and all kinds of markup 235 | (like *this* or \this) is preserved by literal blocks. 236 | Lookie here, I've dropped an indentation level 237 | (but not far enough) 238 | 239 | no more example 240 | 241 | Results in: 242 | 243 | An example:: 244 | 245 | Whitespace, newlines, blank lines, and all kinds of markup 246 | (like *this* or \this) is preserved by literal blocks. 247 | Lookie here, I've dropped an indentation level 248 | (but not far enough) 249 | 250 | no more example 251 | 252 | Note that if a paragraph consists only of "``::``", then it's removed 253 | from the output:: 254 | 255 | :: 256 | 257 | This is preformatted text, and the 258 | last "::" paragraph is removed 259 | 260 | Results in: 261 | 262 | :: 263 | 264 | This is preformatted text, and the 265 | last "::" paragraph is removed 266 | 267 | 268 | Sections 269 | -------- 270 | 271 | (quickref__) 272 | 273 | __ quickref.html#section-structure 274 | 275 | To break longer text up into sections, you use **section headers**. 276 | These are a single line of text (one or more words) with adornment: an 277 | underline alone, or an underline and an overline together, in dashes 278 | "``-----``", equals "``======``", tildes "``~~~~~~``" or any of the 279 | non-alphanumeric characters ``= - ` : ' " ~ ^ _ * + # < >`` that you 280 | feel comfortable with. An underline-only adornment is distinct from 281 | an overline-and-underline adornment using the same character. The 282 | underline/overline must be at least as long as the title text. Be 283 | consistent, since all sections marked with the same adornment style 284 | are deemed to be at the same level:: 285 | 286 | Chapter 1 Title 287 | =============== 288 | 289 | Section 1.1 Title 290 | ----------------- 291 | 292 | Subsection 1.1.1 Title 293 | ~~~~~~~~~~~~~~~~~~~~~~ 294 | 295 | Section 1.2 Title 296 | ----------------- 297 | 298 | Chapter 2 Title 299 | =============== 300 | 301 | This results in the following structure, illustrated by simplified 302 | pseudo-XML:: 303 | 304 |
305 | 306 | Chapter 1 Title 307 | <section> 308 | <title> 309 | Section 1.1 Title 310 | <section> 311 | <title> 312 | Subsection 1.1.1 Title 313 | <section> 314 | <title> 315 | Section 1.2 Title 316 | <section> 317 | <title> 318 | Chapter 2 Title 319 | 320 | (Pseudo-XML uses indentation for nesting and has no end-tags. It's 321 | not possible to show actual processed output, as in the other 322 | examples, because sections cannot exist inside block quotes. For a 323 | concrete example, compare the section structure of this document's 324 | source text and processed output.) 325 | 326 | Note that section headers are available as link targets, just using 327 | their name. To link to the Lists_ heading, I write "``Lists_``". If 328 | the heading has a space in it like `text styles`_, we need to quote 329 | the heading "```text styles`_``". 330 | 331 | 332 | Document Title / Subtitle 333 | ````````````````````````` 334 | 335 | The title of the whole document is distinct from section titles and 336 | may be formatted somewhat differently (e.g. the HTML writer by default 337 | shows it as a centered heading). 338 | 339 | To indicate the document title in reStructuredText, use a unique adornment 340 | style at the beginning of the document. To indicate the document subtitle, 341 | use another unique adornment style immediately after the document title. For 342 | example:: 343 | 344 | ================ 345 | Document Title 346 | ================ 347 | ---------- 348 | Subtitle 349 | ---------- 350 | 351 | Section Title 352 | ============= 353 | 354 | ... 355 | 356 | Note that "Document Title" and "Section Title" above both use equals 357 | signs, but are distinct and unrelated styles. The text of 358 | overline-and-underlined titles (but not underlined-only) may be inset 359 | for aesthetics. 360 | 361 | 362 | Images 363 | ------ 364 | 365 | (quickref__) 366 | 367 | __ quickref.html#directives 368 | 369 | To include an image in your document, you use the the ``image`` directive__. 370 | For example:: 371 | 372 | .. image:: /images/nikola.png 373 | 374 | results in: 375 | 376 | .. image:: /images/nikola.png 377 | 378 | The ``/images/nikola.png`` part indicates the filename of the image 379 | you wish to appear in the document. There's no restriction placed on 380 | the image (format, size etc). If the image is to appear in HTML and 381 | you wish to supply additional information, you may:: 382 | 383 | .. image:: /images/nikola.png 384 | :height: 100 385 | :width: 200 386 | :scale: 50 387 | :alt: alternate text 388 | 389 | See the full `image directive documentation`__ for more info. 390 | 391 | __ http://docutils.sourceforge.net/docs/ref/rst/directives.html 392 | __ http://docutils.sourceforge.net/docs/ref/rst/directives.html#images 393 | 394 | 395 | What Next? 396 | ---------- 397 | 398 | This primer introduces the most common features of reStructuredText, 399 | but there are a lot more to explore. The `Quick reStructuredText`_ 400 | user reference is a good place to go next. For complete details, the 401 | `reStructuredText Markup Specification`_ is the place to go [#]_. 402 | 403 | Users who have questions or need assistance with Docutils or 404 | reStructuredText should post a message to the Docutils-users_ mailing 405 | list. 406 | 407 | .. [#] If that relative link doesn't work, try the master document: 408 | http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html. 409 | 410 | .. _reStructuredText Markup Specification: 411 | http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html 412 | .. _Docutils-users: http://docutils.sourceforge.net/docs/user/mailing-lists.html#docutils-users 413 | .. _Docutils project web site: http://docutils.sourceforge.net/ 414 | -------------------------------------------------------------------------------- /posts/build-github-pages-with-nikola.rst: -------------------------------------------------------------------------------- 1 | .. title: Build Github Pages with Nikola 2 | .. slug: build-github-pages-with-nikola 3 | .. date: 2016-04-26 12:56:35 UTC+08:00 4 | .. tags: github, python, nikola, web 5 | .. category: notes 6 | .. link: 7 | .. description: 8 | .. type: text 9 | .. author: YONG 10 | 11 | Introduction 12 | ============ 13 | 14 | 静态网站生成工具(static site generator)非常多, 15 | 在\ `这里 <https://www.staticgen.com/>`__ 16 | 就可以看到开源的众多静态网站生成工具. 不少工具都有它们各自的特点, 17 | 比如Hugo用golang编写, 在编译网页时速度比其它框架更快, 但缺点也比较明显, 18 | 做个性化扩展比较麻烦. 这里选择Nikola是考虑到它是由Python编写, 19 | 编译速度也比常见的Jekyll等要快不少, 且开发活跃, 20 | 被很多科研人员选作博客工具. 我比较看重的Nikola特性有: 21 | 22 | .. TEASER_END 23 | 24 | - 支持LaTeX数学公式(via MathJax) 25 | - 原生支持多种文档类型, 包括: 26 | 27 | - reStructuredText (``.rst``, ``.txt``, 此为默认格式, 故 ``.txt`` 28 | 文件也是以reStructuredText格式来读取的) 29 | - markdown (``.md``) 30 | - Jupyter/IPython Notebook (``.ipynb``) 31 | - HTML (``.html``) 32 | - PHP (``.php``) 33 | - Pandoc支持的格式, 如Textile, LaTeX, Emacs Org-Mode, MS Word等 34 | (Pandoc需要手动开启支持, 默认关闭因可能会与已有格式冲突) 35 | 36 | - 能过插件支持更多类型文档, 例如 Emacs Org-Mode, reST with HTML 5 37 | output 等 38 | 39 | 除此之外, 它还有很多其它特点, 比如提供image gallery, image slideshow 40 | 模板, 以及个性化的输出路径定制等. 41 | 42 | 配置参考\ `官方指导 <https://getnikola.com/getting-started.html>`__\ 和\ `手册 <https://getnikola.com/handbook.html>`__, 43 | 本文针对Windows和Anaconda作更详细的说明. 44 | 45 | 安装Nikola 46 | ========== 47 | 48 | - 选择一: 直接安装Python 49 | 50 | - 安装Python3: 打开Python官网安装32位python3. 51 | (即使是64位系统也推荐使用兼容性较好的32位python). 安装完后 52 | ``python --version`` 查看版本信息. 53 | - 安装 ``virtualenv``: 进入到python安装目录 54 | ``AppData\Local\Programs\Python\Python35-32``, 55 | ``python -m pip install virtualenv`` 56 | - 新建一个虚拟环境用于安装nikola(当然也可以省掉这步, 57 | 直接把nikola安装在global环境下) 58 | 59 | .. code:: shell 60 | 61 | virtualenv nikola 62 | cd nikola/Scripts 63 | activate.bat 64 | 65 | 说明: 创建一个叫做nikola的虚拟环境. 这里视情况不同, 66 | 如果提示命令失败可以尝试使用 ``virtualenv3``, ``virtualenv-3.x`` 67 | (其中x为python版本), 或者 ``virtualenv -p /usr/bin/python3``. 68 | 因win下没有source命令, 故使用.bat文件进行激活这个虚似环境. 69 | Linux下使用 ``source bin/activate`` 命令. 执行完上面命令, 70 | 此时命令行左侧会出现 ``(nikola)``, 71 | 表明当前的命令将会在这个虚拟环境下执行. 72 | 73 | - 在 ``(nikola)`` 环境下安装 ``lxml`` 与 ``Pillow``: 74 | 下载好这两个whl文件后, 把它们复制到python安装目录 75 | ``AppData\Local\Programs\Python\Python35-32`` 下方便操作, 76 | 并在该目录下执行(如果出错提示, 则需要先安装wheel, 77 | 再通过wheel安装它们): 78 | 79 | .. code:: shell 80 | 81 | python -m pip install Pillow-3.2.0-cp35-cp35m-win32.whl 82 | python -m pip install lxml-3.6.0-cp35-cp35m-win32.whl 83 | cd .. # back to nikola directory 84 | pip install --upgrade "Nikola[extras]" 85 | 86 | - 选择二: 通过Anaconda安装 (本文选择此方法) 87 | 88 | - 安装Anaconda, 如果系统已有, 先升级Anaconda (在Anaconda prompt中使用 ``conda update --all`` 命令升级所有package.) 89 | - 查看python版本, 使用anaconda prompt命令行工具: 90 | 91 | .. code:: shell 92 | 93 | [Anaconda3] C:\home>python --version 94 | Python 3.5.1 :: Anaconda 4.0.0 (64-bit) 95 | 96 | 创建一个叫myblog虚拟环境: 97 | 98 | .. code:: shell 99 | 100 | [Anaconda3] C:\home>conda create -n myblog python=3.x anaconda (where x is your python version. 也可以不创建新的environment直接安装) 101 | [Anaconda3] C:\home>activate myblog # use "source activate myblog" on linux 102 | [myblog] C:\home>pip install "Nikola[extras]" 103 | 104 | 升级nikola时, 先升级Anaconda, 再按照上面步骤, 最后一步使用 ``pip install --upgrade "Nikola[extras]``. 我在升级7.7.9时报错, 于是直接先删除了Nikola再重新安装新版. 即 ``pip uninstall "Nikola[extras]"``, 之后再使用 ``pip install "Nikola[extras]"`` 安装. 105 | 106 | 创建项目 107 | ======== 108 | 109 | - 新建项目 新建一个目录 ``C:/home/mynikolasite`` 用于存放新建的项目: 110 | 111 | .. code:: shell 112 | 113 | [myblog] C:\home>nikola init --demo mynikolasite # create an empty project without "--demo" option 114 | 115 | 这里nikola会问几个问题, 其中一个问到语言, 我们选择英文, 即输入 116 | ``en``, 其余的可视情况填写, 这些设置以后还可以在配置文件 ``conf.py`` 117 | 中更改. 118 | 119 | - 主题 在 https://themes.getnikola.com/ 可以找到nikola的各种主题, 120 | 安装主题 ``bootstrap3``, 为使主题生效, 需要另外在 ``conf.py`` 中设置 121 | ``THEME`` 变量: 122 | 123 | .. code:: shell 124 | 125 | [myblog] C:\home>cd mynikolasite 126 | [myblog] C:\home\mynikolasite>nikola install_theme bootstrap3 127 | 128 | - 配置 ``conf.py`` 文件 129 | 130 | - 这里我们可以编辑刚才创建时选项, 如 ``SITE_URL`` 设置为 131 | “https://defnil.github.io/” (为方便发布到Github, 注意要以 ``/`` 132 | 结尾). 133 | - 排名第一位的格式是默认格式。如下面的 ``.rst`` 格式,用户也可以将自己 134 | 偏好的格式移到第一位。 135 | - 如果页面要使用markdown和ipython notebook, 需要设置 ``POSTS`` 与 136 | ``PAGES`` 项(下面各增加了后几项, 137 | 顺便吐槽以前在nikola中page居然被叫做story!!!): 138 | 139 | .. code:: python 140 | 141 | POSTS = ( 142 | ("posts/*.rst", "posts", "post.tmpl"), 143 | ("posts/*.txt", "posts", "post.tmpl"), 144 | ("posts/*.html", "posts", "post.tmpl"), 145 | ("posts/*.md", "posts", "post.tmpl"), 146 | ("posts/*.ipynb", "posts", "post.tmpl"), 147 | ("posts/*.org", "posts", "post.tmpl"), 148 | ) 149 | PAGES = ( 150 | ("pages/*.rst", "pages", "story.tmpl"), 151 | ("pages/*.txt", "pages", "story.tmpl"), 152 | ("pages/*.html", "pages", "story.tmpl"), 153 | ("pages/*.md", "pages", "story.tmpl"), 154 | ("pages/*.ipynb", "pages", "story.tmpl"), 155 | ("pages/*.org", "pages", "story.tmpl"), 156 | ) 157 | 158 | - ``INDEX_TEASERS`` 设为 ``True`` 可以启用teaser. 159 | 这时只需在每个post中加入 ``.. TEASER_END`` (reST文件)或 160 | ``<!--TEASER_END-->`` (markdown), 就可以使index 161 | page只显示post的第一部分, 而对于org-mode, 需要 162 | ``#+HTML: <!--TEASER_END-->`` 或者 163 | 164 | .. code:: python 165 | 166 | #+BEGIN_HTML 167 | <!--TEASER_END--> 168 | #+END_HTML 169 | 170 | 另外, 171 | 172 | .. code:: python 173 | 174 | INDEX_READ_MORE_LINK = "" 175 | FEED_READ_MORE_LINK = "" 176 | 177 | 可以禁止掉 “Reader more…”. 个人感觉没有必要, 178 | 因为禁掉后读者不能分清楚是否文章在这里真的已经完结还是只是摘要部分. 179 | 180 | - ``USE_BUNDLES`` 设为 ``True`` 可以启用webassets 181 | (前提是你已经安装了它), 这样可以获得速度上的提升. 182 | - 禁止评论功能: 183 | 184 | .. code:: python 185 | 186 | COMMENT_SYSTEM = "" 187 | 188 | 也可以选择启用其它的评论支持, 如disqus, facebook等. 189 | - ``GENERATE_RSS`` 设为 ``True`` 默认支持RSS, 如果设为 ``False``, 190 | 则会关闭任何与RSS相关的功能. 同时还需要在 ``NAVIGATION_LINKS`` 191 | 把和RSS相关的页面去掉 192 | - 去掉Source links, 页面上将不会显示页面源代码的链接 193 | 194 | .. code:: python 195 | 196 | SHOW_SOURCELINK = False 197 | COPY_SOURCES = False 198 | 199 | - 编译 200 | 201 | .. code:: shell 202 | 203 | [myblog] C:\home\mynikolasite>nikola build 204 | 205 | 因为之前我们使用了 ``--demo``, 206 | 所以现在生成的网页已经包含了一些page在里面了. 我们可以看一看效果: 207 | 208 | .. code:: shell 209 | 210 | [myblog] C:\home\mynikolasite>nikola serve 211 | 212 | 这时使用流览器访问 http://localhost:8000/ 213 | 可以看到本地效果(Windows下使用命令 ``nikola serve -b`` 或者 214 | ``nikola serve --browser`` 流览器会打开http://0.0.0.0:8000/, 215 | 则出现无法访问. 正确地址是 http://localhost:8000/). 使用 ``Ctrl+c`` 216 | 停止服务. 217 | 218 | 发布到Github 219 | ============ 220 | 221 | 方式一 222 | ------ 223 | 224 | 使用git发布网站有两种方式, 一种是创建两个branch, 一个存生成的网页, 225 | 另一个branch是整个build后的项目, 在两个branch之间切换, 226 | 这也是官方指导中的方法. 227 | 228 | - 在Github上创建一个空的repo, 名字为 ``defnil.github.io``. 我们这里推荐使用项目主页,项目名字可以随便起,如 ``sitename`` 229 | - 在mynikolasite目录下创建.gitignore文件,(可直接下载使用\ `文件 <https://github.com/getnikola/nikola/blob/master/.gitignore>`__). 230 | - ``conf.py`` 相关设置如下: 231 | 232 | .. code:: python 233 | 234 | GITHUB_SOURCE_BRANCH = 'source' # where your Nikola site source will be deployed. We default to master, but user pages should use src or something else. 235 | GITHUB_DEPLOY_BRANCH = 'gh-pages' # where Nikola-generated HTML files will be deployed. It should be gh-pages for project pages and master for user pages (user.github.io). 236 | GITHUB_REMOTE_NAME = 'origin' 237 | GITHUB_COMMIT_SOURCE = True 238 | 239 | - 打开git bash, 240 | 241 | .. code:: shell 242 | 243 | cd C:/home/mynikolasite 244 | git init 245 | git remote add origin git@github.com:defnil/sitename.git 246 | 247 | - 当你build满意后, 就可以执行 ``nikola github_deploy``, 248 | 不用亲自去commit, 也不用手动建立名为source的branch, 249 | 这一切都自动由nikola做好了. 以后每次要更新网站时只用build后使用 250 | ``nikola github_deploy`` 就可以完成github page的更新, 251 | 这一切都不需要切换到git命令行. 252 | 253 | 方式二 254 | ------ 255 | 256 | 另一种方案是直接用两个repo来存放: 257 | 258 | - 在Github上创建两个空的repo, 名字分别叫 ``nikola-blog`` 和 259 | ``defnil.github.io``, 其中 ``defnil`` 是我Github的用户ID, 260 | 使用时需要换成你自己的ID. 注意不要包含readme或gitignore等文件. 261 | - 在mynikolasite目录下创建一个.gitignore文件, (可直接下载使用 262 | https://github.com/getnikola/nikola/blob/master/.gitignore 263 | 它已将output目录列进了忽略表中) 264 | - 打开一个git bash, 将所有mynikolasite内容push到 ``nikola-blog`` 265 | 这个repo里: 266 | 267 | .. code:: shell 268 | 269 | cd C:/home/mynikolasite 270 | git init 271 | git add . 272 | git commit -m "first commit" 273 | git remote add origin git@github.com:defnil/nikola-blog.git 274 | git push -u origin master 275 | 276 | - 再运行下面命令将output目录下的博客内容push到我们的blog site里, 即 277 | ``defnil.github.io`` 这个repo. 278 | 279 | .. code:: shell 280 | 281 | cd output 282 | git init 283 | git add . 284 | git commit -m "first blog commit" 285 | git remote add origin git@github.com:defnil/defnil.github.io.git 286 | git push -u origin master 287 | 288 | Use Custom Domain 289 | ----------------- 290 | 291 | 比如, 我们现在已经购买了域名 ``abc.me``, 292 | 希望能与刚才创建的Github页面关联. 293 | 假设我们用的是上述方法一来管理和发布页面的. 则先在本地的 ``files/`` 294 | 目录下添加 ``CNAME`` 文件, 其内容很简单, 只有 ``abc.me``. 295 | 可以用下面的命令实现: 296 | 297 | .. code:: shell 298 | 299 | cd C:/home/mynikolasite 300 | echo "abc.me" > files/CNAME 301 | 302 | 之后我们在完成编译后使用 ``github_deploy`` 命令, ``CNAME`` 会被拷贝到 303 | ``output/`` 目录下, 并会自动上传至 ``defnil.github.io`` 的 ``source`` 304 | branch下. 305 | 306 | .. code:: shell 307 | 308 | [myblog] C:\home\mynikolasite>nikola build 309 | [myblog] C:\home\mynikolasite>nikola github_deploy 310 | 311 | 接下来需要去域名服务商那里绑定, 以namecheap为例, 参考 312 | `这里 <https://www.namecheap.com/support/knowledgebase/article.aspx/9645/2208/how-do-i-link-my-domain-to-github-pages>`__. 313 | 其中第1步我们已做过了相关设置, 略过直接从第2步开始. 完成这些步骤后, 314 | 就可以直接使用 ``abc.me`` 访问刚才的 ``defnil.github.io`` 了. 当然, 315 | 这时不要忘记将 ``conf.py`` 中的 ``SITE_URL`` 设为 “http://abc.me/”. 316 | 317 | 文档编辑 318 | ======== 319 | 320 | metadata 321 | -------- 322 | 323 | 进入anaconda prompt, 324 | 325 | .. code:: shell 326 | 327 | [Anaconda3] C:\home>activate myblog # enter "nikola" virtual environment 328 | [myblog] C:\home>cd mynikolasite 329 | [myblog] C:\home\mynikolasite>nikola new_post 330 | 331 | Nikola提供这种方式生成reStructuredText文档, 并存放在posts目录下, 332 | (markdown文档使用 ``nikola new_post -f markdown``). 333 | 每产生个文档中都含有metadata, 包括标题, 作者等信息. 支持汉字作为标题, 334 | 汉字会被自动转换为拼音作为文件名, 如: 335 | 336 | .. code:: shell 337 | 338 | [myblog] C:\home\mynikolasite>nikola new_post -f markdown 339 | Creating New Post 340 | Title: markdown test 我了个去呀 341 | Scanning posts..........done! 342 | [2016-04-23T07:47:55Z] INFO: new_post: Your post's text is at: posts\markdown-test-wo-liao-ge-qu-ya.md 343 | 344 | 我们可以将一些信息(比如作者)放在 ``conf.py`` 中, 345 | 这样所有post都不用再指定作者信息了: 346 | 347 | .. code:: python 348 | 349 | ADDITIONAL_METADATA = { 350 | 'author': 'defnil' 351 | } 352 | 353 | 当然也可以手动在 ``posts/`` 目录下新建文档, 还可以在里面新建多层目录, 354 | 非常灵活. metadata 中比较重要的有: 355 | 356 | - 在 ``tags`` 中可包含多个标签, 用逗号隔开. 357 | 358 | - ``draft`` 表示该文不会被收入索引, 但它默认会被发布. 禁止发布带有 359 | ``draft`` 标签的草稿, 在设置文件 ``conf.py`` 中设置 360 | ``DEPLOY_DRAFTS`` 为 ``False``. 当然前提是 ``DEPLOY_COMMANDS`` 361 | 中没包含 ``nikola build``. 362 | - ``tags`` 中含有 ``private`` 的post不会被收入索引, 但会被发布. 363 | 通过网址可以直接被访问到. 364 | 365 | - Post Types: text and micro. 前者为普通文章, 后者为微博. 366 | - ``nocomments``: 设置为 ``True`` 可以禁止本文的评论 367 | - ``password``: 可以为文章设置密码, 访问者需要输入密码才可以打开页面. 368 | 369 | Math 370 | ---- 371 | 372 | - 要显示latex公式, 需要在post的 ``tags`` 里加入 ``mathjax``. 373 | 374 | - inline math 不再支持 ``$inline$`` 形式, 而使用 ``\(inline\)`` 375 | (有的情况下需要使用 ``\\(inline\\)``), 如 376 | 377 | .. code:: 378 | 379 | Euler’s formula: \(e^{ix} = \cos x + i\sin x\) 380 | 381 | 在reST文件中还可以使用 ``:math:`` (推荐): 382 | 383 | .. code:: 384 | 385 | Euler’s formula: :math:`e^{ix} = \cos x + i\sin x` 386 | 387 | - display math 使用 ``\[\]``, reST中推荐下面这种形式: 388 | 389 | .. code:: 390 | 391 | .. math:: 392 | 393 | \int \frac{dx}{1+ax}=\frac{1}{a}\ln(1+ax)+C 394 | 395 | reST中插入多种格式 396 | ------------------ 397 | 398 | media 399 | ~~~~~ 400 | 401 | .. code:: 402 | 403 | .. media:: http://vimeo.com/72425090 404 | .. media:: http://www.youtube.com/watch?v=wyRpAat5oz0 405 | 406 | YouTube, Vimeo, Soundcloud 407 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 408 | 409 | .. code:: 410 | 411 | .. youtube:: 8N_tupPBtWQ 412 | 413 | .. vimeo:: 20241459 414 | 415 | .. vimeo:: 20241459 416 | :height: 240 417 | :width: 320 418 | 419 | [soundcloud url="http://api.soundcloud.com/tracks/78131362" 420 | 421 | .. soundcloud:: 78131362 422 | 423 | Code 424 | ~~~~ 425 | 426 | .. code:: 427 | 428 | .. code-block:: python 429 | :number-lines: 430 | 431 | print("Our virtues and our failings are inseparable") 432 | 433 | Listing 434 | ~~~~~~~ 435 | 436 | 将 ``foo.py`` 文件放在 ``LISTINGS_FOLDERS`` 指定的目录下. 437 | 438 | .. code:: 439 | 440 | .. listing:: foo.py python 441 | 442 | Gist 443 | ~~~~ 444 | 445 | .. code:: 446 | 447 | .. gist:: 2395294 448 | 449 | Thumbnails 450 | ~~~~~~~~~~ 451 | 452 | To include an image placed in the ``images`` folder (or other folders 453 | defined in ``IMAGE_FOLDERS``), use the thumbnail directive, like 454 | this: 455 | 456 | .. code:: 457 | 458 | .. thumbnail:: ../tesla.jpg 459 | 460 | Nikola Tesla, the man that invented the 20th century. 461 | 462 | Slideshows 463 | ~~~~~~~~~~ 464 | 465 | .. code:: 466 | 467 | .. slides:: 468 | 469 | /galleries/demo/tesla_conducts_lg.jpg 470 | /galleries/demo/tesla_lightning2_lg.jpg 471 | /galleries/demo/tesla4_lg.jpg 472 | /galleries/demo/tesla_lightning1_lg.jpg 473 | /galleries/demo/tesla_tower1_lg.jpg 474 | 475 | Chart 476 | ~~~~~ 477 | 478 | 可以参考 `这里 <http://www.pygal.org/en/latest/>`__ 479 | 480 | .. code:: 481 | 482 | .. chart:: Bar 483 | :title: 'Browser usage evolution (in %)' 484 | :x_labels: ["2002", "2003", "2004", "2005", "2006", "2007"] 485 | 'Firefox', [None, None, 0, 16.6, 25, 31] 486 | 'Chrome', [None, None, None, None, None, None] 487 | 'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6] 488 | 'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4] 489 | 490 | Doc 491 | ~~~ 492 | 493 | 用于跳转到其它页面. 494 | 495 | .. code:: 496 | 497 | Take a look at :doc:`my other post <creating-a-theme>` about theme creating. 498 | Take a look at :doc:`creating-a-theme` to know how to do it. 499 | 500 | Org-Mode 501 | ======== 502 | 503 | - 安装插件 504 | 505 | .. code:: shell 506 | 507 | [Anaconda3] C:\home>activate myblog 508 | [myblog] C:\home>nikola plugin -i orgmode 509 | 510 | - 在 ``conf.py`` 中 ``COMPILERS``, ``POSTS``, ``PAGES`` 项中加入下和 ``.org`` 有关的内容 (参考本项目中的 conf.py 文件)。 511 | 512 | - 创建org文档 513 | 514 | .. code:: shell 515 | 516 | [myblog] C:\home>cd mynikolasite 517 | [myblog] C:\home\mynikolasite>nikola new_post -f orgmode 518 | 519 | - build 520 | 521 | .. code:: shell 522 | 523 | [myblog] C:\home\mynikolasite>nikola auto -b 524 | 525 | 会自动检查文件变化并build, ``-b`` 是打开流览器(Windows下尝试 526 | ``nikola auto`` 总是失败(因为内部调用的 ``epoll`` 命令在win下无效), 527 | 还是老老实实使用 ``nikola build`` 和 ``nikola serve`` 再访问 528 | http:localhost:8000 吧). 529 | 注意emacs.exe所在目录必须要添加到系统环境变量PATH中, 530 | 否则会找不到emacs而报错. 531 | 532 | Markdown 533 | ======== 534 | 535 | Set as Default Format 536 | --------------------- 537 | 538 | 如果要将markdown或者其它格式设置为默认格式, 只需将其放在 ``POSTS`` 和 539 | ``PAGES`` 第一个位置, 这样以后在执行 ``nikola new_post`` 时不用加参数, 540 | 会默认生成 ``.md`` 文件: 541 | 542 | .. code:: python 543 | 544 | POSTS = ( 545 | ("posts/*.md", "posts", "post.tmpl"), 546 | ("posts/*.rst", "posts", "post.tmpl"), 547 | ("posts/*.txt", "posts", "post.tmpl"), 548 | ("posts/*.html", "posts", "post.tmpl"), 549 | ("posts/*.ipynb", "posts", "post.tmpl"), 550 | ) 551 | PAGES = ( 552 | ("pages/*.md", "pages", "story.tmpl"), 553 | ("pages/*.rst", "pages", "story.tmpl"), 554 | ("pages/*.txt", "pages", "story.tmpl"), 555 | ("pages/*.html", "pages", "story.tmpl"), 556 | ("pages/*.ipynb", "pages", "story.tmpl"), 557 | ) 558 | 559 | Extensions 560 | ---------- 561 | 562 | nikola默认使用的python-markdown遵循standard markdown 563 | `标准 <http://daringfireball.net/projects/markdown/>`__, 564 | 如果要使用Github Favored Markdown 565 | (`GFM <https://help.github.com/articles/github-flavored-markdown>`__), 566 | 可以利用python-markdown中的一些 567 | `extensions <http://pythonhosted.org/Markdown/extensions/>`__ 568 | 来尽量模拟GFM格式: 569 | 570 | - `nl2br <http://pythonhosted.org/Markdown/extensions/nl2br.html>`__: 571 | newline to linebreak 572 | - `fenced-code <http://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html>`__: 573 | fenced code blocks 574 | - `smart-strong <http://pythonhosted.org/Markdown/extensions/smart_strong.html>`__: 575 | do not boldify multiple underscores in words 576 | - `codehilite <http://pythonhosted.org/Markdown/extensions/code_hilite.html>`__: 577 | syntax highlighting (using `Pygments <http://pygments.org>`__) 578 | - `footnotes <http://pythonhosted.org/Markdown/extensions/footnotes.html>`__: 579 | Footnots in markdown 580 | 581 | 可以设置 ``conf.py`` 文件中的 ``MARKDOWN_EXTENSIONS`` 582 | 变量来使用这些extensions, 如: 583 | 584 | .. code:: python 585 | 586 | MARKDOWN_EXTENSIONS = ["nl2br", "fenced_code", "footnotes", 587 | "smart_strong","codehilite(linenums=True)", 'extra'] 588 | 589 | Customization 590 | ============= 591 | 592 | Install Theme 593 | ------------- 594 | 595 | Themes can be found `here <https://themes.getnikola.com/>`__ and 596 | installed with ``nikola install_theme themename``. Here *bootstrap3* is 597 | a very good choice among them, since it supports 598 | `Bootswatch <https://bootswatch.com/>`__ schemes. For example, to use 599 | *Superhero* scheme on this `page <https://bootswatch.com/superhero/>`__, 600 | just run 601 | 602 | .. code:: shell 603 | 604 | [myblog] C:\home\mynikolasite>nikola bootswatch_theme -n custum_theme -s superhero -p bootstrap3 605 | 606 | after installing *bootstrap3* theme. To enable this custom scheme, you 607 | need set ``THEME`` to “custom” in ``conf.py``. 608 | 609 | To further tweak your theme, please refer to `Theming 610 | Nikola <https://getnikola.com/theming.html>`__. 611 | 612 | Author Page 613 | ----------- 614 | 615 | 如果你每篇post的作者署名不一致, nikola会判断有多个作者, 616 | 因此会自动产生一个Author Page. 当点击每个post上的Author名时, 617 | 会转向这名作者的页面. 因此需要按此 618 | `说明 <https://getnikola.com/blog/author-pages-in-nikola-v770.html>`__ 619 | 进一步设置. 即: 将 ``AUTHOR_PAGES_ARE_INDEXES`` 设为 ``False``, 620 | 然后设置每个作者的描述: 621 | 622 | .. code:: python 623 | 624 | ENABLE_AUTHOR_PAGES = True 625 | AUTHOR_PAGES_ARE_INDEXES = False 626 | AUTHOR_PATH = "authors" 627 | AUTHOR_PAGES_DESCRIPTIONS = { 628 | DEFAULT_LANG: { 629 | "defnil": "Old posts", 630 | "YONG": "^_^" 631 | }, 632 | } 633 | HIDDEN_AUTHORS = ['Guest'] 634 | 635 | *bootstrap3* 主题已将这些页面包含在内, 636 | 因此作上述设置后就可以直接看到结果了. 如果你要完全禁止这个功能, 637 | 也很简单, 将 ``ENABLE_AUTHOR_PAGES`` 设为 ``False`` 即可. 638 | 639 | Footer 640 | ------- 641 | 642 | 这里主要是在页面下显示 “Contents 2016 authorname - Powered by Nikola” 643 | 字样. 可以在 ``CONTENT_FOOTER`` 中做修改. 644 | 645 | Navigation Pane 646 | --------------- 647 | 648 | 可以在 ``NAVIGATION_LINKS`` 里添加要链接的页面即可. 比如新建了一个名为 649 | ``about.rst`` 的page (会被存放在 ``pages/`` 目录下), 650 | 如果要将它放在导航栏里: 651 | 652 | .. code:: python 653 | 654 | NAVIGATION_LINKS = { 655 | DEFAULT_LANG: ( 656 | ("/archive.html", "Archive"), 657 | ("/categories/", "Tags"), 658 | ("/pages/about/index.html", "About"), # need to be changed to /output/index.html after you set your own homepage 659 | ("/rss.xml", "RSS feed"), 660 | ), 661 | } 662 | 663 | 根据 `Nikola Handbook <https://getnikola.com/handbook.html>`__ 的说法, 664 | 导航栏至多支持一级子菜单 “Only one level of submenus is supported”, 665 | 可以参照说明设置带子菜单样式的导航栏. 666 | 667 | 评论功能 DISQUS 668 | --------------- 669 | 670 | .. code:: python 671 | 672 | COMMENT_SYSTEM = "disqus" 673 | COMMENT_SYSTEM_ID = "yongch" # your disqus ID 674 | 675 | Image Size 676 | ---------- 677 | 678 | ``MAX_IMAGE_SIZE`` 可以决定图片大小, 679 | 设置一个合理的数字可以保证所有页面中的图片不至于太大. 680 | 还有其它关于image的选项可以酌情选择. 681 | 682 | 另外所有放在 ``images/`` 下面的图片都会被复制到 ``output/`` 683 | 里并且会为每张图片自动生成thumbnail图片. 因此如果不想产生Thumbnail, 684 | 就直接把图片放在 ``files/images/`` 目录下. 685 | 686 | Set Your Own Homepage 687 | --------------------- 688 | 689 | 让网页更像site而不是blog, 690 | `这里 <https://getnikola.com/creating-a-site-not-a-blog-with-nikola.html>`__ 691 | 有如何建一个site的步骤. 对于已经按blog建立的站点, 692 | 我们可以进行下面的改造. 693 | 694 | .. code:: python 695 | 696 | INDEX_PATH = "posts" 697 | PAGES = ( 698 | ("pages/*.rst", "", "story.tmpl"), 699 | ("pages/*.txt", "", "story.tmpl"), 700 | ("pages/*.html", "", "story.tmpl"), 701 | ("pages/*.md", "", "story.tmpl"), 702 | ("pages/*.ipynb", "", "story.tmpl"), 703 | ("pages/*.org", "", "story.tmpl"), 704 | ) 705 | 706 | 然后我们可以使用 ``nikola new_page -t Home`` 创建一个名为 “Home” 的页面. 707 | (slug 改为index). 现在我们还需要根据 ``output/`` 708 | 下目录的变化重新调整导航栏, 并且把posts放到“Posts”导航栏里. 如下图: 709 | 710 | .. code:: python 711 | 712 | NAVIGATION_LINKS = { 713 | DEFAULT_LANG: ( 714 | ("/posts/", "Posts"), 715 | ("/categories/", "Tags"), 716 | ("/Notes/index.html", "Notes"), 717 | ("/archive.html", "Archive"), 718 | ("/rss.xml", "RSS"), 719 | ("/about/index.html", "About"), 720 | ), 721 | } 722 | 723 | 这时可以编辑你自己的 ``home.rst`` 了. 也可以直接用我们之前做的 724 | ``about.rst`` 链接过来做主页: ``.. include:: pages/about.rst``. 725 | 如果你正在使用基于 *bootstrap3* 的主题, 因为它基于 ``Bootstrap``, 726 | 因此任何 ``Bootstrap`` 支持的格式都可以用 ``.rst`` 来表达. 可以参考 727 | `这里 <https://getnikola.com/creating-a-site-not-a-blog-with-nikola.html>`__ 728 | 的一个例子来写主页. 更多语法上的参考还可以看 729 | `这里 <https://github.com/rougier/bootstrap-rst>`__. 730 | -------------------------------------------------------------------------------- /.doit.db.bak: -------------------------------------------------------------------------------- 1 | 'render_taxonomies:output\\categories\\emacs\\index.html', (0, 2836) 2 | 'render_galleries:output\\galleries\\demo\\tesla_lightning1_lg.jpg', (3072, 301) 3 | 'copy_assets:output\\assets\\js\\fancydates.js', (3584, 408) 4 | 'render_taxonomies:output\\categories\\tutorial\\index.html', (4096, 1963) 5 | 'render_taxonomies:output\\categories\\cpp\\index.html', (6144, 2910) 6 | 'render_taxonomies:output\\categories\\wen-xue.xml', (9216, 697) 7 | 'render_pages:output\\index.html', (10240, 4620) 8 | 'render_posts', (15360, 56) 9 | 'render_posts:cache\\pages\\notes\\tool-tips.html', (15872, 376) 10 | 'render_taxonomies:output\\categories\\mathjax.xml', (16384, 2656) 11 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.woff2', (19456, 470) 12 | 'render_posts:cache\\posts\\julia-notes.html', (19968, 361) 13 | 'render_pages:output\\posts\\yu-ming-xiang-guan-chang-shi\\index.html', (20480, 5033) 14 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopCenter.png', (25600, 460) 15 | 'render_posts:cache\\posts\\ijulia-installation-failed.html', (26112, 406) 16 | 'render_taxonomies:output\\authors\\docutils-contributors.xml', (26624, 592) 17 | 'render_taxonomies:output\\categories\\markdown\\index.html', (27648, 1950) 18 | 'render_posts:cache\\posts\\atom-latex-settings.html', (29696, 385) 19 | 'copy_files:output\\images\\MiMax-USB-4-5-DebuggingMode.png', (30208, 298) 20 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopLeft.png', (30720, 456) 21 | 'copy_assets:output\\assets\\js\\jquery.colorbox-min.js', (31232, 440) 22 | 'render_posts:cache\\posts\\approximation-error-of-position.html', (31744, 422) 23 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png', (32256, 375) 24 | 'render_taxonomies:output\\authors\\yong.xml', (32768, 16873) 25 | 'render_taxonomies:output\\categories\\domain\\index.html', (49664, 3517) 26 | 'create_bundles:output\\assets\\css\\all.css', (53248, 813) 27 | 'copy_files:output\\images\\custom-domain-settings-of-yandex-mail-hostrecords.png', (54272, 341) 28 | 'copy_assets:output\\assets\\js\\bootstrap.min.js', (54784, 428) 29 | 'render_posts:cache\\posts\\yu-ming-xiang-guan-chang-shi.html', (55296, 412) 30 | 'copy_files:output\\images\\MiMax-USB-2-UnlockDeveloperOptions.png', (55808, 312) 31 | 'copy_files:output\\images\\MiMax-USB-3-DeveloperOptions.png', (56320, 299) 32 | 'copy_files:output\\images\\git-learning-notes-3parts.png', (56832, 293) 33 | 'render_pages:output\\about\\index.html', (57344, 4625) 34 | 'render_taxonomies:output\\posts\\index-2.html', (62464, 9019) 35 | 'render_galleries', (71680, 56) 36 | 'render_taxonomies:output\\categories\\text-editor\\index.html', (72192, 1909) 37 | 'copy_assets:output\\assets\\css\\bootstrap.min.css', (74240, 305) 38 | 'render_taxonomies:output\\categories\\cpp.xml', (74752, 1516) 39 | 'render_galleries:output\\galleries\\demo\\tesla_lightning2_lg.jpg', (76288, 300) 40 | 'render_taxonomies:output\\categories\\git.xml', (76800, 537) 41 | 'render_taxonomies:output\\categories\\dian-shi.xml', (77824, 697) 42 | 'render_posts:cache\\posts\\hunger-games-guan-hou-gan.html', (78848, 403) 43 | 'render_posts:cache\\posts\\arc-length-reparameterization.html', (79360, 414) 44 | 'render_pages:output\\posts\\arc-length-reparameterization\\index.html', (79872, 5037) 45 | 'render_pages:output\\posts\\org-to-rst-notes\\index.html', (84992, 4973) 46 | 'render_taxonomies:output\\categories\\cat_ping-lun\\index.html', (90112, 2521) 47 | 'render_taxonomies:output\\categories\\cat_notes.xml', (92672, 1402) 48 | 'robots_file', (94208, 56) 49 | 'render_taxonomies:output\\posts\\index-4.html', (94720, 4973) 50 | 'render_taxonomies:output\\categories\\matlab\\index.html', (99840, 1911) 51 | 'copy_assets:output\\assets\\js\\moment-with-locales.min.js', (101888, 437) 52 | 'copy_assets:output\\assets\\js\\flowr.js', (102400, 400) 53 | 'render_posts:cache\\pages\\notes\\index.html', (102912, 363) 54 | 'render_taxonomies:output\\categories\\ubuntu\\index.html', (103424, 1989) 55 | 'copy_files:output\\images\\git-learning-notes-reset.png', (105472, 291) 56 | 'copy_files:output\\images\\avatar.jpg', (105984, 255) 57 | 'render_posts:cache\\posts\\build-github-pages-with-nikola.html', (106496, 425) 58 | 'render_taxonomies:output\\categories\\clothoid\\index.html', (107008, 2412) 59 | 'copy_files:output\\favicon.ico', (109568, 242) 60 | 'render_taxonomies:output\\posts\\index.html', (110080, 8971) 61 | 'scale_images', (119296, 56) 62 | 'render_pages:output\\notes\\tool-tips\\index.html', (119808, 4682) 63 | 'copy_assets:output\\assets\\css\\bootstrap-theme.min.css.map', (124928, 452) 64 | 'render_taxonomies:output\\categories\\atom.xml', (125440, 956) 65 | 'render_pages:output\\posts\\lyx-settins-on-windows\\index.html', (126464, 5002) 66 | 'render_taxonomies:output\\categories\\web.xml', (131584, 2021) 67 | 'copy_assets:output\\assets\\js\\jquery.colorbox.js', (133632, 432) 68 | 'render_taxonomies:output\\categories\\cat_math.xml', (134144, 1467) 69 | 'render_taxonomies:output\\categories\\dian-shi\\index.html', (135680, 2091) 70 | 'render_posts:cache\\posts\\atom-markdown-settings.html', (138240, 393) 71 | 'render_galleries:output\\galleries\\demo\\tesla_tower1_lg.jpg', (138752, 293) 72 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.ttf', (139264, 466) 73 | 'render_posts:cache\\posts\\geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan.html', (139776, 478) 74 | 'copy_assets:output\\assets\\css\\theme.css', (140288, 415) 75 | 'render_taxonomies:output\\categories\\python\\index.html', (140800, 2351) 76 | 'render_pages:output\\posts\\geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan\\index.html', (143360, 5143) 77 | 'render_taxonomies:output\\categories\\nikola\\index.html', (148992, 2351) 78 | 'render_taxonomies:output\\categories\\cat_tools.xml', (151552, 6723) 79 | 'render_galleries:output\\galleries\\demo\\index.html', (158720, 5714) 80 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomLeft.png', (164864, 462) 81 | 'robots_file:output\\robots.txt', (165376, 136) 82 | 'render_listings:output\\listings\\index.html', (165888, 1424) 83 | 'render_taxonomies:output\\categories\\zheng-zhi.xml', (167424, 572) 84 | 'render_taxonomies:output\\authors\\yong\\index.html', (168448, 18272) 85 | 'copy_assets:output\\assets\\xml\\rss.xsl', (186880, 399) 86 | 'render_taxonomies:output\\categories\\atom\\index.html', (187392, 2350) 87 | 'render_taxonomies:output\\categories\\emacs.xml', (189952, 1442) 88 | 'render_posts:cache\\posts\\julia-for-matrix-methods.html', (191488, 401) 89 | 'render_pages:output\\posts\\matlab-3d-plot\\index.html', (192000, 4963) 90 | 'render_posts:cache\\posts\\extending.html', (197120, 603) 91 | 'render_posts:cache\\posts\\install-monodevelop-on-ubuntu.html', (198144, 415) 92 | 'render_pages:output\\posts\\xiao-mi-shou-ji-lian-jie-dian-nao\\index.html', (198656, 5058) 93 | 'render_pages:output\\posts\\wrap-angle-to-given-range\\index.html', (203776, 5019) 94 | 'render_taxonomies:output\\authors\\the-nikola-team.xml', (208896, 909) 95 | 'render_taxonomies:output\\2016\\index.html', (209920, 14705) 96 | 'render_pages:output\\posts\\hunger-games-guan-hou-gan\\index.html', (224768, 5018) 97 | 'render_taxonomies:output\\archive.html', (229888, 1812) 98 | 'copy_files:output\\images\\home.jpg', (231936, 252) 99 | 'copy_assets:output\\assets\\js\\jquery.min.map', (232448, 424) 100 | 'render_posts:cache\\posts\\custom-domain-settings-of-yandex-mail.html', (232960, 439) 101 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png', (233472, 375) 102 | 'render_taxonomies:output\\2013\\index.html', (233984, 2170) 103 | 'render_taxonomies:output\\categories\\org-mode.xml', (236544, 1401) 104 | 'copy_assets:output\\assets\\js\\baguetteBox.js', (238080, 412) 105 | 'render_pages:output\\posts\\charts\\index.html', (238592, 4929) 106 | 'render_taxonomies', (243712, 56) 107 | 'render_pages:output\\posts\\extending\\index.html', (244224, 4945) 108 | 'render_posts:cache\\posts\\install-textext-plugin-for-inkscape.html', (249344, 432) 109 | 'render_taxonomies:output\\categories\\algorithm\\index.html', (249856, 4267) 110 | 'copy_assets:output\\assets\\css\\ipython.min.css', (254464, 416) 111 | 'render_galleries:output\\galleries', (254976, 145) 112 | 'copy_assets:output\\assets\\js\\flowr.plugin.js', (255488, 426) 113 | 'render_taxonomies:output\\categories\\inkscape\\index.html', (256000, 2015) 114 | 'render_taxonomies:output\\authors\\the-nikola-team\\index.html', (258048, 2308) 115 | 'render_tag_cloud:output\\assets\\js\\tag_cloud_data.json', (260608, 142) 116 | 'render_pages:output\\posts\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji\\index.html', (261120, 5159) 117 | 'render_pages:output\\posts\\visual-studio-auto-formatting-shortcut\\index.html', (266752, 5081) 118 | 'render_taxonomies:output\\categories\\clothoid.xml', (271872, 1018) 119 | 'render_pages:output\\posts\\git-learning-notes\\index.html', (272896, 4983) 120 | 'copy_files:output\\CNAME', (278016, 226) 121 | 'render_pages:output\\posts\\notepad++-tips\\index.html', (278528, 4961) 122 | 'copy_assets:output\\assets\\js\\bootstrap.js', (283648, 420) 123 | 'render_pages:output\\posts\\install-textext-plugin-for-inkscape\\index.html', (284160, 5067) 124 | 'render_posts:cache\\posts\\interesting-projects-in-google-summer-of-code-2017.html', (289280, 478) 125 | 'create_bundles:output\\assets\\js\\all-nocdn.js', (289792, 878) 126 | 'render_taxonomies:output\\categories\\julia.xml', (290816, 2727) 127 | 'create_bundles:output\\assets\\css\\all-nocdn.css', (293888, 955) 128 | 'render_taxonomies:output\\categories\\email\\index.html', (294912, 2011) 129 | 'render_listings', (296960, 56) 130 | 'render_site', (297472, 56) 131 | 'render_posts:cache\\posts\\charts.html', (297984, 351) 132 | 'copy_files', (298496, 56) 133 | 'render_taxonomies:output\\posts\\index-1.html', (299008, 8599) 134 | 'copy_files:output\\images\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png', (307712, 373) 135 | 'render_posts:cache\\posts\\org-mode-pdf-export-in-chinese.html', (308224, 417) 136 | 'render_taxonomies:output\\categories\\cat_notes\\index.html', (308736, 2796) 137 | 'render_taxonomies:output\\categories\\dian-ying.xml', (311808, 572) 138 | 'copy_assets:output\\assets\\css\\nikola_ipython.css', (312832, 421) 139 | 'render_taxonomies:output\\categories\\python.xml', (313344, 957) 140 | 'render_pages:output\\posts\\spacemacs-learning-notes\\index.html', (314368, 5014) 141 | 'render_taxonomies:output\\categories\\visual-studio\\index.html', (319488, 2029) 142 | 'render_taxonomies:output\\categories\\github.xml', (321536, 1885) 143 | 'render_pages:output\\posts\\interesting-projects-in-google-summer-of-code-2017\\index.html', (323584, 5143) 144 | 'render_posts:cache\\posts\\angle-between-2-vectors.html', (329216, 397) 145 | 'render_posts:cache\\posts\\The-Nikola-Handbook.html', (329728, 634) 146 | 'render_pages:output\\posts\\guan-yu-github-de-shi-yong-si-kao\\index.html', (330752, 5013) 147 | 'redirect', (335872, 56) 148 | 'render_taxonomies:output\\categories\\cat_tools\\index.html', (336384, 8117) 149 | 'render_listings:output\\listings\\hello.py', (344576, 161) 150 | 'render_galleries:output\\galleries\\demo\\tesla4_lg.thumbnail.jpg', (345088, 283) 151 | 'copy_assets:output\\assets\\js\\jquery.js', (345600, 415) 152 | 'render_pages:output\\posts\\chong-zhi-ubuntu-deng-lu-mi-ma\\index.html', (346112, 5041) 153 | 'render_galleries:output\\galleries\\demo\\tesla_tower1_lg.thumbnail.jpg', (351232, 295) 154 | 'render_galleries:output\\galleries\\demo\\rss.xml', (351744, 5806) 155 | 'render_posts:cache\\posts\\spacemacs-learning-notes.html', (357888, 400) 156 | 'render_taxonomies:output\\categories\\shou-ji.xml', (358400, 612) 157 | 'create_bundles:output\\assets\\js\\all.js', (359424, 595) 158 | 'render_taxonomies:output\\categories\\index.html', (360448, 1270) 159 | 'render_galleries:output\\galleries\\demo\\tesla2_lg.thumbnail.jpg', (361984, 282) 160 | 'render_galleries:cache\\galleries\\demo\\index.html', (362496, 386) 161 | 'render_pages:output\\posts\\atom-latex-settings\\index.html', (363008, 4988) 162 | 'render_taxonomies:output\\categories\\inkscape.xml', (368128, 621) 163 | 'render_posts:cache\\posts\\org-to-rst-notes.html', (369152, 376) 164 | 'render_galleries:output\\galleries\\demo\\tesla2_lg.jpg', (369664, 280) 165 | 'render_posts:cache\\pages\\home.html', (370176, 339) 166 | 'render_posts:cache\\posts\\guan-yu-github-de-si-kao.html', (370688, 400) 167 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderMiddleLeft.png', (371200, 462) 168 | 'render_posts:cache\\posts\\mian-fei-yu-ming-you-xiang-xuan-ze.html', (371712, 430) 169 | 'render_galleries:output\\galleries\\rss.xml', (372224, 3631) 170 | 'render_posts:cache\\posts\\notepad++-tips.html', (376320, 369) 171 | '_switch to py3:please!', (376832, 90) 172 | '_switch to py3', (377344, 56) 173 | 'render_taxonomies:output\\categories\\clojure\\index.html', (377856, 1996) 174 | 'create_bundles', (379904, 56) 175 | 'render_taxonomies:output\\categories\\github\\index.html', (380416, 3279) 176 | 'render_posts:cache\\posts\\visual-studio-auto-formatting-shortcut.html', (384000, 441) 177 | 'render_pages:output\\posts\\reStructuredText-notes\\index.html', (384512, 4940) 178 | 'render_galleries:output\\galleries\\demo\\tesla_conducts_lg.jpg', (389632, 297) 179 | 'render_galleries:output\\galleries\\demo\\tesla_lightning2_lg.thumbnail.jpg', (390144, 302) 180 | 'render_pages:output\\posts\\quickref\\index.html', (390656, 5038) 181 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomRight.png', (395776, 464) 182 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomCenter.png', (396288, 466) 183 | 'render_taxonomies:output\\categories\\mathjax\\index.html', (396800, 4050) 184 | 'copy_files:output\\images\\install-monodevelop-on-ubuntu-gui.png', (400896, 309) 185 | 'render_posts:cache\\pages\\notes\\2016-05-2016-07.html', (401408, 395) 186 | 'render_pages:output\\notes\\index.html', (401920, 4660) 187 | 'copy_assets:output\\assets\\css\\bootstrap.css', (407040, 297) 188 | 'render_posts:cache\\posts\\build-github-pages-with-cryogen.html', (407552, 421) 189 | 'copy_files:output\\images\\clothoid-approximation-coordinates.jpg', (408064, 312) 190 | 'render_pages:output\\posts\\approximation-error-of-position\\index.html', (408576, 5049) 191 | 'render_taxonomies:output\\categories\\cat_programming.xml', (413696, 5020) 192 | 'render_pages:output\\posts\\clothoid-approximation\\index.html', (418816, 5003) 193 | 'render_pages:output\\posts\\org-mode-learning-notes\\index.html', (423936, 5008) 194 | 'render_pages:output\\posts\\build-github-pages-with-cryogen\\index.html', (429056, 5048) 195 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.svg', (434176, 466) 196 | 'render_galleries:output\\galleries\\index.html', (434688, 3635) 197 | 'render_posts:cache\\pages\\about.html', (438784, 342) 198 | 'copy_assets:output\\assets\\css\\bootstrap-theme.css', (439296, 436) 199 | 'render_taxonomies:output\\categories\\markdown.xml', (439808, 556) 200 | 'copy_assets:output\\assets\\css\\colorbox.css', (440832, 419) 201 | 'copy_assets:output\\assets\\xml\\atom.xsl', (441344, 401) 202 | 'render_pages:output\\posts\\julia-packages\\index.html', (441856, 4964) 203 | 'render_taxonomies:output\\categories\\email.xml', (446976, 617) 204 | 'render_taxonomies:output\\categories\\cat_programming\\index.html', (448000, 6414) 205 | 'render_taxonomies:output\\categories\\shou-ji\\index.html', (454656, 2006) 206 | 'render_posts:cache\\posts\\matlab-3d-plot.html', (456704, 370) 207 | 'render_taxonomies:output\\categories\\web\\index.html', (457216, 3415) 208 | 'render_pages:output\\posts\\sagemath-file-exchange-with-windows-via-virtualbox\\index.html', (460800, 5143) 209 | 'render_pages', (466432, 56) 210 | 'render_sources', (466944, 56) 211 | 'render_listings:output\\listings\\hello.py.html', (467456, 1531) 212 | 'render_posts:cache\\posts\\clothoid-approximation.html', (468992, 394) 213 | 'copy_assets:output\\assets\\js\\html5shiv-printshiv.min.js', (469504, 435) 214 | 'render_taxonomies:output\\categories\\sage\\index.html', (470016, 2091) 215 | 'render_galleries:output\\galleries\\demo\\tesla_conducts_lg.thumbnail.jpg', (472576, 299) 216 | 'copy_assets:output\\assets\\css\\docs.css', (473088, 413) 217 | 'render_taxonomies:output\\categories\\ubuntu.xml', (473600, 595) 218 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.woff', (474624, 467) 219 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png', (475136, 362) 220 | 'copy_files:output\\images\\MiMax-USB-6-7-USBConfigInterface.png', (475648, 308) 221 | 'render_galleries:output\\galleries\\demo', (476160, 145) 222 | 'render_posts:cache\\posts\\A-reStructuredText-Reference.html', (476672, 417) 223 | 'scale_images:output\\images\\illus_001.jpg', (477184, 223) 224 | 'render_taxonomies:output\\categories\\julia\\index.html', (477696, 4121) 225 | 'render_posts:cache\\posts\\rst-notes.html', (482304, 356) 226 | 'render_pages:output\\posts\\atom-markdown-settings\\index.html', (482816, 5002) 227 | 'render_pages:output\\posts\\build-github-pages-with-nikola\\index.html', (487936, 5051) 228 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderMiddleRight.png', (493056, 464) 229 | 'render_taxonomies:output\\categories\\nikola.xml', (493568, 957) 230 | 'render_posts:timeline_changes', (494592, 109) 231 | 'render_posts:cache\\posts\\A-reStructuredText-Primer.html', (495104, 410) 232 | 'render_posts:cache\\posts\\git-learning-notes.html', (495616, 382) 233 | 'render_pages:output\\posts\\handbook\\index.html', (496128, 4998) 234 | 'render_taxonomies:output\\authors\\docutils-contributors\\index.html', (501248, 1991) 235 | 'render_taxonomies:output\\posts\\index-3.html', (503296, 9096) 236 | 'render_taxonomies:output\\categories\\latex\\index.html', (512512, 2829) 237 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png', (515584, 367) 238 | 'copy_assets:output\\assets\\css\\html4css1.css', (516096, 411) 239 | 'copy_files:output\\images\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png', (516608, 376) 240 | 'render_taxonomies:output\\authors\\index.html', (517120, 1275) 241 | 'render_pages:output\\posts\\julia-notes\\index.html', (518656, 4949) 242 | 'render_taxonomies:output\\categories\\project.xml', (523776, 697) 243 | 'render_posts:cache\\posts\\org-mode-learning-notes.html', (524800, 397) 244 | 'render_taxonomies:output\\categories\\latex.xml', (525312, 1435) 245 | 'render_taxonomies:output\\categories\\domain.xml', (526848, 2123) 246 | 'render_taxonomies:output\\categories\\matlab.xml', (529408, 517) 247 | 'render_posts:cache\\posts\\xiao-mi-shou-ji-lian-jie-dian-nao.html', (530432, 427) 248 | 'copy_assets', (530944, 56) 249 | 'render_taxonomies:output\\2012\\index.html', (531456, 3484) 250 | 'render_posts:cache\\posts\\wrap-angle-to-given-range.html', (535040, 403) 251 | 'render_pages:output\\posts\\ijulia-installation-failed\\index.html', (535552, 5023) 252 | 'render_taxonomies:output\\categories\\cat_ping-lun.xml', (540672, 1127) 253 | 'render_taxonomies:output\\categories\\sage.xml', (542208, 697) 254 | 'render_taxonomies:output\\categories\\visual-studio.xml', (543232, 635) 255 | 'copy_assets:output\\assets\\js\\jquery.min.js', (544256, 421) 256 | 'render_taxonomies:output\\categories\\project\\index.html', (544768, 2091) 257 | 'render_taxonomies:output\\categories\\git\\index.html', (547328, 1931) 258 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png', (549376, 377) 259 | 'render_taxonomies:output\\categories\\cat_math\\index.html', (549888, 2861) 260 | 'render_galleries:output\\galleries\\demo\\tesla_lightning1_lg.thumbnail.jpg', (552960, 303) 261 | 'render_taxonomies:output\\categories\\algorithm.xml', (553472, 2873) 262 | 'render_pages:output\\posts\\org-mode-pdf-export-in-chinese\\index.html', (556544, 5042) 263 | 'render_taxonomies:output\\2017\\index.html', (561664, 4905) 264 | 'render_tag_cloud', (566784, 56) 265 | 'sitemap:output\\sitemap.xml', (567296, 21567) 266 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.eot', (589312, 466) 267 | 'render_taxonomies:output\\rss.xml', (589824, 18090) 268 | 'render_listings:output\\listings\\__pycache__\\index.html', (608256, 1424) 269 | 'render_pages:output\\posts\\mian-fei-yu-ming-you-xiang-xuan-ze\\index.html', (609792, 5063) 270 | 'render_taxonomies:output\\categories\\zheng-zhi\\index.html', (614912, 1966) 271 | 'render_taxonomies:output\\categories\\tutorial.xml', (616960, 569) 272 | 'render_posts:cache\\posts\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji.html', (617984, 487) 273 | 'render_pages:output\\notes\\2016-05-2016-07\\index.html', (618496, 4714) 274 | 'render_taxonomies:output\\categories\\dian-ying\\index.html', (623616, 1966) 275 | 'copy_assets:output\\assets\\css\\rst.css', (625664, 396) 276 | 'copy_assets:output\\assets\\css\\bootstrap.min.css.map', (626176, 441) 277 | 'copy_assets:output\\assets\\js\\baguetteBox.min.js', (626688, 419) 278 | 'copy_assets:output\\assets\\css\\bootstrap-theme.min.css', (627200, 444) 279 | 'copy_assets:output\\assets\\css\\images\\controls.png', (627712, 437) 280 | 'copy_files:output\\images\\MiMax-USB-1-AboutPhone.png', (628224, 288) 281 | 'copy_assets:output\\assets\\css\\bootstrap.css.map', (628736, 433) 282 | 'render_taxonomies:output\\categories\\cat_os\\index.html', (629248, 2459) 283 | 'render_taxonomies:output\\categories\\text-editor.xml', (631808, 515) 284 | 'render_pages:output\\posts\\julia-for-matrix-methods\\index.html', (632832, 5015) 285 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopRight.png', (637952, 458) 286 | 'render_posts:cache\\posts\\lyx-settins-on-windows.html', (638464, 394) 287 | 'render_pages:output\\posts\\custom-domain-settings-of-yandex-mail\\index.html', (638976, 5078) 288 | 'render_taxonomies:output\\categories\\clojure.xml', (644096, 602) 289 | 'copy_assets:output\\assets\\css\\bootstrap-theme.css.map', (645120, 444) 290 | 'render_galleries:output\\galleries\\demo\\tesla4_lg.jpg', (645632, 281) 291 | 'copy_assets:output\\assets\\css\\nikola_rst.css', (646144, 412) 292 | 'scale_images:output\\images\\frontispiece.jpg', (646656, 228) 293 | 'render_taxonomies:output\\categories\\wen-xue\\index.html', (647168, 2091) 294 | 'render_pages:output\\posts\\angle-between-2-vectors\\index.html', (649728, 5008) 295 | 'copy_files:output\\images\\MiMax-USB-8-ChooseMode.png', (654848, 288) 296 | 'copy_assets:output\\assets\\js\\html5.js', (655360, 399) 297 | 'post_render', (655872, 56) 298 | 'sitemap:output\\sitemapindex.xml', (656384, 258) 299 | 'copy_assets:output\\assets\\css\\baguetteBox.css', (656896, 415) 300 | 'copy_assets:output\\assets\\css\\baguetteBox.min.css', (657408, 423) 301 | 'sitemap', (657920, 56) 302 | 'render_taxonomies:output\\categories\\org-mode\\index.html', (658432, 2795) 303 | 'render_pages:output\\posts\\quickstart\\index.html', (661504, 5026) 304 | '_scan_locs:sitemap', (666624, 12177) 305 | 'render_posts:cache\\posts\\chong-zhi-ubuntu-deng-lu-mi-ma.html', (678912, 417) 306 | 'copy_files:output\\images\\nikola.png', (679424, 254) 307 | 'copy_files:output\\images\\custom-domain-settings-of-yandex-mail-mailsettings.png', (679936, 343) 308 | 'render_taxonomies:output\\categories\\cat_os.xml', (680448, 1065) 309 | 'render_posts:cache\\posts\\julia-packages.html', (681984, 370) 310 | 'render_pages:output\\posts\\install-monodevelop-on-ubuntu\\index.html', (682496, 5038) 311 | 'copy_assets:output\\assets\\css\\images\\loading.gif', (687616, 435) 312 | 'copy_files:output\\images\\install-monodevelop-on-ubuntu-cmd.png', (688128, 309) 313 | 'render_posts:cache\\posts\\sagemath-file-exchange-with-windows-via-virtualbox.html', (688640, 478) 314 | 'copy_assets:output\\assets\\css\\code.css', (689152, 141) 315 | -------------------------------------------------------------------------------- /.doit.db.dir: -------------------------------------------------------------------------------- 1 | 'render_taxonomies:output\\categories\\emacs\\index.html', (0, 2836) 2 | 'render_galleries:output\\galleries\\demo\\tesla_lightning1_lg.jpg', (3072, 301) 3 | 'copy_assets:output\\assets\\js\\fancydates.js', (3584, 408) 4 | 'render_taxonomies:output\\categories\\tutorial\\index.html', (4096, 1963) 5 | 'render_taxonomies:output\\categories\\cpp\\index.html', (6144, 2910) 6 | 'render_taxonomies:output\\categories\\wen-xue.xml', (9216, 697) 7 | 'render_pages:output\\index.html', (10240, 4620) 8 | 'render_posts', (15360, 56) 9 | 'render_posts:cache\\pages\\notes\\tool-tips.html', (15872, 376) 10 | 'render_taxonomies:output\\categories\\mathjax.xml', (16384, 2656) 11 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.woff2', (19456, 470) 12 | 'render_posts:cache\\posts\\julia-notes.html', (19968, 361) 13 | 'render_pages:output\\posts\\yu-ming-xiang-guan-chang-shi\\index.html', (20480, 5033) 14 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopCenter.png', (25600, 460) 15 | 'render_posts:cache\\posts\\ijulia-installation-failed.html', (26112, 406) 16 | 'render_taxonomies:output\\authors\\docutils-contributors.xml', (26624, 592) 17 | 'render_taxonomies:output\\categories\\markdown\\index.html', (27648, 1950) 18 | 'render_posts:cache\\posts\\atom-latex-settings.html', (29696, 385) 19 | 'copy_files:output\\images\\MiMax-USB-4-5-DebuggingMode.png', (30208, 298) 20 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopLeft.png', (30720, 456) 21 | 'copy_assets:output\\assets\\js\\jquery.colorbox-min.js', (31232, 440) 22 | 'render_posts:cache\\posts\\approximation-error-of-position.html', (31744, 422) 23 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-jupyternotebook.png', (32256, 375) 24 | 'render_taxonomies:output\\authors\\yong.xml', (32768, 16873) 25 | 'render_taxonomies:output\\categories\\domain\\index.html', (49664, 3517) 26 | 'create_bundles:output\\assets\\css\\all.css', (53248, 813) 27 | 'copy_files:output\\images\\custom-domain-settings-of-yandex-mail-hostrecords.png', (54272, 341) 28 | 'copy_assets:output\\assets\\js\\bootstrap.min.js', (54784, 428) 29 | 'render_posts:cache\\posts\\yu-ming-xiang-guan-chang-shi.html', (55296, 412) 30 | 'copy_files:output\\images\\MiMax-USB-2-UnlockDeveloperOptions.png', (55808, 312) 31 | 'copy_files:output\\images\\MiMax-USB-3-DeveloperOptions.png', (56320, 299) 32 | 'copy_files:output\\images\\git-learning-notes-3parts.png', (56832, 293) 33 | 'render_pages:output\\about\\index.html', (57344, 4625) 34 | 'render_taxonomies:output\\posts\\index-2.html', (62464, 9019) 35 | 'render_galleries', (71680, 56) 36 | 'render_taxonomies:output\\categories\\text-editor\\index.html', (72192, 1909) 37 | 'copy_assets:output\\assets\\css\\bootstrap.min.css', (74240, 305) 38 | 'render_taxonomies:output\\categories\\cpp.xml', (74752, 1516) 39 | 'render_galleries:output\\galleries\\demo\\tesla_lightning2_lg.jpg', (76288, 300) 40 | 'render_taxonomies:output\\categories\\git.xml', (76800, 537) 41 | 'render_taxonomies:output\\categories\\dian-shi.xml', (77824, 697) 42 | 'render_posts:cache\\posts\\hunger-games-guan-hou-gan.html', (78848, 403) 43 | 'render_posts:cache\\posts\\arc-length-reparameterization.html', (79360, 414) 44 | 'render_pages:output\\posts\\arc-length-reparameterization\\index.html', (79872, 5037) 45 | 'render_pages:output\\posts\\org-to-rst-notes\\index.html', (84992, 4973) 46 | 'render_taxonomies:output\\categories\\cat_ping-lun\\index.html', (90112, 2521) 47 | 'render_taxonomies:output\\categories\\cat_notes.xml', (92672, 1402) 48 | 'robots_file', (94208, 56) 49 | 'render_taxonomies:output\\posts\\index-4.html', (94720, 4973) 50 | 'render_taxonomies:output\\categories\\matlab\\index.html', (99840, 1911) 51 | 'copy_assets:output\\assets\\js\\moment-with-locales.min.js', (101888, 437) 52 | 'copy_assets:output\\assets\\js\\flowr.js', (102400, 400) 53 | 'render_posts:cache\\pages\\notes\\index.html', (102912, 363) 54 | 'render_taxonomies:output\\categories\\ubuntu\\index.html', (103424, 1989) 55 | 'copy_files:output\\images\\git-learning-notes-reset.png', (105472, 291) 56 | 'copy_files:output\\images\\avatar.jpg', (105984, 255) 57 | 'render_posts:cache\\posts\\build-github-pages-with-nikola.html', (106496, 425) 58 | 'render_taxonomies:output\\categories\\clothoid\\index.html', (107008, 2412) 59 | 'copy_files:output\\favicon.ico', (109568, 242) 60 | 'render_taxonomies:output\\posts\\index.html', (110080, 8971) 61 | 'scale_images', (119296, 56) 62 | 'render_pages:output\\notes\\tool-tips\\index.html', (119808, 4682) 63 | 'copy_assets:output\\assets\\css\\bootstrap-theme.min.css.map', (124928, 452) 64 | 'render_taxonomies:output\\categories\\atom.xml', (125440, 956) 65 | 'render_pages:output\\posts\\lyx-settins-on-windows\\index.html', (126464, 5002) 66 | 'render_taxonomies:output\\categories\\web.xml', (131584, 2021) 67 | 'copy_assets:output\\assets\\js\\jquery.colorbox.js', (133632, 432) 68 | 'render_taxonomies:output\\categories\\cat_math.xml', (134144, 1467) 69 | 'render_taxonomies:output\\categories\\dian-shi\\index.html', (135680, 2091) 70 | 'render_posts:cache\\posts\\atom-markdown-settings.html', (138240, 393) 71 | 'render_galleries:output\\galleries\\demo\\tesla_tower1_lg.jpg', (138752, 293) 72 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.ttf', (139264, 466) 73 | 'render_posts:cache\\posts\\geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan.html', (139776, 478) 74 | 'copy_assets:output\\assets\\css\\theme.css', (140288, 415) 75 | 'render_taxonomies:output\\categories\\python\\index.html', (140800, 2351) 76 | 'render_pages:output\\posts\\geng-zhen-shi-zi-ran-de-hong-lou-meng-dai-yu-chuan\\index.html', (143360, 5143) 77 | 'render_taxonomies:output\\categories\\nikola\\index.html', (148992, 2351) 78 | 'render_taxonomies:output\\categories\\cat_tools.xml', (151552, 6723) 79 | 'render_galleries:output\\galleries\\demo\\index.html', (158720, 5714) 80 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomLeft.png', (164864, 462) 81 | 'robots_file:output\\robots.txt', (165376, 136) 82 | 'render_listings:output\\listings\\index.html', (165888, 1424) 83 | 'render_taxonomies:output\\categories\\zheng-zhi.xml', (167424, 572) 84 | 'render_taxonomies:output\\authors\\yong\\index.html', (168448, 18272) 85 | 'copy_assets:output\\assets\\xml\\rss.xsl', (186880, 399) 86 | 'render_taxonomies:output\\categories\\atom\\index.html', (187392, 2350) 87 | 'render_taxonomies:output\\categories\\emacs.xml', (189952, 1442) 88 | 'render_posts:cache\\posts\\julia-for-matrix-methods.html', (191488, 401) 89 | 'render_pages:output\\posts\\matlab-3d-plot\\index.html', (192000, 4963) 90 | 'render_posts:cache\\posts\\extending.html', (197120, 603) 91 | 'render_posts:cache\\posts\\install-monodevelop-on-ubuntu.html', (198144, 415) 92 | 'render_pages:output\\posts\\xiao-mi-shou-ji-lian-jie-dian-nao\\index.html', (198656, 5058) 93 | 'render_pages:output\\posts\\wrap-angle-to-given-range\\index.html', (203776, 5019) 94 | 'render_taxonomies:output\\authors\\the-nikola-team.xml', (208896, 909) 95 | 'render_taxonomies:output\\2016\\index.html', (209920, 14705) 96 | 'render_pages:output\\posts\\hunger-games-guan-hou-gan\\index.html', (224768, 5018) 97 | 'render_taxonomies:output\\archive.html', (229888, 1812) 98 | 'copy_files:output\\images\\home.jpg', (231936, 252) 99 | 'copy_assets:output\\assets\\js\\jquery.min.map', (232448, 424) 100 | 'render_posts:cache\\posts\\custom-domain-settings-of-yandex-mail.html', (232960, 439) 101 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-plotexamplefile.png', (233472, 375) 102 | 'render_taxonomies:output\\2013\\index.html', (233984, 2170) 103 | 'render_taxonomies:output\\categories\\org-mode.xml', (236544, 1401) 104 | 'copy_assets:output\\assets\\js\\baguetteBox.js', (238080, 412) 105 | 'render_pages:output\\posts\\charts\\index.html', (238592, 4929) 106 | 'render_taxonomies', (243712, 56) 107 | 'render_pages:output\\posts\\extending\\index.html', (244224, 4945) 108 | 'render_posts:cache\\posts\\install-textext-plugin-for-inkscape.html', (249344, 432) 109 | 'render_taxonomies:output\\categories\\algorithm\\index.html', (249856, 4267) 110 | 'copy_assets:output\\assets\\css\\ipython.min.css', (254464, 416) 111 | 'render_galleries:output\\galleries', (254976, 145) 112 | 'copy_assets:output\\assets\\js\\flowr.plugin.js', (255488, 426) 113 | 'render_taxonomies:output\\categories\\inkscape\\index.html', (256000, 2015) 114 | 'render_taxonomies:output\\authors\\the-nikola-team\\index.html', (258048, 2308) 115 | 'render_tag_cloud:output\\assets\\js\\tag_cloud_data.json', (260608, 142) 116 | 'render_pages:output\\posts\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji\\index.html', (261120, 5159) 117 | 'render_pages:output\\posts\\visual-studio-auto-formatting-shortcut\\index.html', (266752, 5081) 118 | 'render_taxonomies:output\\categories\\clothoid.xml', (271872, 1018) 119 | 'render_pages:output\\posts\\git-learning-notes\\index.html', (272896, 4983) 120 | 'copy_files:output\\CNAME', (278016, 226) 121 | 'render_pages:output\\posts\\notepad++-tips\\index.html', (278528, 4961) 122 | 'copy_assets:output\\assets\\js\\bootstrap.js', (283648, 420) 123 | 'render_pages:output\\posts\\install-textext-plugin-for-inkscape\\index.html', (284160, 5067) 124 | 'render_posts:cache\\posts\\interesting-projects-in-google-summer-of-code-2017.html', (289280, 478) 125 | 'create_bundles:output\\assets\\js\\all-nocdn.js', (289792, 878) 126 | 'render_taxonomies:output\\categories\\julia.xml', (290816, 2727) 127 | 'create_bundles:output\\assets\\css\\all-nocdn.css', (293888, 955) 128 | 'render_taxonomies:output\\categories\\email\\index.html', (294912, 2011) 129 | 'render_listings', (296960, 56) 130 | 'render_site', (297472, 56) 131 | 'render_posts:cache\\posts\\charts.html', (297984, 351) 132 | 'copy_files', (298496, 56) 133 | 'render_taxonomies:output\\posts\\index-1.html', (299008, 8599) 134 | 'copy_files:output\\images\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-sample-list.png', (307712, 373) 135 | 'render_posts:cache\\posts\\org-mode-pdf-export-in-chinese.html', (308224, 417) 136 | 'render_taxonomies:output\\categories\\cat_notes\\index.html', (308736, 2796) 137 | 'render_taxonomies:output\\categories\\dian-ying.xml', (311808, 572) 138 | 'copy_assets:output\\assets\\css\\nikola_ipython.css', (312832, 421) 139 | 'render_taxonomies:output\\categories\\python.xml', (313344, 957) 140 | 'render_pages:output\\posts\\spacemacs-learning-notes\\index.html', (314368, 5014) 141 | 'render_taxonomies:output\\categories\\visual-studio\\index.html', (319488, 2029) 142 | 'render_taxonomies:output\\categories\\github.xml', (321536, 1885) 143 | 'render_pages:output\\posts\\interesting-projects-in-google-summer-of-code-2017\\index.html', (323584, 5143) 144 | 'render_posts:cache\\posts\\angle-between-2-vectors.html', (329216, 397) 145 | 'render_posts:cache\\posts\\The-Nikola-Handbook.html', (329728, 634) 146 | 'render_pages:output\\posts\\guan-yu-github-de-shi-yong-si-kao\\index.html', (330752, 5013) 147 | 'redirect', (335872, 56) 148 | 'render_taxonomies:output\\categories\\cat_tools\\index.html', (336384, 8117) 149 | 'render_listings:output\\listings\\hello.py', (344576, 161) 150 | 'render_galleries:output\\galleries\\demo\\tesla4_lg.thumbnail.jpg', (345088, 283) 151 | 'copy_assets:output\\assets\\js\\jquery.js', (345600, 415) 152 | 'render_pages:output\\posts\\chong-zhi-ubuntu-deng-lu-mi-ma\\index.html', (346112, 5041) 153 | 'render_galleries:output\\galleries\\demo\\tesla_tower1_lg.thumbnail.jpg', (351232, 295) 154 | 'render_galleries:output\\galleries\\demo\\rss.xml', (351744, 5806) 155 | 'render_posts:cache\\posts\\spacemacs-learning-notes.html', (357888, 400) 156 | 'render_taxonomies:output\\categories\\shou-ji.xml', (358400, 612) 157 | 'create_bundles:output\\assets\\js\\all.js', (359424, 595) 158 | 'render_taxonomies:output\\categories\\index.html', (360448, 1270) 159 | 'render_galleries:output\\galleries\\demo\\tesla2_lg.thumbnail.jpg', (361984, 282) 160 | 'render_galleries:cache\\galleries\\demo\\index.html', (362496, 386) 161 | 'render_pages:output\\posts\\atom-latex-settings\\index.html', (363008, 4988) 162 | 'render_taxonomies:output\\categories\\inkscape.xml', (368128, 621) 163 | 'render_posts:cache\\posts\\org-to-rst-notes.html', (369152, 376) 164 | 'render_galleries:output\\galleries\\demo\\tesla2_lg.jpg', (369664, 280) 165 | 'render_posts:cache\\pages\\home.html', (370176, 339) 166 | 'render_posts:cache\\posts\\guan-yu-github-de-si-kao.html', (370688, 400) 167 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderMiddleLeft.png', (371200, 462) 168 | 'render_posts:cache\\posts\\mian-fei-yu-ming-you-xiang-xuan-ze.html', (371712, 430) 169 | 'render_galleries:output\\galleries\\rss.xml', (372224, 3631) 170 | 'render_posts:cache\\posts\\notepad++-tips.html', (376320, 369) 171 | '_switch to py3:please!', (376832, 90) 172 | '_switch to py3', (377344, 56) 173 | 'render_taxonomies:output\\categories\\clojure\\index.html', (377856, 1996) 174 | 'create_bundles', (379904, 56) 175 | 'render_taxonomies:output\\categories\\github\\index.html', (380416, 3279) 176 | 'render_posts:cache\\posts\\visual-studio-auto-formatting-shortcut.html', (384000, 441) 177 | 'render_pages:output\\posts\\reStructuredText-notes\\index.html', (384512, 4940) 178 | 'render_galleries:output\\galleries\\demo\\tesla_conducts_lg.jpg', (389632, 297) 179 | 'render_galleries:output\\galleries\\demo\\tesla_lightning2_lg.thumbnail.jpg', (390144, 302) 180 | 'render_pages:output\\posts\\quickref\\index.html', (390656, 5038) 181 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomRight.png', (395776, 464) 182 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderBottomCenter.png', (396288, 466) 183 | 'render_taxonomies:output\\categories\\mathjax\\index.html', (396800, 4050) 184 | 'copy_files:output\\images\\install-monodevelop-on-ubuntu-gui.png', (400896, 309) 185 | 'render_posts:cache\\pages\\notes\\2016-05-2016-07.html', (401408, 395) 186 | 'render_pages:output\\notes\\index.html', (401920, 4660) 187 | 'copy_assets:output\\assets\\css\\bootstrap.css', (407040, 297) 188 | 'render_posts:cache\\posts\\build-github-pages-with-cryogen.html', (407552, 421) 189 | 'copy_files:output\\images\\clothoid-approximation-coordinates.jpg', (408064, 312) 190 | 'render_pages:output\\posts\\approximation-error-of-position\\index.html', (408576, 5049) 191 | 'render_taxonomies:output\\categories\\cat_programming.xml', (413696, 5020) 192 | 'render_pages:output\\posts\\clothoid-approximation\\index.html', (418816, 5003) 193 | 'render_pages:output\\posts\\org-mode-learning-notes\\index.html', (423936, 5008) 194 | 'render_pages:output\\posts\\build-github-pages-with-cryogen\\index.html', (429056, 5048) 195 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.svg', (434176, 466) 196 | 'render_galleries:output\\galleries\\index.html', (434688, 3635) 197 | 'render_posts:cache\\pages\\about.html', (438784, 342) 198 | 'copy_assets:output\\assets\\css\\bootstrap-theme.css', (439296, 436) 199 | 'render_taxonomies:output\\categories\\markdown.xml', (439808, 556) 200 | 'copy_assets:output\\assets\\css\\colorbox.css', (440832, 419) 201 | 'copy_assets:output\\assets\\xml\\atom.xsl', (441344, 401) 202 | 'render_pages:output\\posts\\julia-packages\\index.html', (441856, 4964) 203 | 'render_taxonomies:output\\categories\\email.xml', (446976, 617) 204 | 'render_taxonomies:output\\categories\\cat_programming\\index.html', (448000, 6414) 205 | 'render_taxonomies:output\\categories\\shou-ji\\index.html', (454656, 2006) 206 | 'render_posts:cache\\posts\\matlab-3d-plot.html', (456704, 370) 207 | 'render_taxonomies:output\\categories\\web\\index.html', (457216, 3415) 208 | 'render_pages:output\\posts\\sagemath-file-exchange-with-windows-via-virtualbox\\index.html', (460800, 5143) 209 | 'render_pages', (466432, 56) 210 | 'render_sources', (466944, 56) 211 | 'render_listings:output\\listings\\hello.py.html', (467456, 1531) 212 | 'render_posts:cache\\posts\\clothoid-approximation.html', (468992, 394) 213 | 'copy_assets:output\\assets\\js\\html5shiv-printshiv.min.js', (469504, 435) 214 | 'render_taxonomies:output\\categories\\sage\\index.html', (470016, 2091) 215 | 'render_galleries:output\\galleries\\demo\\tesla_conducts_lg.thumbnail.jpg', (472576, 299) 216 | 'copy_assets:output\\assets\\css\\docs.css', (473088, 413) 217 | 'render_taxonomies:output\\categories\\ubuntu.xml', (473600, 595) 218 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.woff', (474624, 467) 219 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-winfolder.png', (475136, 362) 220 | 'copy_files:output\\images\\MiMax-USB-6-7-USBConfigInterface.png', (475648, 308) 221 | 'render_galleries:output\\galleries\\demo', (476160, 145) 222 | 'render_posts:cache\\posts\\A-reStructuredText-Reference.html', (476672, 417) 223 | 'scale_images:output\\images\\illus_001.jpg', (477184, 223) 224 | 'render_taxonomies:output\\categories\\julia\\index.html', (477696, 4121) 225 | 'render_posts:cache\\posts\\rst-notes.html', (482304, 356) 226 | 'render_pages:output\\posts\\atom-markdown-settings\\index.html', (482816, 5002) 227 | 'render_pages:output\\posts\\build-github-pages-with-nikola\\index.html', (487936, 5051) 228 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderMiddleRight.png', (493056, 464) 229 | 'render_taxonomies:output\\categories\\nikola.xml', (493568, 957) 230 | 'render_posts:timeline_changes', (494592, 109) 231 | 'render_posts:cache\\posts\\A-reStructuredText-Primer.html', (495104, 410) 232 | 'render_posts:cache\\posts\\git-learning-notes.html', (495616, 382) 233 | 'render_pages:output\\posts\\handbook\\index.html', (496128, 4998) 234 | 'render_taxonomies:output\\authors\\docutils-contributors\\index.html', (501248, 1991) 235 | 'render_taxonomies:output\\posts\\index-3.html', (503296, 9096) 236 | 'render_taxonomies:output\\categories\\latex\\index.html', (512512, 2829) 237 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-plotexample.png', (515584, 367) 238 | 'copy_assets:output\\assets\\css\\html4css1.css', (516096, 411) 239 | 'copy_files:output\\images\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji-domain-share.png', (516608, 376) 240 | 'render_taxonomies:output\\authors\\index.html', (517120, 1275) 241 | 'render_pages:output\\posts\\julia-notes\\index.html', (518656, 4949) 242 | 'render_taxonomies:output\\categories\\project.xml', (523776, 697) 243 | 'render_posts:cache\\posts\\org-mode-learning-notes.html', (524800, 397) 244 | 'render_taxonomies:output\\categories\\latex.xml', (525312, 1435) 245 | 'render_taxonomies:output\\categories\\domain.xml', (526848, 2123) 246 | 'render_taxonomies:output\\categories\\matlab.xml', (529408, 517) 247 | 'render_posts:cache\\posts\\xiao-mi-shou-ji-lian-jie-dian-nao.html', (530432, 427) 248 | 'copy_assets', (530944, 56) 249 | 'render_taxonomies:output\\2012\\index.html', (531456, 3484) 250 | 'render_posts:cache\\posts\\wrap-angle-to-given-range.html', (535040, 403) 251 | 'render_pages:output\\posts\\ijulia-installation-failed\\index.html', (535552, 5023) 252 | 'render_taxonomies:output\\categories\\cat_ping-lun.xml', (540672, 1127) 253 | 'render_taxonomies:output\\categories\\sage.xml', (542208, 697) 254 | 'render_taxonomies:output\\categories\\visual-studio.xml', (543232, 635) 255 | 'copy_assets:output\\assets\\js\\jquery.min.js', (544256, 421) 256 | 'render_taxonomies:output\\categories\\project\\index.html', (544768, 2091) 257 | 'render_taxonomies:output\\categories\\git\\index.html', (547328, 1931) 258 | 'copy_files:output\\images\\sagemath-file-exchange-with-windows-via-virtualbox-directorysetting.png', (549376, 377) 259 | 'render_taxonomies:output\\categories\\cat_math\\index.html', (549888, 2861) 260 | 'render_galleries:output\\galleries\\demo\\tesla_lightning1_lg.thumbnail.jpg', (552960, 303) 261 | 'render_taxonomies:output\\categories\\algorithm.xml', (553472, 2873) 262 | 'render_pages:output\\posts\\org-mode-pdf-export-in-chinese\\index.html', (556544, 5042) 263 | 'render_taxonomies:output\\2017\\index.html', (561664, 4905) 264 | 'render_tag_cloud', (566784, 56) 265 | 'sitemap:output\\sitemap.xml', (567296, 21567) 266 | 'copy_assets:output\\assets\\fonts\\glyphicons-halflings-regular.eot', (589312, 466) 267 | 'render_taxonomies:output\\rss.xml', (589824, 18090) 268 | 'render_listings:output\\listings\\__pycache__\\index.html', (608256, 1424) 269 | 'render_pages:output\\posts\\mian-fei-yu-ming-you-xiang-xuan-ze\\index.html', (609792, 5063) 270 | 'render_taxonomies:output\\categories\\zheng-zhi\\index.html', (614912, 1966) 271 | 'render_taxonomies:output\\categories\\tutorial.xml', (616960, 569) 272 | 'render_posts:cache\\posts\\alexa-qian-100-wan-wang-zhan-yu-ming-hou-zhui-tong-ji.html', (617984, 487) 273 | 'render_pages:output\\notes\\2016-05-2016-07\\index.html', (618496, 4714) 274 | 'render_taxonomies:output\\categories\\dian-ying\\index.html', (623616, 1966) 275 | 'copy_assets:output\\assets\\css\\rst.css', (625664, 396) 276 | 'copy_assets:output\\assets\\css\\bootstrap.min.css.map', (626176, 441) 277 | 'copy_assets:output\\assets\\js\\baguetteBox.min.js', (626688, 419) 278 | 'copy_assets:output\\assets\\css\\bootstrap-theme.min.css', (627200, 444) 279 | 'copy_assets:output\\assets\\css\\images\\controls.png', (627712, 437) 280 | 'copy_files:output\\images\\MiMax-USB-1-AboutPhone.png', (628224, 288) 281 | 'copy_assets:output\\assets\\css\\bootstrap.css.map', (628736, 433) 282 | 'render_taxonomies:output\\categories\\cat_os\\index.html', (629248, 2459) 283 | 'render_taxonomies:output\\categories\\text-editor.xml', (631808, 515) 284 | 'render_pages:output\\posts\\julia-for-matrix-methods\\index.html', (632832, 5015) 285 | 'copy_assets:output\\assets\\css\\images\\ie6\\borderTopRight.png', (637952, 458) 286 | 'render_posts:cache\\posts\\lyx-settins-on-windows.html', (638464, 394) 287 | 'render_pages:output\\posts\\custom-domain-settings-of-yandex-mail\\index.html', (638976, 5078) 288 | 'render_taxonomies:output\\categories\\clojure.xml', (644096, 602) 289 | 'copy_assets:output\\assets\\css\\bootstrap-theme.css.map', (645120, 444) 290 | 'render_galleries:output\\galleries\\demo\\tesla4_lg.jpg', (645632, 281) 291 | 'copy_assets:output\\assets\\css\\nikola_rst.css', (646144, 412) 292 | 'scale_images:output\\images\\frontispiece.jpg', (646656, 228) 293 | 'render_taxonomies:output\\categories\\wen-xue\\index.html', (647168, 2091) 294 | 'render_pages:output\\posts\\angle-between-2-vectors\\index.html', (649728, 5008) 295 | 'copy_files:output\\images\\MiMax-USB-8-ChooseMode.png', (654848, 288) 296 | 'copy_assets:output\\assets\\js\\html5.js', (655360, 399) 297 | 'post_render', (655872, 56) 298 | 'sitemap:output\\sitemapindex.xml', (656384, 258) 299 | 'copy_assets:output\\assets\\css\\baguetteBox.css', (656896, 415) 300 | 'copy_assets:output\\assets\\css\\baguetteBox.min.css', (657408, 423) 301 | 'sitemap', (657920, 56) 302 | 'render_taxonomies:output\\categories\\org-mode\\index.html', (658432, 2795) 303 | 'render_pages:output\\posts\\quickstart\\index.html', (661504, 5026) 304 | '_scan_locs:sitemap', (666624, 12177) 305 | 'render_posts:cache\\posts\\chong-zhi-ubuntu-deng-lu-mi-ma.html', (678912, 417) 306 | 'copy_files:output\\images\\nikola.png', (679424, 254) 307 | 'copy_files:output\\images\\custom-domain-settings-of-yandex-mail-mailsettings.png', (679936, 343) 308 | 'render_taxonomies:output\\categories\\cat_os.xml', (680448, 1065) 309 | 'render_posts:cache\\posts\\julia-packages.html', (681984, 370) 310 | 'render_pages:output\\posts\\install-monodevelop-on-ubuntu\\index.html', (682496, 5038) 311 | 'copy_assets:output\\assets\\css\\images\\loading.gif', (687616, 435) 312 | 'copy_files:output\\images\\install-monodevelop-on-ubuntu-cmd.png', (688128, 309) 313 | 'render_posts:cache\\posts\\sagemath-file-exchange-with-windows-via-virtualbox.html', (688640, 478) 314 | 'copy_assets:output\\assets\\css\\code.css', (689152, 141) 315 | -------------------------------------------------------------------------------- /posts/julia-for-matrix-methods.rst: -------------------------------------------------------------------------------- 1 | .. title: Julia for Matrix Methods 2 | .. slug: julia-for-matrix-methods 3 | .. date: 2017-03-01 13:59:43 UTC+08:00 4 | .. tags: julia, tutorial, mathjax 5 | .. category: programming 6 | .. link: 7 | .. description: 8 | .. type: text 9 | 10 | .. sectnum:: 11 | 12 | .. contents:: 13 | 14 | .. TEASER_END 15 | 16 | .. class:: alert alert-info pull-right 17 | 18 | .. admonition:: References: 19 | 20 | - `Introduction to Matrix Methods <http://stanford.edu/class/ee103/julia.html>`_ 21 | - `Performance Tips <http://docs.julialang.org/en/stable/manual/performance-tips/>`_ 22 | 23 | 24 | 25 | Introduction 26 | ============== 27 | 28 | Basic arithmetric & mathematical functions 29 | --------------------------------------------- 30 | 31 | - ``+``, ``-``, ``*``, ``/``, ``^`` (exponentiate), ... 32 | - ``true``, ``false``, ``+=``, ``!=``, ``<``, ``>``, ``<=``, ``>==``, ``!(value == 4)``, ... 33 | - ``im`` (imaginary unit), ``pi``, ``e``, ``golden``, ... 34 | - ``exp``, ``sqrt``, ``sin``, ``rand()``, ... 35 | - ``typeof(x)``, ``println(23)``, ``quit()``, ``methods(sin)``, ... 36 | - assign multiple variables (return type: Tuple): ``a,b=5,3`` 37 | 38 | Swap two variables: ``a,b=b,a`` 39 | 40 | - convert float to int: ``Int64(3.0)`` 相当于 ``convert(Int64, 3.0``), ``ceil(Int64, 2.5)``, ``round(Int64, 2.5)``, ``floor(Int64, 2.5)`` 41 | 42 | 更高精度 43 | ^^^^^^^^^^^^ 44 | 45 | 对于 Float64 类型,其机器精度 machine epsilon 为 ``eps(Float64) = 2.220446049250313e-16``, 其精度 precision 是 ``precision(Float64) = 53``. 46 | 需要更高精度运算的话,可使用 Julia 自带的 BigFloat 类型或使用第三方 package, 如 "DecFP.jl", "ArbFloats.jl", "DoubleDouble.jl", "DEQuadrature.jl". 47 | 48 | Tuples 49 | --------- 50 | 51 | Tuples act like "immutable" arrays. 52 | 53 | - unpack a tuple: 54 | 55 | .. code:: jlcon 56 | 57 | julia> word1, word2 = ("foo", "bar") 58 | ("foo","bar") 59 | 60 | julia> word1 61 | "foo" 62 | 63 | julia> word2 64 | "bar" 65 | 66 | - ``collect``: convert tuple to array 67 | 68 | - tuples as function arguments: unpack it use an ellipsis ``f((1, 2, 3)...)`` (Refer to `Varargs Functions <http://julia.readthedocs.org/en/latest/manual/functions/#varargs-functions>`_) 69 | 注:之前的版本还可以使用 ``apply`` 函数,现在该函数已被 Julia 作废。 70 | 71 | .. code:: jlcon 72 | 73 | julia> g() = (1, 2, 3) 74 | g (generic function with 1 method) 75 | 76 | julia> f(a, b, c) = +(a, b, c) 77 | f (generic function with 1 method) 78 | 79 | julia> f(g()) 80 | ERROR: MethodError: `f` has no method matching f(::Tuple{Int64,Int64 81 | ,Int64}) 82 | Closest candidates are: 83 | f(::Any, ::Any, ::Any) 84 | 85 | julia> f(g()...) 86 | 6 87 | 88 | Ranges 89 | -------- 90 | 91 | - ``1:5``, ``0.0:0.1:10.0``, ``linspace(0.0,10.0,11)`` 92 | - convert **Range** to **Array**: ``collect(1:5)`` or simply use ``[1:5]`` (``collect`` is much faster) 93 | 94 | Lists 95 | ------- 96 | 97 | List is one-dimensional array. 98 | 99 | - create: ``my_list = ["a", 1, -0.76]`` 100 | - access: ``m_list[2]``, ``my_list[end]``, ``my_list[end-1]`` 101 | - length: ``length(my_list)`` 102 | 103 | Vectors 104 | ========= 105 | 106 | Vectors 107 | --------- 108 | 109 | - create: ``x=[8,-4,3.5]`` or ``x=[8;-4;3.5]`` 110 | 111 | .. math:: 112 | 113 | \boldsymbol{x}=\left( 114 | \begin{array}{c} 115 | 8\\ 116 | -4\\ 117 | 3.5 118 | \end{array} 119 | \right) 120 | 121 | - index: ``x[2]``, ``x[2:3]``, ``x[end]``, ``x[1:2:end]`` 122 | 123 | - block vectors 124 | 125 | stacked vector: ``a=[b;c]`` (Note: Both :math:`\boldsymbol{b}` and :math:`\boldsymbol{c}` are vectors, so ``a=[b,c]`` does NOT work). 126 | 127 | .. math:: 128 | 129 | \boldsymbol{a}=\left( 130 | \begin{array}{c} 131 | \boldsymbol{b}\\ 132 | \boldsymbol{c} 133 | \end{array} 134 | \right) 135 | 136 | - mix vectors with scalars: ``a=[b; 2; c; -6]`` 137 | 138 | - list with vectors :math:`\boldsymbol{a},\boldsymbol{b},\boldsymbol{c}`: ``vector_list=[a,b,c]`` 139 | 140 | * second vector in this list: ``vector_list[2]`` 141 | * access an element in a vector: ``vector_list[2][3]`` 142 | 143 | - Basic functions for arrays: 144 | 145 | - sum of a vector: ``sum(x)`` 146 | - mean of the entries: ``mean(x)`` 147 | - :math:`\boldsymbol{0}_n` (vector with all entries 0): ``zeros(n)`` 148 | - :math:`\boldsymbol{1}_n` (vector with all entries 1): ``ones(n)`` 149 | 150 | Vector operations 151 | ------------------- 152 | 153 | - vector addition and subtraction (the arrays must have the same length): ``+``, ``-`` 154 | 155 | - scalar-vector addition: ``[2,4,8]+3`` 156 | 157 | .. math:: 158 | 159 | \left( 160 | \begin{array}{c} 161 | 2\\ 162 | 4\\ 163 | 8\\ 164 | \end{array} 165 | \right) 166 | + 3 = 167 | \left( 168 | \begin{array}{c} 169 | 5\\ 170 | 7\\ 171 | 11\\ 172 | \end{array} 173 | \right) 174 | 175 | - scalar-vector multiplication: ``-2*[1,9,6]`` or ``[1,9,6]*(-2)`` 176 | 177 | .. math:: 178 | 179 | -2\, 180 | \left( 181 | \begin{array}{c} 182 | 1\\ 183 | 9\\ 184 | 6\\ 185 | \end{array} 186 | \right) 187 | = 188 | \left( 189 | \begin{array}{c} 190 | -2\\ 191 | -18\\ 192 | -12\\ 193 | \end{array} 194 | \right) 195 | 196 | - inner product :math:`\boldsymbol{a}^T\boldsymbol{b}`: ``dot(a,b)`` (:math:`\boldsymbol{a}` and :math:`\boldsymbol{b}` must have the same length) 197 | - vector-vector element-wise operation: ``[2,4].*[10,20]`` 198 | 199 | Norm and distance 200 | ---------------------- 201 | 202 | - ``norm(x)`` 203 | 204 | .. math:: 205 | 206 | \left\|\boldsymbol{x}\right\|=\sqrt{x_1^2+x_2^2+\dots+x_n^2} 207 | 208 | - ``norm(x-y)`` 209 | 210 | .. math:: 211 | 212 | \left\|\boldsymbol{x}-\boldsymbol{y}\right\| 213 | 214 | - root mean square: ``rms(x)`` 215 | 216 | .. math:: 217 | 218 | \boldsymbol{x}_{\text{rms}}=\sqrt{\frac{1}{n}\left(x_1^2+x_2^2+\dots+x_n^2\right)}=\frac{\left\|\boldsymbol{x}\right\|}{\sqrt{n}} 219 | 220 | - angle between vectors: ``angle_a_b = acos(dot(a,b)/(norm(a)*norm(b)))`` 221 | 222 | .. math:: 223 | 224 | \angle (\boldsymbol{a},\boldsymbol{b})=\arccos \left(\frac{\boldsymbol{a}^T\boldsymbol{b}}{\left\|\boldsymbol{a}\right\|\left\|\boldsymbol{b}\right\|} \right) 225 | 226 | 227 | Matrices 228 | ============= 229 | 230 | Matrics 231 | ---------- 232 | 233 | Matrices are 2D or higher dimensional arrays. 234 | 235 | - spaces separate entries in a row; semicolons separate individual rows: ``A=[2 -4 8.2; -5.5 3.5 63]`` 236 | 237 | .. math:: 238 | 239 | \boldsymbol{A}= 240 | \left( 241 | \begin{array}{ccc} 242 | 2 & -4 & 8.2\\ 243 | -5.5 & 3.5 & 63\\ 244 | \end{array} 245 | \right) 246 | 247 | - ``A_rows, A_cols = size(A)``: returns the tuple containing the dimensions of :math:`\boldsymbol{A}`. (``A_rows`` is ``size(A)[1]``, ``A_cols`` is ``size(A)[2]``). 248 | 249 | - block matrix: ``X=[A B; C D]`` (:math:`\boldsymbol{A}, \boldsymbol{B}, \boldsymbol{C}` and :math:`\boldsymbol{D}` are matrices) 250 | 251 | .. math:: 252 | 253 | \boldsymbol{X}= 254 | \left( 255 | \begin{array}{ccc} 256 | \boldsymbol{A} & \boldsymbol{B}\\ 257 | \boldsymbol{C} & \boldsymbol{D}\\ 258 | \end{array} 259 | \right) 260 | 261 | - useful matrices: 262 | 263 | - :math:`\boldsymbol{0}_{m \times n}` (vector with all entries :math:`0`): ``zeros(m,n)`` 264 | - :math:`\boldsymbol{1}_{m \times n}` (vector with all entries :math:`1`): ``ones(m,n)`` 265 | - :math:`\boldsymbol{I}_{n}` (identity matrix of dimension :math:`n`): ``eye(n)`` 266 | - :math:`\text{diag}(\boldsymbol{x})` (diagonal matrix, :math:`\boldsymbol{x}` is a vector): ``diagm(x)`` 267 | 268 | Matrix operations 269 | ------------------------ 270 | 271 | - :math:`\boldsymbol{A}^T` (transpose): ``A'`` 272 | - matrix addition and subtraction: ``+``, ``-`` 273 | - matrix-scalar operations ``+``, ``-``, ``*``, ``/`` apply elementwise: ``10 * [1 2; 3 4]`` gives ``[10 20; 30 40]`` 274 | - matrix-vector multiplication ``*`` 275 | 276 | For example, ``[1 2; 3 4]*[5, 6]``: 277 | 278 | .. math:: 279 | 280 | \left( 281 | \begin{array}{cc} 282 | 1 & 2\\ 283 | 3 & 4\\ 284 | \end{array} 285 | \right) 286 | \left( 287 | \begin{array}{c} 288 | 5\\ 289 | 6\\ 290 | \end{array} 291 | \right) 292 | 293 | - ``*`` is also used for matrix-matrix multiplication 294 | - ``*.`` is for matrix-matrix element-wise multiplication 295 | 296 | Useful functions 297 | ------------------- 298 | 299 | - sum of all entries of a matrix: ``sum(A)`` 300 | - average of entries of a matrix: ``mean(A)`` 301 | - Element-wise *max* and *min*: ``max(A, B)``, ``min(A, B)`` (the arguments must have the same size unless one is a scalar) 302 | - ``norm(A[:])`` or ``vecnorm(A)`` means :math:`\left(\sum_{i,j} A_{i,j}^2\right)^{1/2}` (Note that ``norm(A)`` has a different meaning and do not misuse it) 303 | 304 | Tricks 305 | ========== 306 | 307 | For loops 308 | ----------- 309 | 310 | - loop over a **Range** 311 | 312 | .. code:: julia 313 | 314 | value = 0 315 | for i in 1:10 316 | value += i 317 | end 318 | 319 | - loop over a **List** 320 | 321 | .. code:: julia 322 | 323 | value = 0 324 | my_list = [1,2,3,4,5] 325 | for i in my_list 326 | value += i 327 | end 328 | 329 | - ``zip``: 330 | 331 | .. code:: julia 332 | 333 | countries = ("Japan", "Korea", "China") 334 | cities = ("Tokyo", "Seoul", "Beijing") 335 | for (country, city) in zip(countries, cities) 336 | println("The capital of $country is $city") 337 | end 338 | 339 | - ``enumerate``: yields a tuple ``(index, value)`` 340 | 341 | .. code:: julia 342 | 343 | countries = ("Japan", "Korea", "China") 344 | cities = ("Tokyo", "Seoul", "Beijing") 345 | for (i, country) in enumerate(countries) 346 | city = cities[i] 347 | println("The capital of $country is $city") 348 | end 349 | 350 | 351 | 352 | 353 | Initialization 354 | ---------------- 355 | 356 | Data types 357 | ^^^^^^^^^^^^ 358 | 359 | List (1D **Array**) and matrix (2D or higher dimensional **Array**) may include entries of different types: ``[1, "2", sin, 3.0]``, ``[1, "2"; sin, 3.0]`` 360 | 361 | .. code:: jlcon 362 | 363 | julia> [1, "2", sin, 3.0] 364 | 4-element Array{Any,1}: 365 | 1 366 | "2" 367 | sin 368 | 3.0 369 | 370 | julia> [1 "2"; sin 3.0] 371 | 2x2 Array{Any,2}: 372 | 1 "2" 373 | sin 3.0 374 | 375 | 如果元素类型只有常用的数学类型的时候,会按 ``Int64``, ``Rational{Int64}``, ``Float64`` 的顺序进行自动的promotion. 376 | 如果元素中有复数,则其余实数类型也会被自动转换为复数,实部和复部类型按之前的顺序自动promotion. 377 | 378 | 例子如下: 379 | 380 | .. code:: jlcon 381 | 382 | julia> [2, 3//4] 383 | 2-element Array{Rational{Int64},1}: 384 | 2//1 385 | 3//4 386 | 387 | julia> [2, 3//4, 0.1] 388 | 3-element Array{Float64,1}: 389 | 2.0 390 | 0.75 391 | 0.1 392 | 393 | julia> [2, 3//4, 0.1, 1+2im] 394 | 4-element Array{Complex{Float64},1}: 395 | 2.0+0.0im 396 | 0.75+0.0im 397 | 0.1+0.0im 398 | 1.0+2.0im 399 | 400 | 然而,list 或 matrix 的类型也可以进行明确指定。如: 401 | 402 | .. code:: jlcon 403 | 404 | julia> Float64[1,2,3] 405 | 3-element Array{Float64,1}: 406 | 1.0 407 | 2.0 408 | 3.0 409 | 410 | Empty array 411 | ^^^^^^^^^^^^^^ 412 | 413 | Initialize an empty array. List example (1D array): 414 | 415 | .. code:: jlcon 416 | 417 | julia> Float64[] 418 | 0-element Array{Float64,1} 419 | 420 | julia> Array(Float64,0) 421 | 0-element Array{Float64,1} 422 | 423 | julia> Array{Float64}(0) 424 | 0-element Array{Float64,1} 425 | 426 | julia> [] 427 | 0-element Array{Any,1} 428 | 429 | Matrix example (2D or higher dimensional array), 初始化某一维度为0: 430 | 431 | .. code:: jlcon 432 | 433 | julia> Array(Float64,0,2) 434 | 0x2 Array{Float64,2} 435 | 436 | julia> Array{Float64}(0,2) 437 | 0x2 Array{Float64,2} 438 | 439 | 也可以用 ``reshape`` 函数实现同样效果: 440 | 441 | .. code:: jlcon 442 | 443 | julia> reshape([],0,2) 444 | 0x2 Array{Any,2} 445 | 446 | Allocate array (no initialization) 447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 448 | 449 | - List 450 | 451 | Allocate a list (1D array), and fill it with random values: 452 | 453 | - 直接使用构造函数 ``Array`` 454 | 455 | .. code:: jlcon 456 | 457 | julia> Array(Float64,3) 458 | 3-element Array{Float64,1}: 459 | 1.08099e-314 460 | 1.08097e-314 461 | 1.08098e-314 462 | 463 | julia> Array{Float64}(3) 464 | 3-element Array{Float64,1}: 465 | 0.0 466 | 1.061e-314 467 | 0.0 468 | 469 | - 基于另一个 list, 创建与之相同类型的 list, 利用函数 ``similar`` 470 | 471 | .. code:: jlcon 472 | 473 | julia> similar([1.0, 2.0, 3.0]) 474 | 3-element Array{Float64,1}: 475 | 1.0818e-314 476 | 1.08225e-314 477 | 1.08853e-314 478 | 479 | - 如果数据类型为 Any, 则会被填充未知量。 480 | 481 | .. code:: jlcon 482 | 483 | julia> Array{Any}(3) 484 | 3-element Array{Any,1}: 485 | #undef 486 | #undef 487 | #undef 488 | 489 | 当然也等同于使用 ``Array(Any,3)``. 490 | 491 | - Matrix 492 | 493 | - 同理,我们也可以创建一个 2x3 矩阵(元素为随机产生): ``Array(Float64,2,3)`` or ``Array{Float64}(2,3)`` or ``similar([1 2 3; 4 5 6])`` 494 | 495 | - 为方便起见,一维和二维的情况下,Julia提供了两个函数, ``Vector(3)``, ``Matrix(2,3)`` 分别相当于 ``Array(Any,3)`` 以及 ``Array(Any,2,3)``. 496 | 497 | Initialize a matrix 498 | ^^^^^^^^^^^^^^^^^^^^^ 499 | 500 | 创建一个 2x3 矩阵并赋值,可以用下列方式: 501 | 502 | 1. 按行创建 503 | 504 | .. code:: jlcon 505 | 506 | julia> [1 2 3; 4 5 6] 507 | 2x3 Array{Int64,2}: 508 | 1 2 3 509 | 4 5 6 510 | 511 | #. 按列创建 512 | 513 | .. code:: jlcon 514 | 515 | julia> [[1, 4] [2, 5] [3, 6]] 516 | 2x3 Array{Int64,2}: 517 | 1 2 3 518 | 4 5 6 519 | 520 | #. 由另一个 list 或 matrix 变形而来 521 | 522 | .. code:: jlcon 523 | 524 | julia> reshape([1,4,2,5,3,6], 2, 3) 525 | 2x3 Array{Int64,2}: 526 | 1 2 3 527 | 4 5 6 528 | 529 | .. note:: Julia 是 **列主序** (Column-major) 530 | 531 | * Column-major order: Julia, Fortran, R, Matlab, GNU Octave, BLAS, LAPACK, OpenGL/OpenGL ES 532 | * Row-major order: C/C++, Mathematica, Pascal, Python, C#/CLI/.Net, Direct3D 533 | 534 | 由上面 ``reshape`` 结果也可以看出 Julia 是列主序(Column-major)的。而高维矩阵也可以看成等效的一维矩阵, 535 | 比如 ``A = [1 2 3; 4 5 6]``, 那么 ``A[4]`` 等于 :math:`4` 而非 :math:`5`. 536 | 因此也可以使用 ``A[:]`` 得到矩阵转换为一维数组的结果。在用多维和一维这两种不同方式表示时,有两个函数很有用: 537 | 538 | - ``ind2sub(dims, index)`` 求一维数组表示法中的 index 元素在多维表示法中的位置。 539 | 如 ``ind2sub((2,3), 4)`` 返回 ``(2,2)``, 意即在一个 ``2x3`` 维的矩阵中,位置 ``(2,2)`` 对应一维数组中的脚标 ``4`` 540 | - ``sub2ind((2,3), 2,2)`` 返回 ``4``, 表示在 ``2x3`` 的矩阵中位置 ``(2,2)`` 对应一维数组中的第 ``4`` 个位置。 541 | 542 | 543 | Useful functions 544 | ----------------- 545 | 546 | .. note:: 参考 547 | 548 | 1. http://docs.julialang.org/en/stable/stdlib/arrays/ 549 | #. http://docs.julialang.org/en/stable/stdlib/collections/ 550 | #. https://en.wikibooks.org/wiki/Introducing_Julia/Arrays_and_tuples 551 | 552 | 基本信息 553 | ^^^^^^^^^^^^^ 554 | 555 | 以 ``exampleArray = [1 2 3; 4 5 6; 7 8 9]`` 为例: 556 | 557 | - ``ndims(exampleArray)`` 返回维度 ``2`` 558 | - ``size(exampleArray)`` 返回各维大小 ``(3,3)`` 559 | - ``length(exampleArray)`` 返回总元素数量 ``9`` 560 | 561 | 最大(小)值,以及求和 562 | ^^^^^^^^^^^^^^^^^^^^^^^^ 563 | 564 | - ``maximum``, ``minimum`` 求list或矩阵(及其某一维度上)的最大值和最小值 565 | - ``maxabs``, ``minabs``, 绝对值的最大(小)值 566 | - ``findmax``, ``findmin`` 会返回一个tuple,``(value, index)``,即包括最大(小)值及其位置 567 | - ``sum``, 求和 568 | - ``sumabs``, 求绝对值之和 569 | - ``sumabs2``, 求平方和,等同于 ``sum(abs2(itr))`` 570 | 571 | 572 | 查找,筛选 573 | ^^^^^^^^^^^^^^^^^^ 574 | 575 | - ``in`` 判断元素是否属于某array,如 ``in(3, 1:10)`` 会返回 ``true`` 576 | - ``count(predicate, A)`` 返回所有满足 ``predicate`` 的元素数量. 如 ``count(isodd, exampleArray)`` 返回 ``5``. 577 | - ``find(predicate, A)`` Return a vector of the linear indexes of ``A`` where ``predicate`` returns ``true``. 578 | 579 | .. code:: jlcon 580 | 581 | julia> find(iseven,1:10) 582 | 5-element Array{Int64,1}: 583 | 2 584 | 4 585 | 6 586 | 8 587 | 10 588 | 589 | 如果找不到,则会返回 ``0``. 常用的内置判断函数有 ``iseven``, ``isodd``, ``isinteger``, ``isreal``, ``isprime``, 还可以用 lambda 表达式自定义函数。 590 | 591 | - ``findfirst`` 常用用法 (``findlast`` 用法类似): 592 | 593 | - ``findfirst(A)`` Return the index of the first non-zero value in ``A`` (determined by ``A[i]!=0``). 594 | - ``findfirst(A,v)`` Return the index of the first element equal to ``v`` in ``A``. 如 ``findfirst(2:2:10, 6)`` 返回 ``3``. 595 | - ``findfirst(predicate, A)`` Return the index of the first element of ``A`` for which predicate returns ``true``. 如 ``findfirst(isprime, 0:10)`` 返回 ``3``. 596 | 597 | - ``findnext`` 与 ``findfirst`` 相似,但提供一个额外的参数表示搜索开始位置。所以 ``findfirst(predicate, A)`` 相当于 ``findnext(predicate, A, 1)`` 598 | 599 | 还有一个相似的函数 ``findprev``. 600 | 601 | 注意,``find``, ``findfirst``, ``findlast`` 返回的值都是 index,因此想要拿到对应的值就应该用 ``A[findfirst(predicate,A)]`` 类似的形式。 602 | 603 | - ``filter`` 与 ``find`` 作用相似,不同点是 ``filter`` 直接返回的是元素值而 ``find`` 返回的是对应的脚标。同时 ``filter!`` 可以直接将原来的array改变,只保留满足条件的值。 604 | - 使用 broadcasting 与 indexing. 如 ``A[A.>4]`` 与 ``filter(x->x>4, A)`` 作用相同; ``A[isodd.(A)]`` 与 ``filter(isodd, A)`` 作用相同 (``isodd.(A)`` 这种写法仅Julia 0.5版本之后支持). 605 | 注意,``A[A%3.==0]`` 是正确写法而 ``A[A.%3==0]`` 是不正确的。(实践发现当 ``A`` 元素比较多时,0.4版本这种方式比 ``filter`` 要更快一些。但在另一机器上0.5版本测试结果各有胜负) 606 | - ``any(predicate, A)``: 只要 ``A`` 中存在一个元素满足条件就返回 ``true`` 607 | - ``all(predicate, A)``: 只有 ``A`` 中所有元素都满足条件就返回 ``true`` 608 | 609 | 删除行或列 610 | ^^^^^^^^^^^^^^^^ 611 | 612 | 假设一个 3x3 的矩阵 ``A``, 我们要删除其第二行变成一个 2x3 矩阵。在Julia中,没有办法直接删除元素来改变原矩阵内容,即 ``A[2,:]=[]`` 类似这样的做法是无效的。 613 | 因此我们只能复制原矩阵中部分值赋值给新的矩阵。使用之前提到的用 predicate 函数来indexing的方法,取出剩余部分赋值给新的矩阵 ``B``. 614 | 即 ``B=A[1:end.!=2,:]`` 615 | 616 | Joining arrays and matrices 617 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 618 | 619 | - ``[A B]`` or ``hcat(A, B)`` 620 | - ``[A; B]`` or ``vcat(A, B)`` 621 | - ``[A B; C D]`` 622 | - ``vec(A)`` 把 ``A`` 变成一维数组 623 | 624 | Array of arrays 625 | ------------------ 626 | 627 | - 基本例子: 628 | 629 | .. code:: jlcon 630 | 631 | julia> Array[1:3, 4:6] 632 | 2-element Array{Array{T,N},1}: 633 | [1,2,3] 634 | [4,5,6] 635 | 636 | julia> Array[[1,2], [3,4]] 637 | 2-element Array{Array{T,N},1}: 638 | [1,2] 639 | [3,4] 640 | 641 | - Create an empty array of arrays: 642 | 643 | .. code:: jlcon 644 | 645 | julia> Array{Int}[] 646 | 0-element Array{Array{Int64,N},1} 647 | 648 | julia> Array{Int, 2}[] 649 | 0-element Array{Array{Int64,2},1} 650 | 651 | julia> Array(Array{Float64,3},0) 652 | 0-element Array{Array{Float64,3},1} 653 | 654 | - Create by specifying the size: 655 | 656 | .. code:: jlcon 657 | 658 | julia> Array(Array{Int64, 2},3) 659 | 3-element Array{Array{Int64,2},1}: 660 | #undef 661 | #undef 662 | #undef 663 | 664 | julia> Array{Array{Int64, 2}}(3) 665 | 3-element Array{Array{Int64,2},1}: 666 | #undef 667 | #undef 668 | #undef 669 | 670 | - Use ``hcat()`` or ``vcat()`` to convert an array to a matrix (Refer to `slurping and splatting <http://docs.julialang.org/en/stable/manual/faq/#what-does-the-operator-do>`_) 671 | 672 | .. code:: jlcon 673 | 674 | julia> a = Array[[1,2],[3,4],[5,6]] 675 | 3-element Array{Array{T,N},1}: 676 | [1,2] 677 | [3,4] 678 | [5,6] 679 | 680 | julia> hcat(a...) 681 | 2x3 Array{Int64,2}: 682 | 1 3 5 683 | 2 4 6 684 | 685 | julia> vcat(a...) 686 | 6-element Array{Int64,1}: 687 | 1 688 | 2 689 | 3 690 | 4 691 | 5 692 | 6 693 | 694 | julia> b = Array[[1 2],[3 4],[5 6]] 695 | 3-element Array{Array{T,N},1}: 696 | 1x2 Array{Int64,2}: 697 | 1 2 698 | 1x2 Array{Int64,2}: 699 | 3 4 700 | 1x2 Array{Int64,2}: 701 | 5 6 702 | 703 | julia> vcat(b...) 704 | 3x2 Array{Int64,2}: 705 | 1 2 706 | 3 4 707 | 5 6 708 | 709 | julia> hcat(b...) 710 | 1x6 Array{Int64,2}: 711 | 1 2 3 4 5 6 712 | 713 | Performance 714 | =============== 715 | 716 | 参考 `Reddit Link <https://www.reddit.com/r/Julia/comments/3vhv8l/neat_little_speed_comparison_between_forloops_and/>`_ 中的写法 717 | 以及 `Performance Tips <http://docs.julialang.org/en/stable/manual/performance-tips/>`_, 在比较运行效率时,最好把例子都写进同一个函数。 718 | 719 | List comprehension vs ``for`` loop vs ``map`` 720 | ------------------------------------------------- 721 | 722 | .. code:: julia 723 | 724 | function test_loop() 725 | atest = rand(1000) 726 | btest = rand(30000) 727 | 728 | tic() 729 | list1 = [count(x-> v >=x, atest) for v in btest] 730 | list_untyped = toq() 731 | 732 | tic() 733 | list2 = Int64[count(x-> v >=x, atest) for v in btest] 734 | list_typed = toq() 735 | 736 | tic() 737 | len = length(btest) 738 | list3 = Array(Int64, len) 739 | for i in 1:len 740 | list3[i]=count(x-> btest[i] >=x, atest) 741 | end 742 | forloop = toq() 743 | 744 | tic() 745 | list4 = map(v->count(x-> v >=x, atest), btest) 746 | mapfun = toq() 747 | 748 | print(" 749 | list_untyped: $list_untyped 750 | list_typed: $list_typed 751 | forloop: $forloop 752 | mapfun: $mapfun 753 | ") 754 | end 755 | 756 | 757 | 下面是 Julia 0.4.7 运行第二次的结果(第一次结果未编绎不准确,故不能用作标准), 0.5 版本结果一致。因此这种情况下 ``map`` 要稍快一些。 758 | 759 | .. code:: jlcon 760 | 761 | julia> test_loop() 762 | 763 | list_untyped: 0.848853296 764 | list_typed: 0.875462525 765 | forloop: 1.561129306 766 | mapfun: 0.836571566 767 | 768 | 769 | ``findlast`` faster than ``count`` 770 | --------------------------------------- 771 | 772 | 例子:两个 array (大小可能不同), ``A`` 和 ``B``, 现在需要找出 ``B`` 中每个元素落在 ``A`` 的哪个区间,比如 ``A = [1,3,5,7]``, ``B = [1.2,5.5]``, 773 | 则会返回 ``B`` 中每个元素在 ``A`` 中的相应位置 ``1`` (即 ``1.2`` 属于区间 ``[1,3]``) 和 ``3`` (``5.5`` 属于区间 ``[5,7]``). Mathematica 中可以使用 ``LengthWhile`` 来做, 774 | Julia 中有两个函数可以完成: ``findlast`` (定义在 "array.jl" 中) 与 ``count`` (定义在 "reduce.jl" 中),而经多次测试,前者更快且使用的内存更少。 775 | 776 | .. code:: julia 777 | 778 | function test_findlast_count() 779 | atest = rand(1000) 780 | btest = rand(30000) 781 | 782 | tic() 783 | list1 = Int64[findlast(x-> v >=x, atest) for v in btest] 784 | findlast_time = toq() 785 | 786 | tic() 787 | list2 = Int64[count(x-> v >=x, atest) for v in btest] 788 | count_time = toq() 789 | 790 | print(" 791 | findlast_time: $findlast_time 792 | count_time: $count_time 793 | ") 794 | end 795 | 796 | .. code:: jlcon 797 | 798 | julia> test_findlast_count() 799 | 800 | findlast_time: 0.002317571 801 | count_time: 0.866425052 802 | 803 | 关于求最值 804 | -------------- 805 | 806 | - single array: ``for`` loop vs ``maximum`` 807 | 808 | ``maximum()`` is faster. 809 | 810 | .. code:: julia 811 | 812 | function test_singarray_max() 813 | arr = rand(100000000) 814 | 815 | tic() 816 | max_arr = 0.0 817 | for x in arr 818 | if max_arr < x 819 | max_arr = x 820 | end 821 | end 822 | single_array_forloop = toq() 823 | 824 | tic() 825 | max_arr2 = maximum(arr) 826 | single_array_maximum = toq() 827 | 828 | print(" 829 | single_array_forloop: $single_array_forloop 830 | single_array_maximum: $single_array_maximum 831 | ") 832 | end 833 | 834 | .. code:: jlcon 835 | 836 | julia> test_singarray_max() 837 | 838 | single_array_forloop: 0.177215175 839 | single_array_maximum: 0.077552238 840 | 841 | - multiple arrays: different versions of ``for`` loop vs ``maximum`` 842 | 843 | ``for`` loop using indexing is the fatest. 844 | 845 | .. code:: julia 846 | 847 | function test_multiarray_max() 848 | arr1=rand(100000000) 849 | arr2=rand(100000000) 850 | 851 | tic() 852 | max_arr = 0.0 853 | for x in arr1-arr2 # a temporary array arr1-arr2 is generated here 854 | if max_arr < x 855 | max_arr = x 856 | end 857 | end 858 | multiarray_forloop_temp = toq() 859 | 860 | tic() 861 | max_arr = 0.0 862 | for i in 1:length(arr1) 863 | temp = arr1[i] - arr2[i] 864 | if max_arr < temp 865 | max_arr = temp 866 | end 867 | end 868 | multiarray_forloop_index = toq() 869 | 870 | tic() 871 | max_arr = 0.0 872 | for (a,b) in zip(arr1,arr2) 873 | temp = a-b 874 | if max_arr < temp 875 | max_arr = temp 876 | end 877 | end 878 | multiarray_forloop_zip = toq() 879 | 880 | tic() 881 | list = maximum(arr1-arr2) 882 | multiarray_maximum = toq() 883 | 884 | print(" 885 | multiarray_forloop_temp: $multiarray_forloop_temp 886 | multiarray_forloop_index: $multiarray_forloop_index 887 | multiarray_forloop_zip: $multiarray_forloop_zip 888 | multiarray_maximum: $multiarray_maximum 889 | ") 890 | end 891 | 892 | .. code:: jlcon 893 | 894 | julia> test_multiarray_max() 895 | 896 | multiarray_forloop_temp: 0.434184324 897 | multiarray_forloop_index: 0.161199946 898 | multiarray_forloop_zip: 0.206321564 899 | multiarray_maximum: 0.446215882 900 | --------------------------------------------------------------------------------