关于nginx+luajit的折腾

缘起

需要写一个lua版的SDK在nginx中使用

基本功能

  1. 通过http请求下载关于SDK的配置文件并cache起来
  2. http的响应信息是json格式的
  3. 需要用到rsa/des/rc4解密

系统环境

ubuntu14.04

相关资料

  • http://www.kyne.com.au/~mark/software/lua-cjson-manual.html
  • http://www.kyne.com.au/~mark/software/lua-cjson.php
  • zlib下载地址: http://www.zlib.net/
  • 安装luajit: http://luajit.org/install.html

学到了什么

文件权限之粘滞位

缘起

如果将一个root属主的可执行文件,添加一个属主的粘滞位,那么,由该程序创建的其它进程的euid还是root吗?

测试

test.php

 

看来是不好使的,即: 粘滞位是不能在程序间继承的

awk之exit

题目

有100个日志文件,每个文件大约1G,每条日志都以 “H:i:s” 的时间格式开头,如:

因为是日志文件,所以肯定以时间为顺序的,现在可以确定的是,在某个文件中存在一条 01:02:03 这个时间点的关于xxx的日志,要找出来 ,如何做?

 

办法1:

虽然我们的正则是只匹配行首,算是很快的了,但是,我们还是扫描了整个的100个文件;考虑到每个文件肯定都是有时间顺序的,我们做了大量的无用的工作,其实完全可以提前退出的,加入每10分钟都会有日志出现,则可以优化如下:

 办法2:

这样的话,没个文件只扫描很少的一部分就可以了

办法3:

该题的sed解法:

 办法4:

当然,将 xxx 并入正在表达式也是可以的(只是没有上面看起来更一目了然):

 

sed 示例

在匹配到的行尾添加:

删除匹配后的N行(delete n lines following a pattern)or (delete n lines after match/matches)

如果匹配到的行不需要删除

 

正则替换:

将 “craete time: 1988-02-02 11:22:12″ 替换为”craete time: 1988-02-02T11:22:12”

  1. 使用 -r
  2. 反向引用

 

参考资料: http://blog.csdn.net/holandstone/article/details/8488434

http://stackoverflow.com/questions/4396974/sed-or-awk-delete-n-lines-following-a-pattern

http://stackoverflow.com/questions/8323287/how-can-i-use-sed-to-delete-2-lines-after-match-matches

 

 

svn 1.7手册

http://svnbook.red-bean.com/en/1.7/

 

Examining History

Your Subversion repository is like a time machine. It keeps a record of every change ever committed and allows you to explore this history by examining previous versions of files and directories as well as the metadata that accompanies them. With a single Subversion command, you can check out the repository (or restore an existing working copy) exactly as it was at any date or revision number in the past. However, sometimes you just want to peer into the past instead of going into it.

Several commands can provide you with historical data from the repository:

svn diff
Shows line-level details of a particular change

svn log
Shows you broad information: log messages with date and author information attached to revisions and which paths changed in each revision

svn cat
Retrieves a file as it existed in a particular revision number and displays it on your screen

svn annotate
Retrieves a human-readable file as it existed in a particular revision number, displaying its contents in a tabular form with last-changed information attributed to each line of the file.

svn list
Displays the files in a directory for any given revision

 

more…

理解SVN关键词BASE,HEAD,COMMITTED,PREV

SVN是以版本号(revision number)来记录版本库的每一次改变,一般的SVN操作不需要用到版本号,但是有些SVN操作需要指定版本号。我们可以指定一个明确的整数版本号,但是也可以使用SVN关键字来指代某个特殊的版本号,SVN会真正计算出它所指代的实际整数版本号:

HEAD:版本库中最新的版本;

BASE:某个工作副本项的版本,注意这个是你上次update该项时的版本号,可能晚于当前最新的版本号;

COMMITTED:某个工作副本项最近修改的版本,与BASE相同或更早;

PREV:COMMITTED – 1。

HEAD针对于版本库,另外3个针对于某个工作副本目录或文件。

示例:

$ svn diff -r PREV:COMMITTED foo.c
# shows the last change committed to foo.c
$ svn log -r HEAD
# shows log message for the latest repository commit
$ svn diff -r HEAD
# compares your working copy (with all of its local changes) to the latest version of that tree in the repository
$ svn diff -r BASE:HEAD foo.c
# compares the unmodified version of foo.c with the latest version of foo.c in the repository
$ svn log -r BASE:HEAD
# shows all commit logs for the current versioned directory since you last updated
$ svn update -r PREV foo.c
# rewinds the last change on foo.c, decreasing foo.c’s working revision
$ svn diff -r BASE:14 foo.c
# compares the unmodified version of foo.c with the way foo.c looked in revision 14

 

原文链接: http://www.cnblogs.com/frydsh/archive/2012/08/25/2655569.html