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:842358
Created February 24, 2011 16:12
quote and backquote
`(a list have (+ 2 3) elements) => (a list have (+ 2 3) elements)
'(a list have (+ 2 3) elements) => (a list have (+ 2 3) elements)
`(a list have ,(+ 2 3) elements) => (a list have 5 elements)
p = reinterpret_cast<const unsigned char *>(szKey);
while (*p) {
res = (res << 7) + (res >> 25) + *p++;
}
// 相当于,res这个int32将前面8位移到后面去了, eg. 1101001xxxxxxxxxxxxx,就成了,xxxxxxxxxxxxx110100
@ngn999
ngn999 / go.el
Created May 22, 2011 17:51
test.el
(defun squar (x)
"return x * x"
(* x x))
;; scroll-ahead
;; scroll-behind
;;switch-to-buffer
;;other-buffer
@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
@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 / 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 / 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 '()))
(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 / gist:3141424
Created July 19, 2012 07:47
git log更美观的输出

git log --graph

git log --graph --oneline

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

向后查找:

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

向前查找:

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