サーバーとかで作業する時,つないだ先でたくさんターミナルを開きたい,切断しても継続して欲しいと思うことがあるかもしれません.
そんな需要に答えるのがscreenやtmuxなどのターミナルマルチプレクサです.screenとtmux,あまり大きな違いはないのですが,僕はtmuxを使ってるのでtmuxについて説明します.
$brew install mobile-shell
$sudo port install mosh
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is e5:99:11:ec:f7:f5:61:fa:41:c2:04:76:9b:0f:68:1f. Please contact your system administrator. Add correct host key in /var/root/.ssh/known_hosts to get rid of this message. Offending key in /var/root/.ssh/known_hosts:1 ← ☆ここ☆ RSA host key for [接続先IP] has changed and you have requested strict checking. Host key verification failed.もし出た場合は,☆ここ☆と書いてある行に示されているファイルをemacsなりviなりで開いて,接続先IPの行を消すと,次接続した時にホスト情報が再作成されてたぶん直ります.
int v; v ^= v;//初期化ちなみに、筆者の友人の環境によると、v=0とくらべて、2×10^(-8) [s]早くなりました。 時間がない人はお試しください。
struct array_tag{int x[100]}; struct array_tag a,b; a=b;
M-x describe-bindings
M-x describe-keyをしたあと調べたいキーバインドを入力
(server-start) (defun non-elscreen-current-directory () (let* (current-dir (current-buffer (nth 1 (assoc 'buffer-list (nth 1 (nth 1 (current-frame-configuration)))))) (active-file-name (with-current-buffer current-buffer (progn (setq current-dir (expand-file-name (cadr (split-string (pwd))))) (buffer-file-name))))) (if active-file-name (file-name-directory active-file-name) current-dir)))
alias eclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" function cde () { EMACS_CWD=`eclient -e " (if (featurep 'elscreen) (elscreen-current-directory) (non-elscreen-current-directory))" | sed 's/^"\(.*\)"$/\1/'` echo "chdir to $EMACS_CWD" cd "$EMACS_CWD" } function dired () { eclient -e "(dired \"$PWD\")" }
define GC_DEBUG include "gc.h" define malloc(n) GC_MALLOC(n) define calloc(m,n) GC_MALLOC((m)*(n)) define free(p) GC_FREE(p) define realloc(p,n) GC_REALLOC((p),(n)) define CHECK_LEAKS() GC_gcollect()デバッグ用に上の文を書いときます.プログラム内でmallocした領域がBoehmの管理下に入ります. ちなみにこれを導入したプログラムをgccでコンパイルするときのオプション例は以下.
gcc -o TS TS.c -I/usr/local/include -L/usr/lib -lgc
int main(void) { GC_find_leak = 1; int i; int *p; for(i=0;i<100;i++){ p = (int *)malloc(100*sizeof(int)); } exit(0); return 0; }GC_find_leak=1は ぐるポ検出モードです. return の前に exit してるのは return した瞬間にガベコレが働いていろいろうるさかったからです.Let Mr.Exit shut him upということです. とりあえずこれでちゃんと検出できました.やったね!v(^o^)v
void isalloc(int n) { int *p; p = (int *)malloc(n*sizeof(int)); } int main(void) { GC_find_leak = 1; int i; for(i=0;i<100;i++){ isalloc(100); } exit(0); return 0; }検出.これはループ呼び出し1回だけでも検出します.
void isalloc(int n) { int *p; p = (int *)malloc(n*sizeof(int)); free(p); }検出せず.
void isalloc(int n) { int *p; static int num_hist=0; static int **p_hist; p = (int *)malloc(n*sizeof(int)); p_hist = (int **)realloc(p_hist, sizeof(p_hist)+n*sizeof(int *)); p_hist[num_hist++] = p; }これも検出せず.
complex MulComplex2(complex x, complex y) { double temp; complex z; temp = y.im * (x.re - x.im); z.re = x.re * (y.re - y.im) + temp; z.im = x.im * (y.re + y.im) + temp; return z; }