{"generator":"Jekyll","link":[{"@attributes":{"href":"https:\/\/etern.github.io\/feed.xml","rel":"self","type":"application\/atom+xml"}},{"@attributes":{"href":"https:\/\/etern.github.io\/","rel":"alternate","type":"text\/html"}}],"updated":"2022-04-19T09:11:07+00:00","id":"https:\/\/etern.github.io\/feed.xml","title":"Blog","subtitle":"\u60df\u6c5f\u4e0a\u4e4b\u6e05\u98ce\uff0c\u4e0e\u5c71\u95f4\u4e4b\u660e\u6708\uff0c\u8033\u5f97\u4e4b\u800c\u4e3a\u58f0\uff0c\u76ee\u9047\u4e4b\u800c\u6210\u8272\n","entry":[{"title":"quick sort","link":{"@attributes":{"href":"https:\/\/etern.github.io\/2022\/04\/19\/quick-sort.html","rel":"alternate","type":"text\/html","title":"quick sort"}},"published":"2022-04-19T08:50:05+00:00","updated":"2022-04-19T08:50:05+00:00","id":"https:\/\/etern.github.io\/2022\/04\/19\/quick-sort","content":"<p>When haskellers say they can implement quick sort in just 2 loc:<\/p>\n\n<div class=\"language-haskell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"n\">qsort<\/span> <span class=\"kt\">[]<\/span> <span class=\"o\">=<\/span> <span class=\"kt\">[]<\/span>\n<span class=\"n\">qsort<\/span> <span class=\"p\">(<\/span><span class=\"n\">x<\/span><span class=\"o\">:<\/span><span class=\"n\">xs<\/span><span class=\"p\">)<\/span> <span class=\"o\">=<\/span> <span class=\"n\">qsort<\/span> <span class=\"p\">[<\/span><span class=\"n\">a<\/span> <span class=\"o\">|<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&lt;-<\/span> <span class=\"n\">xs<\/span><span class=\"p\">,<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&lt;=<\/span> <span class=\"n\">x<\/span><span class=\"p\">]<\/span> <span class=\"o\">++<\/span> <span class=\"p\">[<\/span><span class=\"n\">x<\/span><span class=\"p\">]<\/span> <span class=\"o\">++<\/span> <span class=\"n\">qsort<\/span> <span class=\"p\">[<\/span><span class=\"n\">a<\/span> <span class=\"o\">|<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&lt;-<\/span> <span class=\"n\">xs<\/span><span class=\"p\">,<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&gt;<\/span> <span class=\"n\">x<\/span><span class=\"p\">]<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>Pythoner smiles:<\/p>\n\n<div class=\"language-python highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"k\">def<\/span> <span class=\"nf\">qsort<\/span><span class=\"p\">(<\/span><span class=\"n\">x<\/span><span class=\"o\">=<\/span><span class=\"p\">[],<\/span> <span class=\"o\">*<\/span><span class=\"n\">xs<\/span><span class=\"p\">):<\/span>\n\t<span class=\"k\">return<\/span> <span class=\"n\">x<\/span> <span class=\"ow\">and<\/span> <span class=\"p\">(<\/span><span class=\"n\">qsort<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"p\">[<\/span><span class=\"n\">a<\/span> <span class=\"k\">for<\/span> <span class=\"n\">a<\/span> <span class=\"ow\">in<\/span> <span class=\"n\">xs<\/span> <span class=\"k\">if<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">x<\/span><span class=\"p\">])<\/span> <span class=\"o\">+<\/span> <span class=\"p\">[<\/span><span class=\"n\">x<\/span><span class=\"p\">]<\/span> <span class=\"o\">+<\/span> <span class=\"n\">qsort<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"p\">[<\/span><span class=\"n\">b<\/span> <span class=\"k\">for<\/span> <span class=\"n\">b<\/span> <span class=\"ow\">in<\/span> <span class=\"n\">xs<\/span> <span class=\"k\">if<\/span> <span class=\"n\">b<\/span> <span class=\"o\">&gt;=<\/span><span class=\"n\">x<\/span><span class=\"p\">]))<\/span>\n<span class=\"c1\"># (x != 0) call with arg destructuring: qsort(*[3, 1, 2])\n<\/span><\/code><\/pre><\/div><\/div>\n\n<p>For linked list sort, we don\u2019t have to do inplace swaping, this is\nalright. Argument destructuring is used to imitate haskell pattern\nmatching, and here is a real pattern matching version (py3.10):<\/p>\n\n<div class=\"language-python highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"k\">def<\/span> <span class=\"nf\">qsort<\/span><span class=\"p\">(<\/span><span class=\"n\">xs<\/span><span class=\"p\">):<\/span>\n    <span class=\"n\">match<\/span> <span class=\"n\">xs<\/span><span class=\"p\">:<\/span>\n        <span class=\"n\">case<\/span> <span class=\"p\">[]:<\/span>\n            <span class=\"k\">return<\/span> <span class=\"p\">[]<\/span>\n        <span class=\"n\">case<\/span> <span class=\"p\">[<\/span><span class=\"n\">x<\/span><span class=\"p\">,<\/span> <span class=\"o\">*<\/span><span class=\"n\">rest<\/span><span class=\"p\">]:<\/span>\n            <span class=\"k\">return<\/span> <span class=\"n\">qsort<\/span><span class=\"p\">([<\/span><span class=\"n\">a<\/span> <span class=\"k\">for<\/span> <span class=\"n\">a<\/span> <span class=\"ow\">in<\/span> <span class=\"n\">rest<\/span> <span class=\"k\">if<\/span> <span class=\"n\">a<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">x<\/span><span class=\"p\">])<\/span> <span class=\"o\">+<\/span> <span class=\"p\">[<\/span><span class=\"n\">x<\/span><span class=\"p\">]<\/span> <span class=\"o\">+<\/span> <span class=\"n\">qsort<\/span><span class=\"p\">([<\/span><span class=\"n\">b<\/span> <span class=\"k\">for<\/span> <span class=\"n\">b<\/span> <span class=\"ow\">in<\/span> <span class=\"n\">rest<\/span> <span class=\"k\">if<\/span> <span class=\"n\">b<\/span> <span class=\"o\">&gt;=<\/span><span class=\"n\">x<\/span><span class=\"p\">])<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>Still concise, power of multi paradigm language!<\/p>","author":{"name":{}},"summary":"When haskellers say they can implement quick sort in just 2 loc:"},{"title":"Add toggle switch for everything to your Windows desktop","link":{"@attributes":{"href":"https:\/\/etern.github.io\/2022\/02\/16\/add-toggle-switch-to-your-windows-desktop.html","rel":"alternate","type":"text\/html","title":"Add toggle switch for everything to your Windows desktop"}},"published":"2022-02-16T10:56:55+00:00","updated":"2022-02-16T10:56:55+00:00","id":"https:\/\/etern.github.io\/2022\/02\/16\/add-toggle-switch-to-your-windows-desktop","content":"<p>The idea is simple:<\/p>\n<ol>\n  <li>With powershell script, you can do almost everything on Windows,\nfor instance, start\/stop a service:\n    <div class=\"language-powershell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"n\">Start-Service<\/span><span class=\"w\"> <\/span><span class=\"nt\">-Name<\/span><span class=\"w\"> <\/span><span class=\"nx\">FortiSslvpnDaemon<\/span><span class=\"w\">\n<\/span><span class=\"n\">Stop-Service<\/span><span class=\"w\"> <\/span><span class=\"nt\">-Name<\/span><span class=\"w\"> <\/span><span class=\"nx\">FortiSslvpnDaemon<\/span><span class=\"w\">\n<\/span><\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>Create a desktop shortcut for that script<\/li>\n  <li>You can change the look of shortcut on clicking!! That makes a\nswitch with visual state<\/li>\n<\/ol>\n\n<p>Here an example powershell script that start\/stop a service:<\/p>\n\n<div class=\"language-powershell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$shortCutFile<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"C:\\Users\\xxx\\Desktop\\ToggleFortiVPNDaemon.lnk\"<\/span><span class=\"w\">\n<\/span><span class=\"nv\">$svcName<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"FortiSslvpnDaemon\"<\/span><span class=\"w\">\n\n<\/span><span class=\"kr\">function<\/span><span class=\"w\"> <\/span><span class=\"nf\">Change-Shortcut-Icon<\/span><span class=\"p\">(<\/span><span class=\"nv\">$scFile<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"nv\">$iconNo<\/span><span class=\"p\">)<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"nv\">$WScriptShell<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"n\">New-Object<\/span><span class=\"w\"> <\/span><span class=\"nt\">-ComObject<\/span><span class=\"w\"> <\/span><span class=\"nx\">WScript.Shell<\/span><span class=\"w\">\n    <\/span><span class=\"nv\">$shortcut<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"nv\">$WScriptShell<\/span><span class=\"o\">.<\/span><span class=\"nf\">CreateShortcut<\/span><span class=\"p\">(<\/span><span class=\"nv\">$scFile<\/span><span class=\"p\">)<\/span><span class=\"w\">\n    <\/span><span class=\"nv\">$shortcut<\/span><span class=\"o\">.<\/span><span class=\"nf\">IconLocation<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"C:\\Windows\\System32\\imageres.dll, <\/span><span class=\"nv\">$iconNo<\/span><span class=\"s2\">\"<\/span><span class=\"w\">\n    <\/span><span class=\"nv\">$shortcut<\/span><span class=\"o\">.<\/span><span class=\"nf\">Save<\/span><span class=\"p\">()<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><span class=\"w\">\n\n<\/span><span class=\"nv\">$svc<\/span><span class=\"w\"> <\/span><span class=\"o\">=<\/span><span class=\"w\"> <\/span><span class=\"n\">Get-Service<\/span><span class=\"w\"> <\/span><span class=\"nt\">-Name<\/span><span class=\"w\"> <\/span><span class=\"nv\">$svcName<\/span><span class=\"w\">\n<\/span><span class=\"kr\">if<\/span><span class=\"w\"> <\/span><span class=\"p\">(<\/span><span class=\"nv\">$svc<\/span><span class=\"o\">.<\/span><span class=\"nf\">Status<\/span><span class=\"w\"> <\/span><span class=\"o\">-eq<\/span><span class=\"w\"> <\/span><span class=\"s1\">'Running'<\/span><span class=\"p\">)<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"n\">Stop-Service<\/span><span class=\"w\"> <\/span><span class=\"nt\">-Name<\/span><span class=\"w\"> <\/span><span class=\"nv\">$svcName<\/span><span class=\"w\">\n    <\/span><span class=\"n\">echo<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"stoped\"<\/span><span class=\"w\">\n    <\/span><span class=\"n\">Change-Shortcut-Icon<\/span><span class=\"w\"> <\/span><span class=\"nv\">$shortCutFile<\/span><span class=\"w\"> <\/span><span class=\"nx\">26<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><span class=\"w\"> <\/span><span class=\"kr\">elseif<\/span><span class=\"w\"> <\/span><span class=\"p\">(<\/span><span class=\"nv\">$svc<\/span><span class=\"o\">.<\/span><span class=\"nf\">Status<\/span><span class=\"w\"> <\/span><span class=\"o\">-eq<\/span><span class=\"w\"> <\/span><span class=\"s1\">'Stopped'<\/span><span class=\"p\">)<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"n\">Start-Service<\/span><span class=\"w\"> <\/span><span class=\"nt\">-Name<\/span><span class=\"w\"> <\/span><span class=\"nv\">$svcName<\/span><span class=\"w\">\n    <\/span><span class=\"n\">echo<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"started\"<\/span><span class=\"w\">\n    <\/span><span class=\"n\">Change-Shortcut-Icon<\/span><span class=\"w\"> <\/span><span class=\"nv\">$shortCutFile<\/span><span class=\"w\"> <\/span><span class=\"nx\">28<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><span class=\"w\">\n<\/span><\/code><\/pre><\/div><\/div>\n\n<p>Store this script as <code class=\"language-plaintext highlighter-rouge\">ToggleFortiVPNDaemon.ps1<\/code> somewhere like\n<code class=\"language-plaintext highlighter-rouge\">C:\/myscripts<\/code>, and create Desktop shortcut for it, rename the\nshortcut to <code class=\"language-plaintext highlighter-rouge\">ToggleFortiVPNDaemon<\/code>.<\/p>\n\n<p>To run the shortcut as Admin (required by service commands), open\nproperty dialog of the shortcut, in the <code class=\"language-plaintext highlighter-rouge\">Target<\/code> field, add\n<code class=\"language-plaintext highlighter-rouge\">powershell<\/code> before the script name, and click <code class=\"language-plaintext highlighter-rouge\">Advanced<\/code> button,\ncheck the <code class=\"language-plaintext highlighter-rouge\">Run as Admin<\/code>.<\/p>\n\n<p>Now, double click the Desktop shortcut, after a confirmation for admin\npermission, the service is under control.<\/p>\n\n<p>The shortcut icon changes as you click, to reflect the service state,\nand that\u2019s the fantastic part, let\u2019s examine it a bit more.<\/p>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">Change-Shortcut-Icon<\/code> function accepts a <code class=\"language-plaintext highlighter-rouge\">$iconNo<\/code> argument,\nwhich is the index into icons in resource file <code class=\"language-plaintext highlighter-rouge\">imageres.dll<\/code>, you can\nuse a separate <code class=\"language-plaintext highlighter-rouge\">*.ico<\/code> file for this, but the builtin icon resource is\njust easier for maintain, it\u2019s already there.<\/p>\n\n<p>To view all icons in <code class=\"language-plaintext highlighter-rouge\">imageres.dll<\/code>, I recommand\n<a href=\"https:\/\/www.botproductions.com\/iconview\/iconview.html\">IconViewer<\/a>,\nafter install, it\u2019s integreted in windows property dialog. In above\nscript, I use number 26 and 28, those are:<\/p>\n<ul>\n  <li>red cross icon for <code class=\"language-plaintext highlighter-rouge\">Stopped<\/code> status<\/li>\n  <li>green check icon for <code class=\"language-plaintext highlighter-rouge\">Running<\/code> status<\/li>\n<\/ul>\n\n<p>But I still don\u2019t know how to get the icon number, the #number shown\nin IconViewer is not right, I tried it out, tell me if you know how.<\/p>","author":{"name":{}},"summary":"The idea is simple: With powershell script, you can do almost everything on Windows, for instance, start\/stop a service: Start-Service -Name FortiSslvpnDaemon Stop-Service -Name FortiSslvpnDaemon Create a desktop shortcut for that script You can change the look of shortcut on clicking!! That makes a switch with visual state"},{"title":"I wrote this blog post in markdown without writing markdown","link":{"@attributes":{"href":"https:\/\/etern.github.io\/2022\/02\/11\/i-wrote-this-blog-post-in-markdown-without-writing-markdown.html","rel":"alternate","type":"text\/html","title":"I wrote this blog post in markdown without writing markdown"}},"published":"2022-02-11T15:08:00+00:00","updated":"2022-02-11T15:08:00+00:00","id":"https:\/\/etern.github.io\/2022\/02\/11\/i-wrote-this-blog-post-in-markdown-without-writing-markdown","content":"<p>Actually, I wrote Org.<\/p>\n\n<p>Github pages is awesome, with the default supported <code class=\"language-plaintext highlighter-rouge\">jekyll<\/code>, you can\u2019t\nwrite in org-mode, some people resort to alternative site generators,\nlike <code class=\"language-plaintext highlighter-rouge\">hugo<\/code>, for a workaround, and here is another way:\n<a href=\"https:\/\/github.com\/etern\/edit-as-format\">edit-as-format<\/a>.<\/p>\n\n<h1 id=\"how-to-use-the-package\">How to use the package<\/h1>\n\n<p>With this package, you can edit one format as another format, in\n<strong>emacs<\/strong>, as long as both format supported by pandoc, like <code class=\"language-plaintext highlighter-rouge\">org<\/code> &lt;-&gt;\n<code class=\"language-plaintext highlighter-rouge\">markdown<\/code>.<\/p>\n\n<p>Here\u2019s the steps:<\/p>\n\n<ol>\n  <li>\n    <p>Create this blog post as markdown, open it in emacs. (the parent\nbuffer)<\/p>\n  <\/li>\n  <li>\n    <p><code class=\"language-plaintext highlighter-rouge\">M-x<\/code> <code class=\"language-plaintext highlighter-rouge\">edit-as-format-org<\/code> will open an org-mode buffer. (the\nindirect buffer)<\/p>\n  <\/li>\n  <li>\n    <p>Write in this buffer with Org syntax, <code class=\"language-plaintext highlighter-rouge\">C-x C-s<\/code> to commit back to\nparent buffer.<\/p>\n  <\/li>\n<\/ol>\n\n<p>It works vice versa, in case you want to edit Org files as markdown,\n<code class=\"language-plaintext highlighter-rouge\">M-x<\/code> <code class=\"language-plaintext highlighter-rouge\">edit-as-format<\/code> choose <code class=\"language-plaintext highlighter-rouge\">markdown<\/code> from the prompt. Or, define\nyour own convenient commands:<\/p>\n\n<div class=\"language-elisp highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">(<\/span><span class=\"nb\">defun<\/span> <span class=\"nv\">edit-org-as-markdown<\/span> <span class=\"p\">()<\/span>\n  <span class=\"p\">(<\/span><span class=\"nv\">interactive<\/span><span class=\"p\">)<\/span>\n  <span class=\"p\">(<\/span><span class=\"nv\">edit-as-format<\/span> <span class=\"s\">\"org\"<\/span> <span class=\"s\">\"markdown\"<\/span><span class=\"p\">))<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h1 id=\"why-should-you-use-it\">Why should you use it<\/h1>\n\n<p>What really matters about blogging format, the <strong>syntax<\/strong> or <strong>storage\nformat<\/strong>? Here is my view:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Factor<\/th>\n      <th>Really Matters?<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td>Syntax<\/td>\n      <td>Yes<\/td>\n    <\/tr>\n    <tr>\n      <td>Writing Experience<\/td>\n      <td>Yes<\/td>\n    <\/tr>\n    <tr>\n      <td>Storage file<\/td>\n      <td>No<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<ul>\n  <li>I like Org over markdown, because of the syntax, I like to write\nslash(\/) for <em>italic<\/em>, which is more intuitive than star(*)<\/li>\n  <li>I like Org inside <strong>Emacs<\/strong>, it feels soooo good editing Org tables\nwith <code class=\"language-plaintext highlighter-rouge\">TAB<\/code> key<\/li>\n  <li>How is the file stored, <code class=\"language-plaintext highlighter-rouge\">*.md<\/code> file or <code class=\"language-plaintext highlighter-rouge\">*.org<\/code> file? pure text? or\neven binary? Not important, only if it can be edited in emacs with\nOrg syntax<\/li>\n<\/ul>\n\n<p>If you agree with me, the <code class=\"language-plaintext highlighter-rouge\">hugo<\/code> solution seems less attractive, you\nshould try <code class=\"language-plaintext highlighter-rouge\">edit-as-format<\/code> ;)<\/p>\n\n<p>Org mode is such big thing, pandoc might not support all of it\u2019s\nfeatures, I just show you the most basic ones: emphasis, links,\nordered\/unordered list, code blocks and tables, that\u2019s great amount for\nblog posting.<\/p>\n\n<p><em>Caution: <code class=\"language-plaintext highlighter-rouge\">edit-as-format-org<\/code> will process the whole buffer if there\u2019s\nno marked region, for posts with\n<a href=\"https:\/\/jekyllrb.com\/docs\/front-matter\/\">front-matter<\/a>, mark region to\nexclude it first.<\/em><\/p>","author":{"name":{}},"summary":"Actually, I wrote Org. Github pages is awesome, with the default supported jekyll, you can\u2019t write in org-mode, some people resort to alternative site generators, like hugo, for a workaround, and here is another way: edit-as-format. How to use the package With this package, you can edit one format as another format, in emacs, as long as both format supported by pandoc, like org &lt;-&gt; markdown. Here\u2019s the steps: Create this blog post as markdown, open it in emacs. (the parent buffer) M-x edit-as-format-org will open an org-mode buffer. (the indirect buffer) Write in this buffer with Org syntax, C-x C-s to commit back to parent buffer. It works vice versa, in case you want to edit Org files as markdown, M-x edit-as-format choose markdown from the prompt. Or, define your own convenient commands: (defun edit-org-as-markdown () (interactive) (edit-as-format \"org\" \"markdown\")) Why should you use it What really matters about blogging format, the syntax or storage format? Here is my view: Factor Really Matters? Syntax Yes Writing Experience Yes Storage file No I like Org over markdown, because of the syntax, I like to write slash(\/) for italic, which is more intuitive than star(*) I like Org inside Emacs, it feels soooo good editing Org tables with TAB key How is the file stored, *.md file or *.org file? pure text? or even binary? Not important, only if it can be edited in emacs with Org syntax If you agree with me, the hugo solution seems less attractive, you should try edit-as-format ;) Org mode is such big thing, pandoc might not support all of it\u2019s features, I just show you the most basic ones: emphasis, links, ordered\/unordered list, code blocks and tables, that\u2019s great amount for blog posting. Caution: edit-as-format-org will process the whole buffer if there\u2019s no marked region, for posts with front-matter, mark region to exclude it first."},{"title":"Setup github pages","link":{"@attributes":{"href":"https:\/\/etern.github.io\/2022\/02\/07\/setup-github-pages.html","rel":"alternate","type":"text\/html","title":"Setup github pages"}},"published":"2022-02-07T13:12:55+00:00","updated":"2022-02-07T13:12:55+00:00","id":"https:\/\/etern.github.io\/2022\/02\/07\/setup-github-pages","content":"<h1 id=\"install-jekyll\">Install jekyll<\/h1>\n<ol>\n  <li><code class=\"language-plaintext highlighter-rouge\">apt install ruby ruby-dev<\/code><\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">gem install jekyll bundler<\/code><\/li>\n<\/ol>\n\n<h1 id=\"create-site\">Create site<\/h1>\n<ol>\n  <li><code class=\"language-plaintext highlighter-rouge\">mkdir mysite<\/code><\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">jekyll new --skip-bundle .<\/code><\/li>\n  <li>edit Gemfile, comment out <code class=\"language-plaintext highlighter-rouge\">gem \"jekyll\"<\/code>, uncomment <code class=\"language-plaintext highlighter-rouge\">gem \"github-pages\"<\/code><\/li>\n<\/ol>\n\n<h1 id=\"configure-site\">Configure site<\/h1>\n\n<p><code class=\"language-plaintext highlighter-rouge\">_config.yml<\/code><\/p>\n\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"na\">defaults<\/span><span class=\"pi\">:<\/span>\n  <span class=\"pi\">-<\/span> <span class=\"na\">scope<\/span><span class=\"pi\">:<\/span>\n      <span class=\"na\">path<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">\"<\/span> <span class=\"c1\"># an empty string here means all files in the project<\/span>\n      <span class=\"na\">type<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">posts\"<\/span> <span class=\"c1\"># previously `post` in Jekyll 2.2.<\/span>\n    <span class=\"na\">values<\/span><span class=\"pi\">:<\/span>\n      <span class=\"na\">layout<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">post\"<\/span> <span class=\"c1\"># use `post` layout for all posts<\/span>\n      <span class=\"na\">comments<\/span><span class=\"pi\">:<\/span> <span class=\"no\">true<\/span> <span class=\"c1\"># show disqus comment for all posts<\/span>\n<span class=\"na\">disqus<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">shortname<\/span><span class=\"pi\">:<\/span> <span class=\"s\">xxxx<\/span> <span class=\"c1\"># where is it used: minima-theme post template<\/span>\n<span class=\"na\">url<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">https:\/\/xxx\"<\/span> <span class=\"c1\"># disqus `this.page.url` prefix<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<h1 id=\"update-dependency\">Update dependency<\/h1>\n<ol>\n  <li><code class=\"language-plaintext highlighter-rouge\">rm Gemfile.lock<\/code><\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">bundle update<\/code><\/li>\n<\/ol>\n\n<h1 id=\"run-locally\">Run locally<\/h1>\n<p><code class=\"language-plaintext highlighter-rouge\">bundle exec jekyll serve -P 8080<\/code><\/p>\n\n<h1 id=\"create-post\">Create post<\/h1>\n<ol>\n  <li><code class=\"language-plaintext highlighter-rouge\">cd _post<\/code><\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">emacs `date -I`-post-name.md<\/code><\/li>\n  <li>\n    <p><code class=\"language-plaintext highlighter-rouge\">M-x<\/code> <code class=\"language-plaintext highlighter-rouge\">auto-insert<\/code><\/p>\n\n    <p>where front matter template is defined as:<\/p>\n    <div class=\"language-lisp highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">(<\/span><span class=\"nv\">define-auto-insert<\/span> <span class=\"p\">(<\/span><span class=\"nv\">rx<\/span> <span class=\"p\">(<\/span><span class=\"nv\">seq<\/span> <span class=\"p\">(<\/span><span class=\"nb\">=<\/span> <span class=\"mi\">4<\/span> <span class=\"nv\">digit<\/span><span class=\"p\">)<\/span> <span class=\"nv\">?-<\/span> <span class=\"p\">(<\/span><span class=\"nb\">=<\/span> <span class=\"mi\">2<\/span> <span class=\"nv\">digit<\/span><span class=\"p\">)<\/span> <span class=\"nv\">?-<\/span> <span class=\"p\">(<\/span><span class=\"nb\">=<\/span> <span class=\"mi\">2<\/span> <span class=\"nv\">digit<\/span><span class=\"p\">)<\/span> <span class=\"p\">(<\/span><span class=\"nv\">one-or-more<\/span> <span class=\"nv\">any<\/span><span class=\"p\">)<\/span> <span class=\"s\">\".md\"<\/span><span class=\"p\">))<\/span>\n  <span class=\"p\">(<\/span><span class=\"k\">lambda<\/span> <span class=\"p\">()<\/span>\n    <span class=\"p\">(<\/span><span class=\"nv\">insert<\/span> <span class=\"s\">\"---\\ntitle: \"<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">(<\/span><span class=\"nv\">insert<\/span> <span class=\"p\">(<\/span><span class=\"nv\">substring<\/span> <span class=\"p\">(<\/span><span class=\"nv\">file-name-base<\/span> <span class=\"p\">(<\/span><span class=\"nv\">buffer-name<\/span><span class=\"p\">))<\/span> <span class=\"mi\">11<\/span><span class=\"p\">))<\/span>\n    <span class=\"p\">(<\/span><span class=\"nv\">insert<\/span> <span class=\"s\">\"\\ndate: \"<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">(<\/span><span class=\"nv\">insert<\/span> <span class=\"p\">(<\/span><span class=\"nv\">format-time-string<\/span> <span class=\"s\">\"%Y-%m-%d %H:%M:%S %z\\n---\"<\/span><span class=\"p\">))))<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n<\/ol>\n\n<h1 id=\"reference\">Reference<\/h1>\n<ul>\n  <li><a href=\"https:\/\/docs.github.com\/en\/pages\/setting-up-a-github-pages-site-with-jekyll\/about-github-pages-and-jekyll\">Set up site with jekyll<\/a><\/li>\n<\/ul>","author":{"name":{}},"summary":"Install jekyll apt install ruby ruby-dev gem install jekyll bundler"},{"title":"\u6b22\u8fce\u8bbf\u95ee\u6211\u7684\u535a\u5ba2!","link":{"@attributes":{"href":"https:\/\/etern.github.io\/technology\/2017\/08\/24\/welcome-to-jekyll.html","rel":"alternate","type":"text\/html","title":"\u6b22\u8fce\u8bbf\u95ee\u6211\u7684\u535a\u5ba2!"}},"published":"2017-08-24T01:13:53+00:00","updated":"2017-08-24T01:13:53+00:00","id":"https:\/\/etern.github.io\/technology\/2017\/08\/24\/welcome-to-jekyll","content":"<p>jekyll\u751f\u6210\u7684\u9759\u6001\u7f51\u7ad9\uff0c\u5728_post\u91ccmarkdown\uff0c\u4e0a\u4f20\u4e4b\u540e\uff0cgithub\u670d\u52a1\u7aef\u4f1a\u8fd0\u884cjekyll\uff0c\u751f\u6210\u9759\u6001\u7f51\u9875<\/p>\n\n<p>_post\u91ccmarkdown\u547d\u540d\u5f62\u5f0f\u4e3a <code class=\"language-plaintext highlighter-rouge\">YYYY-MM-DD-name-of-post.ext<\/code> \uff0cmarkdown\u6587\u4ef6\u91cc\u9700\u8981\u6dfb\u52a0jekyll\u7684 <code class=\"language-plaintext highlighter-rouge\">front matter<\/code>\u3002\u53ef\u4ee5\u770b\u770b\u8fd9\u6761\u65e5\u5fd7\u7684\u6e90\u7801\u4e86\u89e3 <code class=\"language-plaintext highlighter-rouge\">front matter<\/code>\u3002<\/p>\n\n<p>Jekyll\u4e5f\u63d0\u4f9b\u4ee3\u7801\u6bb5\u9ad8\u4eae\u5c55\u793a\uff0c\u6bd4\u5982:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-ruby\" data-lang=\"ruby\"><span class=\"k\">def<\/span> <span class=\"nf\">print_hi<\/span><span class=\"p\">(<\/span><span class=\"nb\">name<\/span><span class=\"p\">)<\/span>\n  <span class=\"nb\">puts<\/span> <span class=\"s2\">\"Hi, <\/span><span class=\"si\">#{<\/span><span class=\"nb\">name<\/span><span class=\"si\">}<\/span><span class=\"s2\">\"<\/span>\n<span class=\"k\">end<\/span>\n<span class=\"n\">print_hi<\/span><span class=\"p\">(<\/span><span class=\"s1\">'Tom'<\/span><span class=\"p\">)<\/span>\n<span class=\"c1\">#=&gt; prints 'Hi, Tom' to STDOUT.<\/span><\/code><\/pre><\/figure>\n\n<p>\u6b22\u8fce\u8bbf\u95ee<a href=\"https:\/\/github.com\/etern\">\u6211\u7684github\u4e3b\u9875<\/a><\/p>","author":{"name":{}},"category":{"@attributes":{"term":"technology"}},"summary":"jekyll\u751f\u6210\u7684\u9759\u6001\u7f51\u7ad9\uff0c\u5728_post\u91ccmarkdown\uff0c\u4e0a\u4f20\u4e4b\u540e\uff0cgithub\u670d\u52a1\u7aef\u4f1a\u8fd0\u884cjekyll\uff0c\u751f\u6210\u9759\u6001\u7f51\u9875"}]}