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
p = reinterpret_cast<const unsigned char *>(szKey);
while (*p) {
res = (res << 7) + (res >> 25) + *p++;
}
// 相当于,res这个int32将前面8位移到后面去了, eg. 1101001xxxxxxxxxxxxx,就成了,xxxxxxxxxxxxx110100
@kevintop
kevintop / 12306AutoLogin.user.js
Created January 6, 2012 15:05
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 / gist:3148484
Created July 20, 2012 03:32
正则表达式的向后查找, 向前查找

向后查找:

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

向前查找:

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

@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

@yvbeek
yvbeek / KeychainItemWrapper.h
Created August 17, 2012 05:32 — forked from dhoerl/KeychainItemWrapper.h
KeychainItemWrapper ARCified
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
@ngn999
ngn999 / gist:3761037
Created September 21, 2012 11:47
Emacs Abbrev

Abbrev是神马

Abbrev就是缩写的意思, 在Emacs里Abbrev能方便的输入这种缩写. 比如, 定义好, mgmtmanagement的缩写,
那以后你输入mgmt, 加一非字母数字符号, 就自动扩展成management. 很好用.

如何使用

定义:

@ngn999
ngn999 / gist:3781227
Created September 25, 2012 11:27
scanf,printf的那些变态用法
ret = sscanf(p,"%*s %1024s",request);
if(ret!=1){
    ...
}

p是"GET /index.html", 这行代码的意思是说直接取"/index.html", 跳过前面的"GET ".
这种用法, 避免定义一个哑变量.

@ngn999
ngn999 / gist:3783167
Created September 25, 2012 17:03
emacs怎么全文高亮指定的字符串?

emacs自带的:
高亮匹配的字符串:M-s h p
高亮匹配字符串所在的行:M-s h l
取消高亮: M-s h u

也可以用highlight-symbol.el这个扩展。

--
smth emacs版

@ngn999
ngn999 / gist:3791870
Created September 27, 2012 02:38
Regexp::Common

Regexp::Common

这个碉堡了!

use Regexp::Common;

if (/$RE{net}{IPv4}/){
  ...;
}
@ngn999
ngn999 / gist:3863072
Created October 10, 2012 04:00
统计某一app来的query的特点
cat http2kfc.20121008  | grep tbskip |head -n 1000000 | 
perl -MURI -MList::Util -nale '$uri = new URI ("/bin/search?" . $F[-1]); 
%h = $uri->query_form; $fat= List::Util::reduce { $a . "_". $b } (keys %h); 
print $fat;'  | sort | uniq -c