emacs start from scratch
melpha – for package install
default indent in init file:
Emacs 24: (org-indent-mode 1)
Emacs 24+: (add-hook ‘org-mode-hook ‘org-indent-mode)
- shortcut to start a code block or other block types
- need to be in the start of the line to trigger
|<s TAB||#+BEGIN_SRC … #+END_SRC|
|<l TAB||#+BEGIN_EXPORT latex … #+END_EXPORT|
|e||#+BEGIN_EXAMPLE … #+END_EXAMPLE|
|q||#+BEGIN_QUOTE … #+END_QUOTE|
|c||#+BEGIN_CENTER … #+END_CENTER|
|h||#+BEGIN_EXPORT html … #+END_EXPORT|
|a||#+BEGIN_EXPORT ascii … #+END_EXPORT|
Ctrl-i: fold the block content
I use ubuntu default desktop environment – Unity, so I should change
the desktop entry and using “env” command to modify the LC_CTYPE for
only emacs. Because if I modify the LC_CTYPE for overall environment,
some programs may have problems.
env LC_CTYPE=zh_CN.UTF-8 emcas
save working environment
emacs offers desktop auto-save mode by using “M-x desktop-save“ to
save it manually or using “M-x desktop-save-mode“ or adding entry to
the init file.
Besides, theres has some other options for this mode see here
org and org2blog
When publishing an org file to blog, if added a title in the org file, it will raise an error like:
Wrong type argument: listp, #("Title" 0 15 (:parent (#0))).
The solution is to reload org using `M-x org-reload` or reload fully using ‘C-u M-x org-reload’.
If this doesn’t work, then reinstall the org.
export org files as blogs
M-x org2blog/wp-login C-c M-p d: M-x org2blog/wp-post-buffer C-c M-p p: publish
- create a new layer
- add package info to the
package.elof the layer
(defconst mylayer-packages '(org2blog) (defun mylayer/init-org2blog () (use-package org2blog))
- add configuration to
(require 'org2blog-autoloads) (setq org2blog/wp-blog-alist `(("ersansansan" :url "http://22.214.171.124/xmlrpc.php" :username "org2blog" :default-categories ("misc") :keep-new-lines t :confirm t :wp-code nil :tags-as-categories nil) )) (setq org2blog/wp-buffer-template "----------------------- #+TITLE: %s #+DATE: %s -----------------------\n") (defun my-format-function (format-string) (format format-string org2blog/wp-default-title (format-time-string "%d-%m-%Y" (current-time)))) (setq org2blog/wp-buffer-format-function 'my-format-function)
- note that if the url is wrong, it will raise an error:
Wrong type argument: listp, "URL/HTTP 200"
(setq url-proxy-services (("no_proxy" . "^\\(localhost\\)") ("http" . "127.0.0.1:1080") ("https" . "127.0.0.1:1080")))
kill listening port
when python start a simple http server and terminated, the listening port is left open.
use “fuser -k 8888/tcp”
shell environment variables
setting: export VAR_NAME=VAR_VALUE
getting: echo VAR_NAME
reference for ubuntu 16
install by dpkg
and set the system keyboard input method to fcitx
and add chines(simplify) language support
command line version
ubuntu 16 rc.local
Check status with command `systemctl status rc-local.service`. If the
status is failed, then check according to the failure message. Mine
is the script is not executable, so I change the first line of
rc.local from !/usr/bin/sh -e to !/usr/bin/bash and it’s solved.
However, somehow, the command xrandr is not executed and the log shows
“can’t open display”. I think it’s becuase the script is run before
the unity starts, so instead I put the commands into a scripts and add
the script to startup applications. However, it still doesn’t work.
- `df -h`: disk size and usage and mount point
- `lsblk`: list disk partitions and mount point
- `lshw`: list hardware infomation
chrome/terminal start slowly
look up computer’s configuration
$ lspci $ lshw $ cat /proc/cpuinfo $ cat /proc/meminfo $ lscpu
windows web server shelve
it seems windows 10 has problem with shelve; use pickle instead
besides for pickle, the code has to deal with the case that the file does not exists, so thet the pickle may raise an error
- download from apt-get, but cannot -d start
- download from python-pip
- pip can be downloaded from apt-get: sudo apt install python-pip
- remember to install using pip with sudo root, otherwise it will be installed under /home
- add to rc.local for auto start
- gfwlist url: https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
- negative integer dividing by shifting
add biasing by 2^k-1 to divide by k
- floating points: http://www.toves.org/books/float/
fixed-point representation & Normalized floating-point
Process finished with exit code 9
OS has an oom-killer which will find those using too much memory and out of the allowed virtual memory.
To verify whether the process is really killed by oom-killer (on Ubuntu):
grep -i 'kill process' /var/log/syslog grep -i 'killed process' /var/log/syslog
Generally, there will be three figures indicating something:
- total-vm: The virtual memory the process is used
- anon-rss: The memory that is mapped to memory blocks
- file-rss: The memory mapped to devices or files
When allocating lots of memory but not really using it, the total-vm will be high but anon-rss won’t.
When allocating lots of memory and really use it, the anon-rss will also be high. When opening some huge files, the file-rss will be high.
About OOM killer, there are lots of good blogs. A chinese blog