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: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)))
@ngn999
ngn999 / 12306AutoLogin.user.js
Created January 8, 2012 06:11 — forked from kevintop/12306AutoLogin.user.js
12306 Auto Login
/*
12306 Auto Login => A javascript snippet to help you auto login 12306.com.
Copyright (C) 2011 Kevintop
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes 12306.user.js