Memo on upgrading ArchLinux
Run pacman -Syu
to upgrade all packages.
- Archlinux replaces grub with grub2
- I cannot install grub2, blocklists stuff
- Downgrade to grub-obsolee
- Then grub
- Setup (hd0) to install MBR
- Restart netbook (make sure the boot priority is right)
notes on upgrading Gentoo Linux
sudo emerge --update --deep --with-bdeps=y --newuse world
- I get notified that some newer version package is required, so I have to manually install those package and re-run the `emerge world`
- Some package is gone (libreoffice-bin, for example).
Here is command to manually install package:
sudo ebuild /usr/portage/www-client/firefox-bin/firefox-bin-23.0.ebuild unpack compile install qmerge clean
How to take screen shot for business people efficiently in Emacs
CREATED:
UPDATED:
Tools
Name | Description | Minimum version |
---|---|---|
Org-mode | create org-file which could be converted to odt file | 7.8 |
scrot | command line tool to take screen shot | any version |
Libreoffice | convert odt to Microsoft Word | any version |
xsel | X clipboard tool | any version |
Work flow
Use scrot to screenshot and put its path into clipboard
scrot '%H%M%S-%d_$wx$h.png' -e 'mkdir -p ~/screenshot;mv $f ~/screenshot/;echo ~/screenshot/$f|tr -d \"\\n\"|xsel -ib;'
Create org file and insert path of screen shot
Actually I use below elisp command to do the insertion for me.
(defun insert-file-link-from-clipboard ()
"Make sure the full path of file exist in clipboard. This command will convert
The full path into relative path and insert it as a local file link in org-mode"
(interactive)
(let (str)
(with-temp-buffer
(shell-command
(cond
((eq system-type 'cygwin) "getclip")
((eq system-type 'darwin) "pbpaste")
(t "xsel -ob"))
1)
(setq str (buffer-string)))
;; convert to relative path (relative to current buffer) if possible
(let ((m (string-match (file-name-directory (buffer-file-name)) str) ))
(when m
(if (= 0 m )
(setq str (substring str (length (file-name-directory (buffer-file-name)))))
))
(insert (format "[[file:%s]]" str)))
))
Convert org file into Microsoft Word format
I'm sure this method works even on Windows. But I don't have Windows PC to validate my belief. Libreoffice is required.
Run the command "M-x org-export-as-odt".
Word document is automatically created if you insert below code into your ~/.emacs:
;; This setup is tested on Emacs 24.3 & Emacs 24.4 on Linux/OSX
;; org v7 bundled with Emacs 24.3
(setq org-export-odt-preferred-output-format "doc")
;; org v8 bundled with Emacs 24.4
(setq org-odt-preferred-output-format "doc")
;; BTW, you can assign "pdf" in above variables if you prefer PDF format
;; Only OSX need below setup
(defun my-setup-odt-org-convert-process ()
(interactive)
(let ((cmd "/Applications/LibreOffice.app/Contents/MacOS/soffice"))
(when (and (eq system-type 'darwin) (file-exists-p cmd))
;; org v7
(setq org-export-odt-convert-processes '(("LibreOffice" "/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to %f%x --outdir %d %i")))
;; org v8
(setq org-odt-convert-processes '(("LibreOffice" "/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to %f%x --outdir %d %i"))))
))
(my-setup-odt-org-convert-process)
Emacs will find the binary "soffice" from libreoffice to do the conversion.
Tips
If you need page break in exported document, insert below snippet into the org file:
#+ODT: <text:p text:style-name="PageBreak"/>
How to use flyspell in web-mode
Please see http://blog.binchen.org/posts/effective-spell-check-in-emacs.html for solution.
How to use git effectively
To take the full power of git, you need forget GUI and use CLI only. A little knowledge of script language like Bash/Perl/Python may be helpful.
Here is an example how I use git.
Problem
I'm working for a big enterprise project which uses git as version control software. My daily routine is find what files I changed. So I often use git commands with "–stat" parameters.
git show --stat
git diff --cached --stat
git log --stat
git diff --stat
Since I use CLI git in bash shell only. I set alias for these commands in bash. For example, I need only type gds
in bash instead of git diff --stat
.
Git commands with "–stat" option usually only display relative paths, so I write some bash function which enable me select that relative path interactively (without using mouse, of course), convert that path to absolute path, and copy that absolute path into clipboard.
Getting full path into clipboard is useful because in big projects I need do lots of communication with managers and colleagues. For example, I need list files I changed in our bug tracking system (JIRA) and also email them using Outlook. If you still don't understand why it's hard in big project, let me give you some hint. Big project is usually a big shit. If you edit file A, you will find another 10 files distributed in different location with same file name and similar code. Those files are not your business.
Set up
Now you understand the problem. Here comes the solution.
Step 1, You need install percol by sudo pip install percol
. Percol will provide some interactive UI to help you select the line in shell.
Step 2, install xclip under Linux to support paste text into X clipboard. BTW, you did install some clipboard manager under Linux, didn't you?
Step 3, insert below code into your ~/.bash:
# search the file and pop up dialog, then put the full path in clipboard
function pclip() {
if [ $OS_NAME == CYGWIN ]; then
putclip $@;
elif [ $OS_NAME == Darwin ]; then
pbcopy $@;
elif [ -x /usr/bin/xclip ]; then
xclip -selection c $@;
else
echo "xclip is not installed!"
fi
}
function glsf () {
local str=`git --no-pager log --oneline --decorate --stat $* |percol`
if [[ $str =~ ^[[:space:]]*([a-z0-9A-Z_.\/-]*).*$ ]]; then
echo -n ${BASH_REMATCH[1]} |pclip;
echo ${BASH_REMATCH[1]}
fi
}
function ff()
{
# @see http://stackoverflow.com/questions/13373249/extract-substring-using-regexp-in-plain-bash
local fullpath=$*
local filename=${fullpath##*/}
local filter=${fullpath##*./}
# only the filename without path is needed
# filename should be reasonable
local cli=`find $PWD -type f -iname '*'${filename}'*'|grep ${filter}|percol`
echo ${cli}
echo -n ${cli} |pclip;
}
Usage
glsf
ff line-from-clipboard
# now I can paste the full path into firefox, outlook ...
Here is the screen cast:
三文鱼炖豆腐做法
用料: 三文鱼、老豆腐、面粉、黑胡椒粒、甜椒、葱、 大蒜、姜、松子、香菜、盐、老抽、生抽、糖。 做法: 1: 三文鱼去掉鱼骨,拔出鱼刺,和豆腐切成大小相仿的小块, 并用厨房纸巾稍稍擦干水份,三文鱼块里撒入适量的黑胡椒粒, 放入2勺面粉稍微裹以下; 鱼炖豆腐好吃2字诀-三文鱼炖豆腐 2: 其他材料备好; 鱼炖豆腐好吃2字诀-三文鱼炖豆腐 3: 锅底用姜片擦一遍,放入姜片、三文鱼2面煎黄取出, 再放入豆腐块煎黄; 鱼炖豆腐好吃2字诀-三文鱼炖豆腐 4: 倒入适量老抽上色,生抽、盐、糖、大蒜调味, 一次性倒入足量的开水,大火煮开,中火炖至快干; 鱼炖豆腐好吃2字诀-三文鱼炖豆腐 5: 放入甜椒块翻炒一下,撒入松子、香菜段即可起锅。 鱼炖豆腐好吃2字诀-三文鱼炖豆腐 小牛贴心提示: 1:炖豆腐和鱼,想要好吃,关键要时间, 即是老话所说"千滚的豆腐万滚的鱼"; 2:鱼块裹面粉、生姜擦锅都能防止鱼不沾锅; 3:一次性加入足量的开水,中途不要频繁加水。
- 生抽至少两大勺,我放得太少
- 炖得时候我放水太少,一开始就要多放,至少半大碗水
- 鱼和豆腐煎的黄一点,一开始用纸吸干水份较好,否则油到处溅
- 老抽没有了,所以颜色很难看
- 诀窍1,黑胡椒之类的辛香料都是油炸过后才更香
- 诀窍2,如果做汤的话,鱼和豆腐炖的时间越长越好吃,也有营养
另附有三文鱼豆腐汤的做法
Copy file name or full path of file from Emacs dired buffer into system clipboard
Simple, insert below code into your ~/.emacs:
;; {{ copy the file-name/full-path in dired buffer into clipboard ;; `w` => copy file name ;; `C-u 0 w` => copy full path (defadvice dired-copy-filename-as-kill (after dired-filename-to-clipboard activate) (with-temp-buffer (insert (current-kill 0)) (shell-command-on-region (point-min) (point-max) (cond ((eq system-type 'cygwin) "putclip") ((eq system-type 'darwin) "pbcopy") (t "xsel -ib") ))) (message "%s => clipboard" (current-kill 0)) )
It support Cygwin and OSX out of the box. You need install xsel under Linux.
BTW, I suggest installing a clipboard manager like parcellite under Linux to sync the two X clipboards.
番茄鸡蛋汤做法
- 放蒜(可以加姜,葱)大火爆炒,也可以加点老抽
- 放入番茄超出茄红素
- 加水煮,调味放盐糖
- 最后放入打碎鸡蛋,五秒钟后起锅
有人介绍下面也是类似原理,加葱花老抽爆炒,然后放水煮面
Matthew Keeler video tutorial on org-mode in Emacs
At 4:57 it becomes interesting.