Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / gist:933a2855fd94d7ae3068b6af91398e4a
Last active October 9, 2018 05:37
keyword "volatile" in Linux C code
linux/Documentation/process/volatile-considered-harmful.rst
@c02y
c02y / init.el
Last active October 15, 2018 09:13
helm-gtags for emacs
1. fix string in mch
2. comment ggtags part code, you can use ggtags or helm-gtags
3. fix the multiple ggtags-mode in mode-line
4. delete gc-cons-threshold in init-gnus.el since it is already defined in init.el
5. add (helm-gtags-mode . " Hg")
(setq
;; helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
@c02y
c02y / init.el
Created October 11, 2018 07:31
cscope config for Emacs
(require 'xcscope)
(cscope-setup)
(setq cscope-option-use-inverted-index t)
(defadvice cscope-bury-buffer (after cscope-bury-buffer activate)
"Kill the *cscope* window after hitting q or Q instead of leaving it open."
(delete-window))
(defun cscope-create-database (top-directory)
"Create cscope* files in one step containing, do this before using cscope:
1. C-c s L
2. C-c s I
@c02y
c02y / init.el
Created October 16, 2018 07:55
remove company-ropemacs line in init.el
https://github.com/company-mode/company-mode/issues/159#issuecomment-122598917
@c02y
c02y / init.el
Last active October 16, 2018 10:08
python in emacs
https://realpython.com/emacs-the-best-python-editor/
1. remove paradox since it will keep loading the list
2. remove python-mode configuration about company/anaconda since when you open python file, it will say
"comint-send-string: Process Python Internal(file.py) not running"
3. install elpy, py-autopep8
;; Python Development Environment
@c02y
c02y / init.el
Last active October 18, 2018 07:47
replace nlinum-mode with display-line-numbers-mode which is supported by Emacs 26 and more
https://github.com/emacs-mirror/emacs/blob/ff49d86b6419f88205ff9a5d8b1cc46fcda8371c/etc/NEWS#L493
http://xuchengpeng.com/2018/03/30/emacs-show-line-numbers/
;; M-x profiler-start and do your thing and M-x profiler-report to show the
;; performance report, the following improves the structure of the report
(setq profiler-report-cpu-line-format '((80 left) (24 right ((19 right) (5 right)))))
(setq profiler-report-memory-line-format '((80 left) (24 right ((19 right) (5 right)))))
@c02y
c02y / init.el
Created October 19, 2018 07:15
tweak keybings since it affect the keybings in other modes like elpy-*
(bind-keys :map emacs-lisp-mode-map
("C-x c" . emacs-lisp-byte-compile-and-load)
("C-c c" . eval-buffer)
("C-c C-r" . (lambda () (interactive) (load-file "~/.emacs.d/init.elc")))
)
(bind-keys :map lisp-interaction-mode-map
("C-c C-e" . (lambda () (interactive) (find-file "~/.emacs.d/init.el")))
("C-c C-r" . (lambda () (interactive) (load-file "~/.emacs.d/init.elc")))
;; C-h e to switch to *Message* Buffer
)
@c02y
c02y / gist:e6d31643dc69bb9da11f72eb21df1c83
Created October 24, 2018 07:11
resource how to top process of cpu and mem, useful for tmux status line
#!/bin/bash
MEM=$(ps -eo pid,cmd,%mem --sort=-%mem | sed '2q;d')
TOP_MEM_PID=$(echo $MEM | awk '{print $1}')
TOP_MEM=$(echo $MEM | awk '{print $2}')
TOP_MEM_P=$(echo $MEM | awk '{print $NF}')
CPU=$(ps -eo pid,cmd,%cpu --sort=-%cpu | sed '2q;d')
TOP_CPU_PID=$(echo $CPU | awk '{print $1}')
TOP_CPU=$(echo $CPU | awk '{print $2}')
TOP_CPU_P=$(echo $CPU | awk '{print $NF}')
@c02y
c02y / init.el
Created October 31, 2018 06:43
change sudo string og Tramp
/sudo:root@localhost:
to
/sudo::
@c02y
c02y / config.fish
Created November 1, 2018 07:18
list contents of deb package
alias debl 'dpkg --contents' # list contents of deb package