emacs

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/"))) 
    (package-initialize)
    
  • restart emacs
  • call list-packages

org mode

practice
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
<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
L #+LaTeX:
h #+BEGIN_EXPORT html … #+END_EXPORT
H #+HTML:
a #+BEGIN_EXPORT ascii … #+END_EXPORT
A #+ASCII:
i #+INDEX:
I #+INCLUDE: “filename”

shortcut

Ctrl-i: fold the block content

fcitx input

reference

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

spacemacs

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
  '(org2blog)
(defun mylayer/init-org2blog ()
  (use-package org2blog)) 
  • add configuration to .spacemacs in the dotspacemacs/user-config
(require 'org2blog-autoloads)
(setq org2blog/wp-blog-alist
      `(("ersansansan"
         :url "http://45.63.61.252/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"

set proxy

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

Ubuntu

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

python

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

shadowsocks

ubuntu

ICS

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

C++

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 *