Wednesday, May 13, 2009


* 2009 La Casa della Musica, Parma, Italy - Website, A/V Streams & Slides

LAC (Linux Audio Conference) is held annually and this year it was in Italy in April, and from its papers and slides, it can be observed that frugal may be the next right direction.

Sunday, May 10, 2009

之前写过一篇 Blog
这里,能找到这个系列又多了一个
  1. Karmic Koala (命运的树袋熊) 9.10 Released in October 2009
最近又发现了一系列有意思的名字,就是 Linux 内核的发布代号:

这个代号隐藏于 每一内核发布的 Makefile 文件中,第5行是

git show v2.6.30-rc5:Makefile |head -n5
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 30
EXTRAVERSION = -rc5
NAME = Vindictive Armadillo


其中 Vindictive Armadillo (怀恨的犰狳) 就是了。

倒推过来是
  1. v2.6.30 Vindictive Armadillo (怀恨的犰狳) (Not Released Yet)
  2. v2.6.29 Temporary Tasmanian Devil (临时的 Tasmanian 恶魔)
  3. v2.6.28 Erotic Pickled Herring ()
  4. v2.6.27 Rotary Wombat ()
  5. v2.6.26 Rotary Wombat
  6. v2.6.25 Funky Weasel is Jiggy wit it
  7. v2.6.24 Arr Matey! A Hairy Bilge Rat!
  8. v2.6.23 Arr Matey! A Hairy Bilge Rat!
  9. v2.6.22 Holy Dancing Manatees, Batman!
  10. v2.6.21 Nocturnal Monster Puppy
  11. v2.6.20 Homicidal Dwarf Hamster
  12. v2.6.19 Avast! A bilge rat!
  13. v2.6.18 Avast! A bilge rat!
  14. v2.6.17 Crazed Snow-Weasel
  15. v2.6.16 Sliding Snow Leopard
  16. v2.6.15 Sliding Snow Leopard
  17. v2.6.14 Affluent Albatross
  18. v2.6.13 Woozy Numbat
  19. v2.6.12 Woozy Numbat
  20. v2.6.11 Woozy Numbat

Thursday, May 07, 2009

A simple way with curl to post code snippet to ubuntu paste:


$ curl -v -d 'poster=chengrq&syntax=python' --data-urlencode 'content@/home/gektop/bin/diff-filter' http://paste.ubuntu.com
* About to connect() to paste.ubuntu.com port 80 (#0)
* Trying 91.189.90.174... connected
* Connected to paste.ubuntu.com (91.189.90.174) port 80 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8j zlib/1.2.3
> Host: paste.ubuntu.com
> Accept: */*
> Content-Length: 3002
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 302 Found
< Date: Fri, 08 May 2009 01:29:08 GMT
< Server: Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.8.8
< Location: /166435/
< Content-Length: 0
< Content-Type: text/html; charset=utf-8
<
* Connection #0 to host paste.ubuntu.com left intact
* Closing connection #0

I need a diff (or patch) manipulation utility, but unfortunately I have not found one, then I wrote one, of course, it's in Python.



#!/usr/bin/python

import sys, os

# Usage: diff-filter [-v] path1 path2 ...
# <INPUT >OUTPUT
if len(sys.argv) <= 1:

print "Usage: %s [-v] path1 path2 ... <INPUT" % \
os.path.basename(sys.argv[0])

sys.exit(1)

# some global variables
inChunk = True

strip = 1
matched = False
buffer = ''

invert = False

# to invert the filter
if sys.argv[1] == '-v':

invert = True
del sys.argv[1]

# the main filter
while True:
line = sys.stdin.readline()

if not line:
break

if line.startswith("--- ") or \
line.startswith("diff") or \
line.startswith("Binary") or \
line.startswith("Index"):

matched = False
inChunk = False

if line.startswith("diff") or \
line.startswith("Binary") or \
line.startswith("Index"):

buffer += line
continue
else:
path = line.split()[1]

slash = path.find('/')
path = path[slash+1:]

for arg in sys.argv[1:]:
if path.startswith(arg):

matched = True
break
else:
matched = False

if invert:
matched = not matched
if not matched:

buffer = ''

if inChunk:
print line,

if matched:
if buffer:
print buffer,

buffer = ''
print line,


It also can be reached by the ubuntu paste service:



http://paste.ubuntu.com/166435/

Application field: if you have a big diff generated by "diff -R", and want to split it according to some seperate path or components, you can use this. Happy hacking!