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: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:3761037
Created September 21, 2012 11:47
Emacs Abbrev

Abbrev是神马

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

如何使用

定义:

@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: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=)'

@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
p = reinterpret_cast<const unsigned char *>(szKey);
while (*p) {
res = (res << 7) + (res >> 25) + *p++;
}
// 相当于,res这个int32将前面8位移到后面去了, eg. 1101001xxxxxxxxxxxxx,就成了,xxxxxxxxxxxxx110100