Skip to content

Instantly share code, notes, and snippets.

View ngn999's full-sized avatar
💭
I may be slow to respond.

ngn999 ngn999

💭
I may be slow to respond.
View GitHub Profile
@ngn999
ngn999 / gist:3168642
Last active April 27, 2017 08:23
Emacs 常用Mode

学会基本操作后,值得细究的Mode:

  • CC Mode, 写C/C++代码, 管理缩进,高亮
  • Cperl Mode, 写Perl代码, 比Perl Mode更强.
  • Python Mode
  • eshell, M-x shell RET
  • Diff Mode / Ediff Mode, 看diff, 做merge操作.
  • VC, 与版本管理系统相接合,支持CVS, SVN, Git etc.
  • Hippie Expand, M-/
  • Dired Mode, 文件, 目录管理. copy, mv, rename. create
@ngn999
ngn999 / gist:3167484
Created July 24, 2012 01:58
分析src来源
perl -MURI -anle '%h=URI->new("http://127.0.0.1" . $F[-1])->query_form; print $h{src}' 

| sort | uniq -c | sort -nr

@ngn999
ngn999 / gist:3155115
Created July 21, 2012 08:28
统计最常用的10条命令
history | perl -anle '$c{$F[3]}++; END{@keys = sort { $c{$b} <=> $c{$a}} keys %c; foreach(@keys){print;}}'
| head
@ngn999
ngn999 / gist:3148635
Last active October 7, 2015 10:08
编译emacs 23.4

我的配置是是针对23的,也不知道到24有多大变化, 所以还是用23好了.
升到24, 好多包的管理方式要变了, 怕不适应.

编译参数:

 ./configure --prefix=/opt/emacs/ --with-x=no --with-x-toolkit=no --enable-largefile

make -j 8

@ngn999
ngn999 / gist:3148484
Created July 20, 2012 03:32
正则表达式的向后查找, 向前查找

向后查找:

echo "pt=1234" | grep -Po '(?<=pt=)\d+'

向前查找:

echo "1234pt=" | grep -Po '\d+(?=pt=)'

@ngn999
ngn999 / gist:3141424
Created July 19, 2012 07:47
git log更美观的输出

git log --graph

git log --graph --oneline

(defn max2 [ & coll ]
(if (empty? coll)
nil
((fn iter [s m]
(if (empty? s)
m
(if (>= (first s) m)
(iter (rest s) (first s))
(iter (rest s) m))))
(rest coll) (first coll))
@ngn999
ngn999 / range.clj
Created July 5, 2012 14:19
my range
(fn range2 [ss ee]
((fn iter [s e res]
(if (>= s e)
res
(do
(iter (inc s) e (concat res (list s))))))
ss ee '()))
@ngn999
ngn999 / replicate-seq.clj
Created July 5, 2012 13:27
Replicate a Sequence
(fn [coll n]
(apply concat
(map #(for [x (range n)] %) coll)))
@ngn999
ngn999 / dup-seq.clj
Created July 5, 2012 13:20
Duplicate a Sequence
(fn [coll]
(apply concat
(map (fn [x] (list x x)) coll)))