Wednesday, August 11, 2010

Java帝国的王储—Groovy !

让我们来回顾一下主流语言的发展历程:机器语言(由01组成)  汇编语言 → ... → C语言 → C++ → Java → ?

不知道大家有没有发现在语言发展过程中,存在这么一个规律:能成为未来主流语言的,必与当前主流语言属同一‘语系’,换句话说,由王子继承王位。

在C语言之前,似乎还处于‘春秋战国’,各种编程语言混战,于20世纪70年代,C语言成为‘秦始皇’,各种软件甚至操作系统也改用C语言编写。但可惜C语言是面向过程的,程序代码一多,逻辑流程就容易混乱,再加上全局变量和可运算指针的添乱,使程序员调试程序万般辛苦。

Tuesday, August 10, 2010

How to Repair a Crashed MySQL Table

Today, I had a server crash when the /var partition filled up while reindexing. I attempted to clear out extra log files and such but df was still showing greater than 100% utilization. Checking /var/db/mysql showed I had one table that was taking up too much space. du -d 1 -h is a very useful command when tracking down the largest folder usage on partition.
Jul 21 07:39:06 plab2catsg01 kernel: pid 36500 (mysqld), uid 88 inumber 329992 o
n /var: filesystem full
Jul 21 07:39:22 plab2catsg01 kernel: pid 36500 (mysqld), uid 88 inumber 353413 o
n /var: filesystem full
Jul 21 07:39:23 plab2catsg01 kernel: pid 36500 (mysqld), uid 88 inumber 353288 o
n /var: filesystem full

I attempted to stop MySQL by executing /usr/local/etc/rc.d/mysql-server stop and unfortunately, it kept looping while trying to stop the process. I was eventually forced to reboot the server.



On reboot, I thought all was well but then I found the Eventum application I use wasn't showing support emails. I checked the MySQL log files:


plab2catsg01# tail -f plab2catsg01.ten-net.net.err
...
090721 9:15:54 [ERROR] /usr/local/libexec/mysqld: Table './eventum/eventum_mail
_queue' is marked as crashed and last (automatic?) repair failed
090721 9:15:54 [ERROR] /usr/local/libexec/mysqld: Table './eventum/eventum_mail
_queue' is marked as crashed and last (automatic?) repair failed
090721 9:15:55 [ERROR] /usr/local/libexec/mysqld: Table './eventum/eventum_mail
_queue' is marked as crashed and last (automatic?) repair failed
090721 9:15:55 [ERROR] /usr/local/libexec/mysqld: Table './eventum/eventum_mail
_queue' is marked as crashed and last (automatic?) repair failed
...

Use MySQL Regexp Sample

[cc lang="mysql"]DELETE FROM `google_data` WHERE site_id=4 AND url REGEXP '\.php\\?matchid=[0-9]+$'[/cc]

森林“板房”

Monday, August 9, 2010

苹果

以前总觉得苹果的 macbook pro 非常好,觉得matetext是那么Cool。以致于自己都想买一台,可是当自己做为Linux的9年用户得时候,觉得macbook并不是那么神通广大。然而Iphone,也不是那么炫。不是还有Android吗?放弃封闭的,投奔开放吧。

极速 Twisted Web 60秒(4): 动态URL处理

[cc lang="python"]
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor

from calendar import calendar

class YearPage(Resource):
def __init__(self, year):
Resource.__init__(self)
self.year = year

def render_GET(self, request):
return "
%s
" % (calendar(self.year),)

class Calendar(Resource):
def getChild(self, name, request):
return YearPage(int(name))

root = Calendar()
factory = Site(root)
reactor.listenTCP(8880, factory)
reactor.run()
[/cc]

Friday, August 6, 2010

极速 Twisted Web 60秒(3): 静态URL处理

[cc lang="python"]
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.web.static import File

root = Resource()
root.putChild("foo", File("/tmp"))
root.putChild("bar", File("/lost+found"))
root.putChild("baz", File("/opt"))

factory = Site(root)
reactor.listenTCP(8880, factory)
reactor.run()
[/cc]