emacs start from scratch

melpha – for package install

  • add to init file
    (require 'package)
    (add-to-list 'package-archives 
                 '("melpa" . "https://melpa.org/packages/")) 
    (when (< emacs-major-version 24) 
        (add-to-list 'pacfffkage-archives '("gnu" . "http://elpa.gnu.org/packages/"))) 
  • restart emacs
  • call list-packages

org mode

default indent in init file:
Emacs 24: (org-indent-mode 1)
Emacs 24+: (add-hook ‘org-mode-hook ‘org-indent-mode)

easy template

  • shortcut to start a code block or other block types
  • need to be in the start of the line to trigger
L #+LaTeX:
i #+INDEX:
I #+INCLUDE: “filename”


Ctrl-i: fold the block content

fcitx input


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
在emacs24.desktop的Exec命令前面加上env LC_CTYPE=zh_CN.UTF-8

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.
(desktop-save-mode 1)
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


install org2blog

  • create a new layer
M-x configuration-layer/create-layer
  • add package info to the package.el of the layer
(defconst mylayer-packages
(defun mylayer/init-org2blog ()
  (use-package org2blog)) 
  • add configuration to .spacemacs in the dotspacemacs/user-config
(require 'org2blog-autoloads)
(setq org2blog/wp-blog-alist
         :url ""
         :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
(defun my-format-function (format-string)
  (format format-string
          (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"

set proxy

(setq url-proxy-services
     (("no_proxy" . "^\\(localhost\\)")
      ("http" . "")
      ("https" . "")))


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

Sogou input

reference for ubuntu 16
install by dpkg
and set the system keyboard input method to fcitx
and add chines(simplify) language support

Chinese-English dictionary

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.

check disk

  • `df -h`: disk size and usage and mount point
  • `lsblk`: list disk partitions and mount point
  • `lshw`: list hardware infomation

look up computer’s configuration

$ lspci
$ lshw
$ cat /proc/cpuinfo
$ cat /proc/meminfo
$ lscpu

set up a wordpress


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




data representations

  • 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

Categories: Notes

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *