Exuanbo’s Wiki

This page is built using Emacs Org mode with Gulp.js, inspired by GeekPlux. Source code is hosted in this repo.

1 Life

1.1 Style

1.1.1 Minimalism

1.1.2 Self-control

1.2 Skill

1.2.1 Typing

  1. 双拼
    • 选择输入法的哲学:兼论双拼的优缺点 - 少数派
      • 录入文字的过程可以简单分为两个环节:1. 大脑将思考的内容转化为可以通过键盘录 入的内容(比如字形、字音);2. 通过键盘将字形或字音录入电脑并组合为最终文字。
      • 我们的大脑更容易把思维转化为声音而不是文字 ,甚至有很多人必须先把思维转化 为声音然后才能进一步转化为文字:我们见过很多人在输入的时候嘴里念念有词,这就 是通过声音来辅助文字呈现的一种方式,但我们从来没见过有人说话的时候,需要拿支 笔边写边说。
      • 双拼输入法是拼音输入法的一种,因此它继承了拼音输入法在第一环节的优势;而由于 简化了复合声母和韵母,在第二环节的效率追平甚至超过了五笔输入法。
    1. Practice
      • 强制替换电脑和手机上的输入法
      • 打印键位并贴到墙上
      • 使用讯飞输入法键位皮肤
      • 微信聊天背景设为键位图
    2. Resource
  2. RIME
    • alswl/ Rime - Rime configuration for Squirrel (macOS) & fcitx-rime
    1. Squirrel

1.2.2 Bypass GFW

  1. Server
  2. Client
    1. App
    2. Subscription
    3. Rules
  3. Other
    • GoogleHosts
    • geph-official/ geph2 - Geph (迷霧通) is a modular Internet censorship circumvention system designed specifically to deal with national filtering
  4. Tutorial

1.3 Tool

1.4 Hobby

1.4.1 Marathon

  1. Gear

1.4.2 Podcast

  • 播客届的京派与海派 - 少数派

    时隔近百年,当下的中文播客圈,听众之中流行着一个说法,将中文播客分类为「陪伴型 / 湿货」和「硬核型 / 干货」两种类型。苹果发布的 2019 年最佳中文播客榜单中,不 乏「大内密谈」「日谈公园」「跟宇宙结婚」这样的「闲话类」陪伴型播客,也丰盈着 「忽左忽右」「博物志」「声东击西」「不可理论」等信息度相对密集、知识点充沛的播 客节目。前者往往以北京为核心,主要是北方语系;后者则以上海为中心,且基本有海外 背景。

  1. App

    泛用型播客客户端:

  2. Explore

    Jesse Chan (@Jesoooor) 言:

    独立 = 创作过程不受限制、影响。

    这个限制和影响可能来自资本、技术、商业、受众。但你不可能找到一个一刀切的标准来定义「独立」。

    小众厂牌 Spotify 独占,能叫独立音乐吗?微软独占的《Cuphead》叫独立游戏吗?

    这是要从内容本身出发去判断的,真正「独立」的内容会散发出独一无二的气质。

  3. Subscription
    • Luke’s English Podcast
    • Casticle

      这是一档探索并发现优质单期英文播客的中文节目。每期节目将为你推荐三期不同主题或 类型的英文播客,讲述这些播客的精彩之处,整理与其相关的信息与知识。我们希望能帮 助你更高效地接触英文原生内容,并享受随之而来的快乐与启发。

    • 得意忘形

      这是一个主张追求个体自由与探寻真理的实验计划。我们见证了第一次工业革命以来科技 对人类社会的极大推动与助益,但也意识到资本主义与市场经济不可避免地催生了消费文 化、剥夺了个人价值、并窃取了大众时间。带着对生命的有限性与无目的性的敬畏,我们 试图为读者与听众提供更全面的觉察自我与认知世界的工具,以不断重建当下的方式穿越 时间、抵达生活的本质。

    • Byte.Coffee

      一家以 Engineer 视角面对世界的字节咖啡店,提供一支独立极简、健康明亮、科学主调、 人文余韵的声波咖啡豆。人间指南主播 hb 曾打趣说是「科技与人文十字路口的街角咖啡 店」,我觉得需要改成「科学与人文的十字路口」,特指自然科学。技术固然重要,但背 后的科学是基础是理论是根基,一名科研工作者必须谨记这一点。

    • 迟早更新

      这是一档探讨科技、商业、设计和生活之间混沌关系的播客节目,也是风险基金 ONES Ventures 关于热情、趣味和好奇心的音频记录。我们希望通过这档播客,能让熟悉的事 物变得新鲜,让新鲜的事物变得熟悉。

    • 机核网 GADIO 游戏广播
    • 反波 Antiwave - web.archive.org
  4. Episode
    • 数学与编程 | 内核恐慌 #12

      特别嘉宾木遥与 Rio 和吴涛讨论了数学与编程之间的联系。话题包括但不限于:数学系 的发展、统计学、数学与科学的关联、明尼苏达的天气、数学背景对于成为程序员的助益、 Google 的工程师驱动特性、人们嘲讽新泽西的原因、养猫的经验、抽象几何学、Haskell、 编程动手能力的来源、学习编程语言的意义、可视化编程、Lisp、FORTRAN、Go、C++、 Swift、Optional、Google 的激励机制、欧洲的社会保障体制、技术变革带来的社会影响、 中国政治坐标系测试、和食物替代饮料 Soylent。

2 Job

2.1 Prepare

2.2 Resource

3 General Learning

4 Language

4.1 English

4.1.4 Reading

4.1.5 Speaking

  • “White Girl Problems” - novel
  • “New Girl” - TV Series
  • “Girls” - TV Series
  • “Jessie” - TV Series
  • “Dream School” - Netflix TV Series

5 Reading

6 Writing

7 Design

8 Blog

9 Free & Open

9.4 Github

9.4.1 Github Pages

9.4.2 Github Actions

  • GitHub Actions 入门教程 - P3TERX ZONE
  • GitHub Actions 手动触发方式 - P3TERX ZONE
    • Star

      name: Test
      
      on:
        watch:
          types: started
      
      jobs:
        build:
          runs-on: ubuntu-latest
          if: github.event.repository.owner.id == github.event.sender.id
      
          steps:
             - name: Checkout
               uses: actions/checkout@v2
      # ...
      
    • Webhook

      name: Webhook Test
      
      on:
        repository_dispatch:
          types: [helloworld, test, none]
      
      jobs:
        build:
          runs-on: ubuntu-latest
      
          steps:
          - name: Hello World
            if: contains(github.event.action, 'hello')
            run: |
              echo My name is P3TERX.
              echo Hello World!
      
          - name: TEST
            if: github.event.action == 'test'
            run: |
              echo test
      
      curl -X POST https://api.github.com/repos/:owner/:repo/dispatches \
          -H "Accept: application/vnd.github.everest-preview+json" \
          -H "Authorization: token ACTIONS_TRIGGER_TOKEN" \
          --data '{"event_type": "TRIGGER_KEYWORDS"}'
      
  • Caching dependencies to speed up workflows - GitHub Help

    name: Caching with npm
    
    on: push
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
        - uses: actions/checkout@v2
    
        - name: Cache node modules
          uses: actions/cache@v1
          env:
            cache-name: cache-node-modules
          with:
            path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
            key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
            restore-keys: |
              ${{ runner.os }}-build-${{ env.cache-name }}-
              ${{ runner.os }}-build-
              ${{ runner.os }}-
    
        - name: Install Dependencies
          run: npm install
    
        - name: Build
          run: npm build
    
        - name: Test
          run: npm test
    
  • matchai/ awesome-pinned-gists - A collection of awesome dynamic pinned gists for GitHub

10 Computer Science

11 Programming

11.1 Functional Programming

11.1.1 Haskell

  1. Environment Setup
    • Haskell Platform - Installs GHC, Cabal, and some other tools, along with a starter set of libraries in a global location on your system.

      curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
      curl -sSL https://get.haskellstack.org/ | sh
      
    • Using Homebrew

      brew install cabal-install ghc
      brew haskell-stack
      stack setup
      

11.2 C++

11.3 Java

11.4 Python

11.4.1 Tips

12 Algorithm

  • The Algorithms · GitHub - Open Source resource for learning Data Structures & Algorithms and their implementation in any Programming Language

13 Web

  • Code Guide by @mdo - Standards for developing consistent, flexible, and sustainable HTML and CSS
  • gothinkster/ realworld - Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more

13.1 Javascript

  • trekhleb/ javascript-algorithms - Algorithms and data structures implemented in JavaScript with explanations and links to further readings
  • jQuery.getScript alternative in native JavaScript - Stack Overflow

    const loadScript = (source, options) => {
      return new Promise((resolve, reject) => {
        let script = document.createElement('script')
        const prior = document.getElementsByTagName('script')[0]
    
        function onloadHander(_, isAbort) {
          if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
            script.onload = null
            script.onreadystatechange = null
            script = undefined
    
            isAbort ? reject(new Error('Failed to load script')) : resolve()
          }
        }
    
        const attributes = {
          async: false,
          defer: true
        }
    
        if (options) {
          for (const i in options) {
            attributes[i] = options[i]
          }
        }
    
        for (const i in attributes) {
          script[i] = attributes[i]
        }
    
        script.onload = onloadHander
        script.onreadystatechange = onloadHander
        script.src = source
        prior.parentNode.insertBefore(script, prior)
      })
    }
    
  • IntersectionObserver - Web APIs | MDN
  • verlok/ lazyload - written in plain “vanilla” JavaScript
  • JSMonk/ hegel - An advanced static type checker
  • alpinejs/ alpine - A rugged, minimal framework for composing JavaScript behavior in your markup. Think of it like Tailwind for JavaScript

13.2 Typescript

13.3 Node.js

13.4 NPM

13.5 Gulp.js

gulp.js - The streaming build system

function defaultTask(cb) {
  // place code for your default task here
  cb();
}

exports.default = defaultTask

13.5.1 Example

  • same src and dest

    function html() {
      return src('public/**/*.html', { base: '.' })
        .pipe(htmlmin({ collapseWhitespace: true }))
        .pipe(dest('.'))
    }
    
  • gulp.watch() + browser-sync

    const browserSync = require('browser-sync').create()
    
    function server() {
      browserSync.init({
        server: {
          baseDir: './public',
        },
      })
      watch(
        [
          'assets/**',
          '!assets/build/**',
          'content/**',
          'layouts/**',
          'static/**',
          'config.toml',
        ],
        { ignoreInitial: false },
        series('default')
      )
      watch('public/**').on('change', browserSync.reload)
    }
    
    exports.server = server
    

13.5.2 Plugins

  • gulp-rename
  • @exuanbo/gulp-inject-inline
  1. Javascript
    • gulp-concat
    • gulp-uglify-es
  2. CSS
    • gulp-concat-css
    • gulp-postcss
  3. HTML
    • gulp-htmlmin

13.6 PostCSS

13.6.1 Plugins

  • postcss/ postcss-import - PostCSS plugin to inline @import rules content
  • @fullhuman/postcss-purgecss
  • autoprefixer
  • cssnano - A modular minifier based on the PostCSS ecosystem

    const plugins = [
      cssnano({
        preset: ['default', { discardComments: { removeAll: true } }]
      })
    ]
    

13.9 Static Site Generator

13.9.1 Hugo

13.9.2 Eleventy

11ty/ eleventy

A simpler static site generator. An alternative to Jekyll. Written in JavaScript. Transforms a directory of templates (of varying types) into HTML.

Works with HTML, Markdown, Liquid, Nunjucks, Handlebars, Mustache, EJS, Haml, Pug, and JavaScript Template Literals.

13.9.3 Saber

saberland /saber

()==[:::::::::::::> Build static sites in Vue.js, without the hassle

13.11 Resource

13.11.1 Icons

14 iOS

15 Game

16 Git

  • Learn Git Branching - the most visual and interactive way to learn Git on the web
  • commitizen/ cz-cli - Simple commit conventions for internet citizens
  • git reset

    
                   (default)
          --soft    --mixed   --hard
    ----------------------------------------- commit (repository)
             |         |         |
             V         |         |
    ----------------------------------------- stage (index)
                       |         |
                       V         |
    ----------------------------------------- unstage (working tree)
                                 |
                                 V
                              discard
    
    

16.1 Hacks

16.1.1 Hook

  • auto sync to Dropbox after commit
    1. vim ~/.gitconfig

      [core]
        hooksPath = /Users/xuanbo/Dropbox/git/hooks # your hook file folder
      
    2. vim ~/Dropbox/git/hooks/post-commit

      #!/usr/bin/env bash
      
      set -e # always immediately exit upon error
      
      # directory config. ending slashes are important!
      src_dir="$HOME/repositories/"
      dest_dir="$HOME/Dropbox/repositories/"
      
      # run the sync
      rsync -arv --delete-after --delete-excluded --progress \
        --filter="dir-merge,- .gitignore" \
        --exclude-from="$HOME/.gitignore_global" \ # if exists
        --chmod="F-w" \
        "$src_dir" "$dest_dir"
      

16.2 Pull-Request steps

The beginner’s guide to contributing to a GitHub project

  1. Fork the project and clone locally
  2. git remote add upstream [email protected]:xxx/xxx.git
  3. git checkout -b newBranch
  4. Do something and commit
  5. git pull --rebase upstream master
  6. git push origin

16.3 Command

git init  # 在当前目录新建一个 Git 代码库
git clone [url]  # 下载一个项目和它的整个代码历史
git config --list # 显示当前的 Git 配置
git config -e [--global]  # 编辑 Git 配置文件
git add  # 添加指定文件到暂存区
git rm   # 删除工作区文件,并且将这次删除放入暂存区
git commit -m [message]  # 提交暂存区到仓库区
git commit -a # 提交工作区自上次 commit 之后的变化,直接到仓库区
git commit --amend -m [message]   # 使用一次新的 commit,替代上一次提交 如果代码没有任何新变化,则用来改写上一次 commit 的提交信息
git commit --amend [file1] [file2] ...  # 重做上一次 commit,并包括指定文件的新变化

# 分支相关
git branch  # 列出所有本地分支
git branch -r  # 列出所有远程分支
git branch [branch-name]  # 新建一个分支,但依然停留在当前分支
git checkout [branch-name]  # 切换到指定分支,并更新工作区
git checkout -b [branch]  # 新建一个分支,并切换到该分支
git branch [branch] [commit]  # 新建一个分支,指向指定 commit
git checkout -b [branch] [tag]  # 新建一个分支,指向某个 tag
git branch --track [branch] [remote-branch]  # 新建一个分支,与指定的远程分支建立追踪关系
git branch --set-upstream [branch] [remote-branch]  # 建立追踪关系,在现有分支与指定的远程分支之间
git merge [branch]  # 合并指定分支到当前分支
git cherry-pick [commit]  # 选择一个 commit,合并进当前分支
git branch -d [branch-name]  # 删除分支
git push origin --delete [branch-name] # 删除远程分支
git branch -dr [remote/branch]  # 删除远程分支

# 标签
git tag  # 列出所有 tag
git tag [tag] # 新建一个 tag 在当前 commit
git tag [tag] [commit] # 新建一个 tag 在指定 commit
git show [tag]  # 查看 tag 信息
git push [remote] [tag]  # 提交指定 tag
git push [remote] --tags   # 提交所有 tag

# 查看
git status # 显示有变更的文件
git log # 显示当前分支的版本历史
git log --stat # 显示 commit 历史,以及每次 commit 发生变更的文件
git log --follow [file] # 显示某个文件的版本历史,包括文件改名
git log -p [file] # 显示指定文件相关的每一次 diff
git blame [file] # 显示指定文件是什么人在什么时间修改过
git diff # 显示暂存区和工作区的差异
git diff --cached [file] # 显示暂存区和上一个 commit 的差异
git diff HEAD # 显示工作区与当前分支最新 commit 之间的差异
git diff [first-branch]...[second-branch] # 显示两次提交之间的差异
git show [commit] # 显示某次提交的元数据和内容变化
git show --name-only [commit] # 显示某次提交发生变化的文件
git show [commit]:[filename] # 显示某次提交时,某个文件的内容
git reflog # 显示当前分支的最近几次提交

# 远程
git fetch [remote] # 下载远程仓库的所有变动
git remote -v  # 显示所有远程仓库
git remote show [remote]  # 显示某个远程仓库的信息
git remote add [shortname] [url]  # 增加一个新的远程仓库,并命名
git pull [remote] [branch]  # 取回远程仓库的变化,并与本地分支合并
git push [remote] [branch] # 上传本地指定分支到远程仓库
git push [remote] --force # 强行推送当前分支到远程仓库,即使有冲突
git push [remote] --all # 推送所有分支到远程仓库

# 撤销
git checkout [file] # 恢复暂存区的指定文件到工作区
git checkout [commit] [file] # 恢复某个 commit 的指定文件到工作区
git checkout . # 恢复上一个 commit 的所有文件到工作区
git reset [file] # 重置暂存区的指定文件,与上一次 commit 保持一致,但工作区不变
git reset --hard # 重置暂存区与工作区,与上一次 commit 保持一致
git reset [commit] # 重置当前分支的指针为指定 commit,同时重置暂存区,但工作区不变
git reset --hard [commit] # 重置当前分支的 HEAD 为指定 commit,同时重置暂存区和工作区,与指定 commit 一致
git reset --keep [commit] # 重置当前 HEAD 为指定 commit,但保持暂存区和工作区不变
git revert [commit] # 新建一个 commit,用来撤销指定 commit,后者的所有变化都将被前者抵消,并且应用到当前分支

17 Text Editor

17.1 Emacs


       +================================+
       |                                |
    +===============================+   |
    |                               |   |
+===============================+   |   |
|              |                |   |   | ..... Frame 3
|   Window 2   |                |   |   |
|              |                |   |---+
|--------------|    Window 1    |   | ......... Frame 2
|              |                |---+
|   Window 3   |                |
|              |                | ............. Frame 1
+-------------------------------+

17.1.2 Tips

  • eval-after-load vs. mode hook - Stack Overflow

    Code wrapped in eval-after-load will be executed only once, so it is typically used to perform one-time setup such as setting default global values and behaviour. An example might be setting up a default keymap for a particular mode. In eval-after-load code, there’s no notion of the “current buffer”.

    Mode hooks execute once for every buffer in which the mode is enabled, so they’re used for per-buffer configuration. Mode hooks are therefore run later than eval-after-load code; this lets them take actions based upon such information as whether other modes are enabled in the current buffer.

  • The difference between setq and setq-default in Emacs Lisp

    Some variables in Emacs are “buffer-local”, meaning that each buffer is allowed to have a separate value for that variable that overrides the global default. tab-width is a good example of a buffer-local variable.

    If a variable is buffer-local, then setq sets its local value in the current buffer and setq-default sets the global default value.

    If a variable is not buffer-local, then setq and setq-default do the same thing.

17.1.4 Packages

17.2 Spacemacs

17.2.1 Configuration

A dotdirectory /.spacemacs.d can be used instead of a dotfile. If you want to use this option, move /.spacemacs to /.spacemacs.d/init.el.

My configuration exuanbo/ dotfiles/.spacemacs.d

for reference:

17.2.2 Layers

17.2.3 Tips

17.3 Doom Emacs

hlissner/ doom-emacs - An Emacs configuration for the stubborn martian vimmer

My configuration .doom.d

17.3.2 Modules

  • term/vterm - +vterm/toggle (SPC o t): Toggle vterm pop up window in the current project

17.3.3 Hacks

  • Need doom/toggle-maximized command #397

    (add-to-list 'initial-frame-alist '(fullscreen . maximized))
    
  • modules/lang/org

    TAB was changed to toggle only the visibility state of the current subtree, rather than cycle through it recursively. This can be reversed with:

    (after! evil-org
      (remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h))
    
  • Doom crashes when…

    On some systems (particularly MacOS), manipulating the fringes or window margins can cause Emacs to crash. This is most prominent in the Doom Dashboard (which tries to center its contents), in org-mode buffers (which uses org-indent-mode to create virtual indentation), or magit. There is currently no known fix for this, as it can’t be reliably reproduced. Your best bet is to reinstall/rebuild Emacs or disable the errant plugins/modules. e.g.

    To disable org-indent-mode:

    (after! org
      (setq org-startup-indented nil))
    

    Or disable the :ui doom-dashboard & :tools magit modules (see #1170).

17.4 Other configuration

17.5 Vim

17.6 Visual Studio Code

18 Org Mode

18.1 Configuration

18.1.1 General

(setq org-export-with-sub-superscripts nil
      org-html-doctype "html5"
      org-html-html5-fancy t ; enable new block elements introduced with the HTML5 standard
      org-html-head-include-default-style nil
      org-html-htmlize-output-type 'css)

18.1.2 for Spacemacs

dotspacemacs-configuration-layers
'((org :variables
       org-projectile-file "TODOs.org"
       org-want-todo-bindings t))
(defun dotspacemacs/user-config ()
  (with-eval-after-load 'org
    (setq ... )))

18.1.3 gongzhitaao/ orgcss

When exported to HTML, there are three options for code highlighting, controlled by the variable org-html-htmlize-output-type.

  1. (setq org-html-htmlize-output-type 'inline-css)

    This is the default setting. It highlights the code according to the current Emacs theme you are using. It directly applies color to the code with inline styles, e.g., <span style="color: 0x000000">int</span>.

    The problem is that the highlight theme depends on the Emacs theme. If you use a dark theme in your Emacs but a light theme (usually we like light themed web pages) web pages, the exported code are hardly illegible due to the light font color, or vice versa.

  2. (setq org-html-htmlize-output-type nil)

    This configuration disables highlighting by htmlize. You may use a third-party Javascript highlight library. I recommend highlight.js if I need code highlight.

    There are two problems:

    1. The problem is that you have to rely on highlight.js support on a certain language which is occasionally missing, e.g., emacs-lisp, org, etc.
    2. highlight.js by default does not recognized the tags and classes exported by org mode. You need some extra Javascript code in your Org file.
  3. (setq org-html-htmlize-output-type 'css)

    This is similar to the first optional, instead of using inline styles, this will assign classes to each component of the code, e.g., <span class="org-type">int</span>, and you could create your own stylesheet for .org-type.

    To obtain a list of all supported org classes, run M-x org-html-htmlize-generate-css. This will create a buffer containing all the available org style class names in the current Emacs session.

18.2 Hacks

  • org mode - Set the background of org-exported <code> blocks according to them…

    (defun my/org-inline-css-hook (exporter)
      "Insert custom inline css to automatically set the
    background of code to whatever theme I'm using's background"
      (when (eq exporter 'html)
        (let* ((my-pre-bg (face-background 'default))
               (my-pre-fg (face-foreground 'default)))
          (setq
           org-html-head-extra
           (concat
            org-html-head-extra
            (format "<style type=\"text/css\">\n pre.src {background-color: %s; color: %s;}</style>\n"
                    my-pre-bg my-pre-fg))))))
    
    (add-hook 'org-export-before-processing-hook 'my/org-inline-css-hook)
    

    the same way to insert inline CSS or Javascript from local files:

    (defun my/org-inline-source-hook (exporter)
      (when (eq exporter 'html)
        (setq org-html-head-extra (concat
                                  "<style type=\"text/css\">\n"
                                  "<!--/*--><![CDATA[/*><!--*/\n"
                                  (with-temp-buffer
                                    (insert-file-contents "style.css")
                                    (buffer-string))
                                  "\n"
                                  "/*]]>*/-->\n"
                                  "</style>\n"
                                  "<script type=\"text/javascript\">\n"
                                  "<!--/*--><![CDATA[/*><!--*/\n"
                                  (with-temp-buffer
                                    (insert-file-contents "script.js")
                                    (buffer-string))
                                  "\n"
                                  "/*]]>*/-->\n"
                                  "</script>\n"))))
    
    (add-hook 'org-export-before-processing-hook 'my/org-inline-source-hook)
    
  • emacs - how to tell org-mode to embed my css file on HTML export? - Stack Ove…
  • 有没有办法让org-mode导出的html页面漂亮一点? - Emacs-general - Emacs China
  • rgb-24bit/ org-html-theme-list - 这个仓库用于存放我收集的 org-export-to-html 样式或主题
  • Feature: +style feature that provide better org HTML export default by fuxialexander · Pull Request #461 · hlissner/doom-emacs
  • MetroWind/ dotfiles-mac

    ;; Embed inline CSS read from a file.
    (defun my-org-inline-css-hook (exporter)
      "Insert custom inline css"
      (when (eq exporter 'html)
        (let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
               (path (concat dir "style.css"))
               (homestyle (and (or (null dir) (null (file-exists-p path)))
                               (not (null-or-unboundp 'my-org-inline-css-file))))
               (final (if homestyle my-org-inline-css-file path)))
          (if (file-exists-p final)
              (progn
                (setq-local org-html-head-include-default-style nil)
                (setq-local org-html-head (concat
                                           "<style type=\"text/css\">\n"
                                           "<!--/*--><![CDATA[/*><!--*/\n"
                                           (with-temp-buffer
                                             (insert-file-contents final)
                                             (buffer-string))
                                           "/*]]>*/-->\n"
                                           "</style>\n")))))))
    
    (add-hook 'org-export-before-processing-hook 'my-org-inline-css-hook)
    

18.3 App

19 LaTeX

20 Research

21 OS

21.1 Linux

21.1.1 Server

21.2 MacOS

21.2.1 Setup

  • Mac OS X Setup Guide
  • 改变 Launchpad 中应用图标的大小

    defaults write com.apple.dock springboard-columns -int 列数
    defaults write com.apple.dock springboard-rows -int 行数
    defaults write com.apple.dock ResetLaunchPad -bool TRUE
    killall Dock
    

21.2.2 Zsh

.zshenv is sourced on all invocations of the shell, unless the -f option is set. It should contain commands to set the command search path, plus other important environment variables. .zshenv should not contain commands that produce output or assume the shell is attached to a tty.

21.2.3 Tips

  • Use iconutil to Create an icns File Manually

    from stackoverflow.com/questions/12306223

    mkdir MyIcon.iconset
    
    # convert a 1024x1024 png (named "Icon1024.png") to the required icns file
    sips -z 16 16     Icon1024.png --out MyIcon.iconset/icon_16x16.png
    sips -z 32 32     Icon1024.png --out MyIcon.iconset/[email protected]
    sips -z 32 32     Icon1024.png --out MyIcon.iconset/icon_32x32.png
    sips -z 64 64     Icon1024.png --out MyIcon.iconset/[email protected]
    sips -z 128 128   Icon1024.png --out MyIcon.iconset/icon_128x128.png
    sips -z 256 256   Icon1024.png --out MyIcon.iconset/[email protected]
    sips -z 256 256   Icon1024.png --out MyIcon.iconset/icon_256x256.png
    sips -z 512 512   Icon1024.png --out MyIcon.iconset/[email protected]
    sips -z 512 512   Icon1024.png --out MyIcon.iconset/icon_512x512.png
    cp Icon1024.png MyIcon.iconset/[email protected]
    
    iconutil -c icns MyIcon.iconset
    

21.3 Windows

22 Hardware

23 Self-hosting

awesome-selfhosted

This is a list of Free Software network services and web applications which can be hosted locally. Non-Free software is listed on the Non-Free page.

23.1 Nginx Configuration

# 生成 dhparam.pem 文件, 在命令行执行任一方法:

# 方法1: 很慢
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

# 方法2: 较快
# 与方法1无明显区别. 2048位也足够用, 4096更强
openssl dhparam -dsaparam -out /etc/nginx/ssl/dhparam.pem 4096

23.2 Analytics

Ackee - Self-hosted analytics tool for those who care about privacy. MIT Nodejs

Ackee/docs/SSL and HTTPS - Nginx configuration

#
# Set "$cors_header" to avoid "if" inside location context
# https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
# https://stackoverflow.com/questions/14499320/how-to-properly-setup-nginx-access-control-allow-origin-into-response-header-bas
#
map $http_origin $cors_header {
    default "";
    ~*^https://([^/]+\.)*(domainone|domaintwo)\.com$ $http_origin;
}

#
# Redirect all www to non-www
#
server {
    listen 80;
    listen 443 ssl;

    server_name www.example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    return 301 https://example.com$request_uri;
}

#
# Redirect all non-encrypted to encrypted
#
server {
    listen 80;

    server_name example.com;

    return 301 https://example.com$request_uri;
}

#
# There we go
#
server {
    listen 443 ssl http2;

    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    access_log /var/log/nginx/log/example.com.access.log main;
    error_log  /var/log/nginx/log/example.com.error.log;

    location / {
        add_header          Access-Control-Allow-Origin "$cors_header" always;
        add_header          Access-Control-Allow-Methods "GET, POST, PATCH, OPTIONS" always;
        add_header          Access-Control-Allow-Headers "Content-Type" always;
        add_header          Strict-Transport-Security "max-age=31536000" always;
        add_header          X-Frame-Options deny;
        proxy_pass          http://localhost:3000;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect      off;
        proxy_buffering     off;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

24 Uncategorized

  • /uses - A list of /uses pages detailing developer setups, gear, software and configs
  • mayswind/ AriaNg-Native - A better aria2 desktop frontend than AriaNg, containing all features of AriaNg and has more features for desktop
  • Calendarpedia - Your source for calendars
  • 废话集 | Nonsense-Series

    以下为一则清单,包含信息资讯、工具推荐、使用教程、生活感悟、每周一书等,旨在将你引向独立思考 和客观理性。我会持续更新和维护,也可以视作本人的「废话集」和 eBooksPlan 公众号文集的备份

Author: Exuanbo

Created: 2020-05-15 Fri 22:34