<?xml version="1.0" encoding="UTF-8" ?>
  <rss version="2.0">
    <channel>

<title>动态感觉  静观其变</title>
      <link>http://xlp223.ycool.com/</link>
      <description><![CDATA[]]></description>
      <pubDate>Fri, 05 Sep 2008 15:09:02 GMT</pubDate>
      <lastBuildDate>Fri, 05 Sep 2008 15:09:02 GMT</lastBuildDate>
      <image>
        <url>http://sta.yculblog.com/images/logo/general-88x31.gif</url>
        <title>动态感觉  静观其变</title>
        <link>http://xlp223.ycool.com/</link>
      </image>
<item>
        <title>打补丁编译要从头猜到尾</title>
        <link>http://xlp223.ycool.com/post.2138333.html</link>
        <description><![CDATA[<font size="3">打补丁的内容再不写，过段时间自己也要忘记了，还是抓紧时间记录下来。我在安装gobby时，发现archlinux更新后，gobby要用到的libgnutls.so.13这个库没有了，就想把它重新编译它，采用新的libgnutls库。结果编译的过程中发现了几个问题：<br />
<br />
1）gcc编译时报错<br />
<br />
报错的信息是std:memcpy，我猜想估计是gcc的版本，因为好久也没有用c/c++了，所以只能猜，到gobby的主站去看新的代码是怎么处理的，发现要增加<br />
<br />
#include &lt;cstring&gt;<br />
<br />
改了一个地方，又发现两个地方，都是如此，改了之后，再作make有发现了新问题。<br />
<br />
2）gnutls惹的祸<br />
<br />
编译通过，可是连接又总是报错，先开头总是没有想明白，gobby的makefile里没有指定gnutls的版本号啊，继续猜吧，它没有用到，可能就是依赖的包也依赖gnutls的老版本，接着发现gobby依赖的两个obby，net6依赖gnutls，就把这两个的PKGBUILD下载下来，重新打包安装。<br />
<br />
3）打补丁<br />
<br />
因为要让gobby的打包自动能进行，不要手工介入，我就分步骤试验打补丁过程，先想能不能用版本控制的hg，来作补丁，hg diff，patch文件倒是可以，但是发现有个问题，就是补丁和版本号连在一起。所以只能单独使用diff，<br />
<br />
a)把修改过的文件unix.cpp, header.cpp，preferencesdialog.cpp拷贝到gobby_patch/src/下<br />
<span class="content"><br />
b)diff -ud src/gobby-0.4.5/src/ gobby_patch/src |grep -v '^Only' &gt; gobby.patch<br />
<br />
c)patch -p1 &lt; gobby.patch<br />
<br />
4）改PKGBUILD<br />
<br />
完成上面3步，make成功了，然后就把第3步弄进PKGBUILD。<br />
<br />
<font size="2">pkgname=gobby<br />
pkgver=0.4.5<br />
pkgrel=1<br />
pkgdesc=&quot;A collaborative text editor&quot;<br />
arch=('i686' 'x86_64')<br />
url=&quot;http://gobby.0x539.de&quot;<br />
license=('GPL')<br />
depends=('obby' 'libxml++2' 'gtkmm' 'gtksourceview' 'gnome-vfs' 'libbonobo')<br />
makedepends=('gettext')<br />
source=(http://releases.0x539.de/gobby/gobby-$pkgver.tar.gz)<br />
#install=$pkgname.install<br />
<br />
build() {<br />
&nbsp; <font color="#ff0000">patch -p1 &lt; $startdir/gobby.patch</font><br />
&nbsp; cd $startdir/src/gobby-$pkgver<br />
&nbsp; ./configure --prefix=/usr --with-gnome<br />
&nbsp; make || return 1<br />
&nbsp; make DESTDIR=$startdir/pkg install<br />
&nbsp; #find -name gobby.desktop -exec sed -i &quot;s|Network|Office|&quot; {} \;<br />
&nbsp; install -D -m644 contrib/gobby.desktop \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $startdir/pkg/usr/share/applications/gobby.desktop<br />
&nbsp; #install -D -m644 contrib/artwork/gobby.png \<br />
&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $startdir/pkg/usr/share/pixmaps/gobby.png<br />
}<br />
</font><br />
这下就能自动进行打包了，makepkg -c，gobby的包自动生成。pacman -U 安装成功，运行成功。就连以前的一个错误，avahi的错，如今也没有了。<br />
<br />
gobby到底是什么？记得原先介绍过，是一款协同编辑器，远程多人编辑的好利器。<br />
<br />
5）把打包用的脚本也打包<br />
<br />
为了方便，把脚本打包tar zcvf gobby_patch.tar.gz --exclude='*.tar.gz'，排除掉已经打好包的文件。<br />
<font color="#ff0000"><br />
干了一圈，几乎都是在猜，原来打补丁，别的功夫弱点没关系，猜的功夫是要有的，呵呵！</font></span></font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2138333.html</guid>
        <pubDate>Fri, 05 Sep 2008 01:09:11 GMT</pubDate>

      </item>

      <item>
        <title>第一次打补丁编译打包</title>
        <link>http://xlp223.ycool.com/post.2137893.html</link>
        <description><![CDATA[<font size="3">昨天开始琢磨打补丁的事，因为在装gobby的时候，有些问题，libgnutls库不再是13版本，已经升级到了新版本，</font><font size="3">造成gobby, obby, net6都不能使用，因此重新编译obby,net6，对gobby因为gcc 4.3的缘故，要打一下补丁，</font><font size="3">所以pkgbuild要加入patch处理。<br />
<br />
具体细节，我有空详细写出。<font color="#ff0000">（待续）</font></font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2137893.html</guid>
        <pubDate>Thu, 04 Sep 2008 03:09:20 GMT</pubDate>

      </item>

      <item>
        <title>宣传archlinux</title>
        <link>http://xlp223.ycool.com/post.2136976.html</link>
        <description><![CDATA[<font size="3">archlinux是一个非常好的linux版本，我从2007年开始使用，到现在没有再换其他版本了。服务器和桌面，archlinux都比较适合。如今我安装eva，再加上openoffice，基本上可以用这个作单位上的事，不必切换回windows。为了更好的宣传archlinux，我会不定期 贴出一些我使用archlinux的截图。<br />
<br />
截图放在好看簿那，地址：<br />
<br />
<a href="http://www.haokanbu.com/story/106344/">http://www.haokanbu.com/story/106344/</a></font><br />
<font size="3"><br />
上次几个朋友聚会，弄过一个介绍archlinux的幻灯，<br />
<br />
<a href="http://www.haokanbu.com/story/106462/">http://www.haokanbu.com/story/106462/</a><br />
<br />
内容会陆续放上去。<br />
<br />
对archlinux，只想让更多的朋友认识到它，并开始使用它。对它和其他的版本的比较，我不会去比较，个人使用之后自有心得。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2136976.html</guid>
        <pubDate>Tue, 02 Sep 2008 09:09:45 GMT</pubDate>

      </item>

      <item>
        <title>与孩子一起写作文</title>
        <link>http://xlp223.ycool.com/post.2136695.html</link>
        <description><![CDATA[<font size="3">昨晚</font><font size="3">cctv2有个节目，学校要求孩子观看，并要写出观后感，这个节目就是《<a href="http://fifid.com/search/%E5%BC%80%E5%AD%A6%E7%AC%AC%E4%B8%80%E8%AF%BE?src=yb_qsal&utm_source=yb_qsal&utm_medium=link&utm_content=rsspost" target="_blank">开学第一课</a>》。节目主题是汶川大地震和北京奥运。电视看完之后，孩子开始写作文了，四年级的新生，要她写观后感，实在是有些勉为其难。大概写了一个多小时，我进去看了看她写的内容，感觉还是要改改，孩子毕竟是孩子，还没有那么好的构思，组织的能力。我就和她一起来写，我就按我的思绪写，顺着我的思绪，我开始慢慢的说，以一种散文诗的形式来走。<br />
<br />
我边想边说，她也时不时的参与进来，慢慢的她的思路也往我的思路上靠，而且带给我几个惊喜。实际上她的用词比我还要好，她仅仅是不知道用什么题材和形式来表达。我印象最深的至少有3个地方，一个是题目，我起的题目是学会坚强，学会快乐。她最后把这个题目改了，而且没有和我讲，后来她一说，我拍手叫好。她改成了《<a href="http://fifid.com/search/%E6%88%91%E5%9D%9A%E5%BC%BA%EF%BC%8C%E6%88%91%E5%BF%AB%E4%B9%90?src=yb_qsal&utm_source=yb_qsal&utm_medium=link&utm_content=rsspost" target="_blank">我坚强，我快乐</a>》，这改的就是小孩的味道了，太棒了。第二个，不记得是哪个地方，我想表现节目中的小朋友高兴的样子，但是我一下子想不出来，她却随口而出，&ldquo;台上的小朋友的脸上挂满了微笑&rdquo;，好，好，我立刻说好。第三个地方是我的思绪停留在《<a href="http://fifid.com/search/%E6%88%91%E5%92%8C%E4%BD%A0?src=yb_qsal&utm_source=yb_qsal&utm_medium=link&utm_content=rsspost" target="_blank">我和你</a>》的主题歌的歌词上，想着换种说法，我把心连心，改成了&ldquo;我们和他们心永远连在一起&rdquo;，可下面还想用一个&ldquo;永远&rdquo;的句子，可一直想不起来，就随口唱起来歌曲，孩子也和我一起唱，当唱到&ldquo;来吧，朋友，伸出你的手&rdquo;，她马上说出了一句话&ldquo;我们和他们手永远牵在一起&rdquo;，哎呀，真是太好了。<br />
<br />
孩子的思维比我快，比我想的好，他们的潜能是巨大的。欠缺的仅仅是组织和构思，他们的表达是我无法比及的，我喜欢和她这样一起上课，一起写作文，我也学到了很多，很多。。。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2136695.html</guid>
        <pubDate>Mon, 01 Sep 2008 23:09:41 GMT</pubDate>

      </item>

      <item>
        <title>让eva开始运行</title>
        <link>http://xlp223.ycool.com/post.2135523.html</link>
        <description><![CDATA[<font size="3">一直都不太用qq，没办法，工作上要用，而现在基本都是用archlinux，不想用回win去。所以想在archlinux上用eva。eva听说是一款比较好用的linux版本qq。至少tencent的linux qq效果不怎么的。<br />
<br />
折腾了几日，终于在archlinux上安装好了eva。主要折腾的原因在于archlinux已经转向kde 4，保留的kde 3，有些包没有。幸好有archlinux fans自己作了一个比较完备的kde 3，同时eva论坛上，云帆做了archlinux gcc 4.3的补丁。<br />
<br />
1) 设定kde 3源<br />
</font>   <br />
<font size="3">见http://bbs.archlinux.org/viewtopic.php?pid=412190，在/etc/pacman.conf中[extra]之前，加入</font><br />
<br />
[kde3]<br />
Server = http://csclub.uwaterloo.ca/~jkschmid/arch/kde3/i686<br />
<br />
<font size="3">2）安装kde 3</font><br />
<br />
pacman -Sy kdelibs3<br />
<font size="3"><br />
3）下载eva源码和补丁</font>，<font size="3">这是由云帆论坛提供</font><br />
<br />
pkgname=eva<br />
pkgver=20080127_1<br />
pkgrel=1<br />
arch=('i686' 'x86_64')<br />
pkgdesc=&quot;QQ protocol instant messaging client for KDE.&quot;<br />
url=&quot;http://sourceforge.net/projects/evaq&quot;<br />
license=&quot;GPL&quot;<br />
depends=('kdelibs3' 'qt3')<br />
makedepends=('pkgconfig' 'make')<br />
source=(http://www.myswear.net/myswear/eva/beta/$pkgname-$pkgver.tar.bz2)<br />
md5sums=('567cac84576442101f25ffe01b208cd3')<br />
<br />
build() {<br />
&nbsp;&nbsp;&nbsp;  cd $startdir/src/$pkgname<br />
&nbsp;&nbsp;&nbsp;  echo $startdir<br />
&nbsp;&nbsp;&nbsp;  patch -p1 &lt; $startdir/eva_patch<br />
&nbsp;&nbsp;&nbsp;  ./configure --prefix=`kde-config --prefix`<br />
&nbsp;&nbsp;&nbsp;  make || return 1<br />
&nbsp;&nbsp;&nbsp;  make DESTDIR=$startdir/pkg install<br />
}<br />
<br />
<font size="3">把depends中kdelibs改成kdelibs3, 注意看其中有个patch，这个补丁是支持gcc 4.3的<br />
<br />
4）编译打包安装<br />
<br />
makepkg -c<br />
<br />
pacman -U eva****<br />
<br />
5）重新启动<br />
<br />
因为在/etc/profile.d中有kde3.sh, qt3.sh，所以重新启动后，相关环境可以配置好。<br />
<br />
6）启动eva<br />
<br />
如果字体觉得不爽，那就修改在主目录下~/.kde/share/config/kdeglobals</font>    <br />
<br />
[General]<br />
StandardFont=WenQuanYi Bitmap Song,10,-1,5,50,0,0,0,0,0<br />
XftHintStyle=hintfull<br />
activeFont=WenQuanYi Bitmap Song,10,-1,5,75,0,0,0,0,0<br />
fixed=DejaVu Sans Mono,10,-1,5,50,0,0,0,0,0<br />
font=WenQuanYi Bitmap Song,10,-1,5,50,0,0,0,0,0<br />
menuFont=WenQuanYi Bitmap Song,10,-1,5,50,0,0,0,0,0<br />
taskbarFont=WenQuanYi Bitmap Song,10,-1,5,50,0,0,0,0,0<br />
toolBarFont=WenQuanYi Bitmap Song,10,-1,5,50,0,0,0,0,0<br />
<br />
<font size="3">使用文泉驿的字体。<br />
<br />
运行eva之后，这下就好看多了，明天可以到单位上用archlinux的qq了。。。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2135523.html</guid>
        <pubDate>Sun, 31 Aug 2008 12:08:06 GMT</pubDate>

      </item>

      <item>
        <title>archlinux后台程序</title>
        <link>http://xlp223.ycool.com/post.2134188.html</link>
        <description><![CDATA[<font size="3">archlinux用了这么久，一直也懒，没有管它后台服务的处理，今天抽了一个时间编写了一下django的后台，启动fastcgi，和nginx一起使用。下面我就把这个服务贴出来，我也是依照其他的daemon的形式模仿写的，效果一样，呵呵。<br />
<br />
<font size="2">#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
PROJECT=&quot;/home/hzg/work/fx_analysis&quot;<br />
PIDFILE=&quot;$PROJECT/log/mysite.pid&quot;<br />
<br />
PID=`cat $PIDFILE 2&gt;/dev/null`<br />
<br />
case &quot;&quot; in<br />
&nbsp; start)<br />
&nbsp;&nbsp;&nbsp; stat_busy &quot;Starting Django Project fx_analysis Daemon&quot;<br />
&nbsp;&nbsp;&nbsp; cd $PROJECT<br />
<br />
&nbsp;&nbsp;&nbsp; if [ -f $PIDFILE ]; then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kill -9 `cat -- $PIDFILE` &gt; /dev/null 2&gt;&amp;1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm -f -- $PIDFILE<br />
&nbsp;&nbsp;&nbsp; fi<br />
<br />
&nbsp;&nbsp;&nbsp; su - hzg&nbsp; -c &quot;source /home/hzg/mypy/bin/activate; cd $PROJECT; python ./manage.py runfcgi host=127.0.0.1 port=8000 pidfile=$PIDFILE --settings=settings&quot;<br />
<br />
&nbsp;&nbsp;&nbsp; if [ $? -gt 0 ]; then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stat_fail<br />
&nbsp;&nbsp;&nbsp; else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add_daemon start_dj.sh<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stat_done<br />
&nbsp;&nbsp;&nbsp; fi<br />
&nbsp;&nbsp;&nbsp; ;;<br />
&nbsp; stop)<br />
&nbsp;&nbsp;&nbsp; stat_busy &quot;Stopping Django Project fx_analysis Daemon&quot;<br />
&nbsp;&nbsp;&nbsp; [ ! -z &quot;$PID&quot; ] &amp;&amp; kill $PID &amp;&gt; /dev/null<br />
&nbsp;&nbsp;&nbsp; if [ $? -gt 0 ]; then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stat_fail<br />
&nbsp;&nbsp;&nbsp; else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm_daemon start_dj.sh<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stat_done<br />
&nbsp;&nbsp;&nbsp; fi<br />
&nbsp;&nbsp;&nbsp; ;;<br />
&nbsp; restart)<br />
&nbsp;&nbsp;&nbsp; {post.abstract} stop<br />
&nbsp;&nbsp;&nbsp; sleep 1<br />
&nbsp;&nbsp;&nbsp; {post.abstract} start<br />
&nbsp;&nbsp;&nbsp; ;;<br />
&nbsp; *)<br />
&nbsp;&nbsp;&nbsp; echo &quot;usage: {post.abstract} {start|stop|restart}&quot;&nbsp; <br />
esac<br />
exit 0<br />
<br />
<font size="3">写完之后，把它放到/etc/rc.d/这个目录下去，在/etc/rc.conf中加入daemon={ ... start_dj.sh ...}，开机就能以其他用户，和virtualenv本地的python环境，运行django project了，不用手动，全走自动。<br />
<br />
应dotyao的要求，要用nginx用户来运行，我用了su -s的选项，临时给一个shell出来，把相应的目录权限调整成nginx的权限就可以了。<br />
<br />
</font></font></font><font size="3"><font size="2">su - nginx -s /bin/bash&nbsp; -c &quot;source /home/hzg/mypy/bin/activate; cd $PROJECT; python ./manage.py runfcgi host=127.0.0.1 port=8000 pidfile=$PIDFILE --settings=settings&quot;</font></font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2134188.html</guid>
        <pubDate>Fri, 29 Aug 2008 01:08:42 GMT</pubDate>

      </item>

      <item>
        <title>usb无线网卡</title>
        <link>http://xlp223.ycool.com/post.2114331.html</link>
        <description><![CDATA[<font size="3"><font color="#ff6600">注：突然发现似乎新版的kernel可以直接使用rt73usb，有空再看看自带的驱动，有可能和</font></font><font size="3" color="#ff6600"><font size="2">rt2x00-rt71w-fw</font></font><font size="3"><font color="#ff6600">有关。<br />
<br />
</font>zengsun想在archlinux中使用tp-link的tl-wn321g+的usb无线网卡，说是碰到了问题。正好我手头有一个这个，就自己来试试。结果是有些问题，只好到官方论坛上去查一些帖子看看，结果有这方面问题的不少。自己就琢磨着用源码来安装了，正好自己也看看archlinux的包是怎么个弄法。参考了一下aur中的rt73-cvs的包（这是有点老了，而且是用cvs），我就按照直接下载包的方式改了改。有两个文件：<br />
一个是PKGBUILD，另一个是rt73.install<br />
<br />
PKGBUILD==&gt;<br />
<br />
<font size="2">pkgname=rt73-cvs<br />
pkgver=daily<br />
pkgrel=1<br />
pkgdesc=&quot;RaLink RT73 USB Drivers&quot;<br />
arch=('i686' 'x86_64')<br />
url=&quot;http://rt2x00.serialmonkey.com/wiki/index.php?title=Downloads&quot;<br />
license=('GPL')<br />
depends=('kernel26', 'rt2x00-rt71w-fw')<br />
provides=('rt73-test')<br />
conflicts=('rt73-test')<br />
install=rt73.install<br />
source=(http://rt2x00.serialmonkey.com/$pkgname-$pkgver.tar.gz)<br />
md5sums=('')<br />
&nbsp;&nbsp;&nbsp; &nbsp;<br />
_kernver=2.6.25-ARCH<br />
<br />
build() {<br />
&nbsp;&nbsp;&nbsp; cd $startdir/src/$pkgname-2008072820/Module<br />
&nbsp;&nbsp;&nbsp; make || return 1<br />
&nbsp;&nbsp;&nbsp; install -Dm644 rt73.ko $startdir/pkg/lib/modules/$_kernver/kernel/drivers/net/wireless/rt73.ko || return 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg &quot;Drivers installed, but not loaded. To enable it: 'rmmod rt73usb &amp;&amp; modprobe rt73'&quot;<br />
&nbsp;&nbsp;&nbsp; msg &quot;Or use airdriver-ng, you can install it from AUR: 'aicrack-ng-svn'&quot;<br />
}<br />
<font size="3"><br />
rt73.install:==&gt;<br />
<br />
<font size="2">post_install() {<br />
depmod -a<br />
cat &lt;&lt; EOF<br />
&gt;&gt;&gt;<br />
&gt;&gt;&gt; Documentation is seperated it's called rt73-cvs-doc.<br />
&gt;&gt;&gt; Install it to learn how to use WPA and more.<br />
&gt;&gt;&gt;<br />
&gt;&gt;&gt; Kernel 2.6.25 provides rt2x00 drivers, so if you want to use rt73 must<br />
&gt;&gt;&gt; add 'rt73usb' to your MOD_BLACKLIST=() at /etc/rc.conf<br />
&gt;&gt;&gt;<br />
EOF<br />
}<br />
<br />
post_upgrade() {<br />
post_install <br />
}<br />
<br />
post_remove() {<br />
/bin/true<br />
}<br />
<br />
<font size="3">打包之前要先安装abs和fakeroot，</font></font></font></font></font><font size="3"><font size="2">rt2x00-rt71w-fw</font></font><font size="3"><font size="2"><font size="3"><font size="2"><font size="3">，然后makepkg -c，打好包之后，pacman -U 安装即可。<br />
<br />
包安装好之后，在/etc/rc.conf中，在MOD_BACKLISTS里加入rt73usb和rt2500usb，这样启动之后就不会把这两个模块加载了。<br />
<br />
插上usb的无线网卡，modprobe rt73，就可以找到硬件了，用ifconfig -a，可以看到wlan0的界面了，接下去配置就是了。<br />
</font></font></font></font> </font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2114331.html</guid>
        <pubDate>Tue, 29 Jul 2008 01:07:28 GMT</pubDate>

      </item>

      <item>
        <title>不算短的sql</title>
        <link>http://xlp223.ycool.com/post.2099492.html</link>
        <description><![CDATA[<font size="3">兑现昨晚的说法，公布自己瞎弄的sql，算是歪打正着吧。看看这个sql，你要觉得怪异，尽管说：<br />
1）<br />
select dy.jh, dy.jm, dy.lze as dylze, coalesce(ls.lze,0.00) as lslze, coalesce(dy.lze,0.00)+coalesce(ls.lze,0.00) as lze from <br />
&nbsp; (select d.jh, d.jm, e.lze from nps_dxj as d left join (select c.sdxzqh as sdxzqh, sum(c.pdssk) as pdlze, sum(c.zdssk) as zdlze,<br />
&nbsp;&nbsp; sum(c.zdssk+c.pdssk) as lze<br />
&nbsp;&nbsp; from nps_card as c, nps_bkml as b <br />
where c.yxn=2008<br />
&nbsp;&nbsp; and c.jyr&gt;='20070701' and c.jyr&lt;='20080701'<br />
&nbsp;&nbsp; and c.bkdh='33-2' and c.dyfw='本地' and c.dylx!='零售'<br />
&nbsp;&nbsp; and b.nd=2008 and b.bkdh='33-2'<br />
&nbsp;&nbsp; group by c.sdxzqh<br />
&nbsp;&nbsp; order by c.sdxzqh) as e on d.jh=e.sdxzqh) as dy,<br />
<br />
&nbsp; (select d.jh, d.jm, e.lze from nps_dxj as d left join (select c.sdxzqh as sdxzqh, sum(c.pdssk) as pdlze, sum(c.zdssk) as zdlze,<br />
&nbsp;&nbsp;&nbsp;&nbsp; sum(c.zdssk+c.pdssk) as lze<br />
&nbsp;&nbsp; from nps_card as c, nps_bkml as b <br />
where c.yxn=2008<br />
&nbsp;&nbsp; and c.jyr&gt;='20070701' and c.jyr&lt;='20080701'<br />
&nbsp;&nbsp; and c.bkdh='33-2' and c.dyfw='本地' and c.dylx='零售'<br />
&nbsp;&nbsp; and b.nd=2008 and b.bkdh='33-2'<br />
&nbsp;&nbsp; group by c.sdxzqh<br />
&nbsp;&nbsp; order by c.sdxzqh) as e on d.jh=e.sdxzqh) as ls<br />
where dy.jh=ls.jh;<br />
<br />
2）<br />
select dy.dqh, sum(coalesce(dy.lze,0.00)) as dylze, sum(coalesce(ls.lze,0.00)) as lslze, sum(coalesce(dy.lze,0.00)+coalesce(ls.lze,0.00)) as lze from <br />
&nbsp; (select d.jh, d.dqh, d.jm, e.lze from nps_dxj as d left join (select c.sdxzqh as sdxzqh, sum(c.zdssk+c.pdssk) as lze<br />
&nbsp;&nbsp; from nps_card as c, nps_tjlx as t<br />
where c.yxn=2008<br />
&nbsp;&nbsp; and c.bkdh = t.bkdh<br />
&nbsp;&nbsp; and c.jyr&gt;='20071201' and c.jyr&lt;='20071210'<br />
&nbsp;&nbsp; and c.clbz!='变动' and c.dyfw='本地' and c.dylx!='零售'<br />
&nbsp;&nbsp; and t.nd=2008 and t.bkfl='畅销及潜力'<br />
&nbsp;&nbsp; group by c.sdxzqh<br />
&nbsp;&nbsp; order by c.sdxzqh) as e on d.jh=e.sdxzqh) as dy,<br />
<br />
&nbsp; (select d.jh, d.dqh, d.jm, e.lze from nps_dxj as d left join (select c.sdxzqh as sdxzqh, sum(c.zdssk+c.pdssk) as lze<br />
&nbsp;&nbsp; from nps_card as c, nps_tjlx as t<br />
where c.yxn=2008<br />
&nbsp;&nbsp; and c.bkdh = t.bkdh<br />
&nbsp;&nbsp; and c.jyr&gt;='20071201' and c.jyr&lt;='20071210'<br />
&nbsp;&nbsp; and c.clbz!='变动' and c.dyfw='本地' and c.dylx='零售'<br />
&nbsp;&nbsp; and t.nd=2008 and t.bkfl='畅销及潜力'<br />
&nbsp;&nbsp; group by c.sdxzqh<br />
&nbsp;&nbsp; order by c.sdxzqh) as e on d.jh=e.sdxzqh) as ls<br />
where dy.jh=ls.jh<br />
group by dy.dqh<br />
order by dy.dqh;<br />
</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2099492.html</guid>
        <pubDate>Fri, 04 Jul 2008 00:07:40 GMT</pubDate>

      </item>

      <item>
        <title>sql到底要多长</title>
        <link>http://xlp223.ycool.com/post.2099363.html</link>
        <description><![CDATA[<font size="3">sql到底要写成怎样才能晕？我一直都在门外，努力不让自己被sql弄晕，可是最近几天要处理一些数据，必须要把一些数据分开处理，终于写了一个超长的sql，可能对别人来说是超短的了，因为曾经有人说写了200行的sql，而我的只有20多行而已，可已经弄的有点吓人了，都不知道自己是怎样就把它写成了，明天我将公布这些sql，猜猜我能写成什么样吧。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2099363.html</guid>
        <pubDate>Thu, 03 Jul 2008 15:07:42 GMT</pubDate>

      </item>

      <item>
        <title>功夫熊猫见功夫</title>
        <link>http://xlp223.ycool.com/post.2096957.html</link>
        <description><![CDATA[<font size="3">今天带着小孩去看了电影《<a href="http://fifid.com/search/%E5%8A%9F%E5%A4%AB%E7%86%8A%E7%8C%AB?src=yb_qsal&utm_source=yb_qsal&utm_medium=link&utm_content=rsspost" target="_blank">功夫熊猫</a>》，看完之后，我的思绪还停留在这个电影的人物，情节中，颇有感触，试着对小孩提出了几个问题，让她去想想，让我也想想，有空自由讨论一番，回到家也给其他人大力推荐了一番。<br />
<br />
1. 为什么神龙秘笈是无字的书，却不让大龙看？<br />
<br />
2. 为什么熊猫看了神龙秘笈能悟到，大龙也看到了无字之书却悟不到？<br />
<br />
3. 熊猫能学到功夫是什么原因？ 大龙那么大的本领又是什么原因？ 两者有什么不同？<br />
<br />
确实要记录，中午思绪还停留在电影中，所以当时给小孩提的问题，现在都想不全了。</font><br />
<br />
<font size="3">我想这个片子很多元素实际上中国的很多故事都有，但它用一种电影、动画的艺术形式表现出来了，同时在电影院里看，思考的成分也沉浸其中。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2096957.html</guid>
        <pubDate>Sun, 29 Jun 2008 11:06:20 GMT</pubDate>

      </item>

      <item>
        <title>自制ftp server</title>
        <link>http://xlp223.ycool.com/post.2082465.html</link>
        <description><![CDATA[<font size="3">不知道为什么总是会碰到一些问题？filezilla server安装在windows xp上有个问题，经常会第一次连接挂死。抽空换了它，最近看到一个python ftpd的库，很有意思，非常小，是异步方式的，我想对我来说足够了，我把它做成windows service，让它自动运行起来，不用管它了。<br />
<br />
http://code.google.com/p/pyftpdlib/<br />
<br />
文档都不错，还有例子，我就照搬了，然后把windows service的套上去：<br />
<br />
</font><font size="2">            import win32serviceutil<br id="v3co0" />
import win32service<br id="v3co1" />
import win32event<br id="v3co4" />
<br id="v3co5" />
from pyftpdlib import ftpserver<br id="v3co6" />
<br id="v3co7" />
FTP_USER = 'nps_card'<br id="v3co8" />
FTP_PASS = 'nps_card'<br id="v3co9" />
HOME_DIR='d:\nps_data\'<br id="v3co10" />
<br id="v3co11" />
class MyFtpd(object):<br id="v3co12" />
&nbsp;&nbsp;&nbsp; def __init__(self):<br id="v3co13" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd = None<br id="v3co14" />
<br id="v3co15" />
&nbsp;&nbsp;&nbsp; def main(self):<br id="v3co16" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Instantiate a dummy authorizer for managing 'virtual' users<br id="v3co17" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorizer = ftpserver.DummyAuthorizer()<br id="v3co18" />
<br id="v3co19" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Define a new user having full r/w permissions and a read-only<br id="v3co20" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # anonymous user<br id="v3co21" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorizer.add_user(FTP_USER, FTP_PASS, HOME_DIR, perm='elradfmw')<br id="v3co22" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorizer.add_anonymous(HOME_DIR)<br id="v3co23" />
<br id="v3co24" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Instantiate FTP handler class<br id="v3co25" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ftp_handler = ftpserver.FTPHandler<br id="v3co26" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ftp_handler.authorizer = authorizer<br id="v3co27" />
<br id="v3co28" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Define a customized banner (string returned when client connects)<br id="v3co29" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ftp_handler.banner = &quot;pyftpdlib %s based ftpd ready.&quot; %ftpserver.__ver__<br id="v3co35" />
<br id="v3co36" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Instantiate FTP server class and listen to 0.0.0.0:21<br id="v3co37" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address = ('', 21)<br id="v3co38" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd = ftpserver.FTPServer(address, ftp_handler)<br id="v3co39" />
<br id="v3co40" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # set a limit for connections<br id="v3co41" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd.max_cons = 256<br id="v3co42" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd.max_cons_per_ip = 5<br id="v3co43" />
<br id="v3co44" />
&nbsp;&nbsp;&nbsp; def start(self):<br id="v3co45" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # start ftp server<br id="v3co46" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd.serve_forever()<br id="v3co47" />
<br id="v3co48" />
&nbsp;&nbsp;&nbsp; def stop(self):<br id="v3co49" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ftpd.close_all()<br id="v3co50" />
<br id="v3co51" />
class MyService(win32serviceutil.ServiceFramework):<br id="v3co52" />
&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;NT Service.&quot;&quot;&quot;<br id="v3co53" />
&nbsp;&nbsp; &nbsp;<br id="v3co54" />
&nbsp;&nbsp;&nbsp; _svc_name_ = &quot;PyFtpService&quot;<br id="v3co55" />
&nbsp;&nbsp;&nbsp; _svc_display_name_ = &quot;Py Ftp Service&quot;<br id="v3co56" />
<br id="v3co57" />
&nbsp;&nbsp;&nbsp; def __init__(self, args):<br id="v3co58" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; win32serviceutil.ServiceFramework.__init__(self, args)<br id="v3co59" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # create an event that SvcDoRun can wait on and SvcStop<br id="v3co60" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # can set.<br id="v3co61" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stop_event = win32event.CreateEvent(None, 0, 0, None)<br id="v3co62" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.myftpd = MyFtpd() <br id="v3co63" />
<br id="v3co64" />
&nbsp;&nbsp;&nbsp; def SvcDoRun(self):<br id="v3co65" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.myftpd.main()<br id="v3co66" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.myftpd.start()<br id="v3co67" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # now, block until our event is set...<br id="v3co68" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE)<br id="v3co69" />
&nbsp;&nbsp;&nbsp; <br id="v3co70" />
&nbsp;&nbsp;&nbsp; def SvcStop(self):<br id="v3co71" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)<br id="v3co72" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.myftpd.stop()<br id="v3co73" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; win32event.SetEvent(self.stop_event)<br id="v3co74" />
<br id="v3co75" />
if __name__ == '__main__':<br id="v3co76" />
&nbsp;&nbsp;&nbsp; win32serviceutil.HandleCommandLine(MyService)<br />
<br />
<br />
</font><font size="3">然后用另外一个ftp client的库，ftputil，<br />
<br />
http://ftputil.sschwarzer.net/trac<br />
<br />
随后，做好server，放到实际环境下实验，结果发现还是存在问题，估计就是外网和内网之间的互联互通上的防火墙的问题，也会造成没有响应，后来发现去掉service，server端看日志，发现server并没有退出，但是不响应，看看例子上的代码，有个地方我删除了，有可能就是nat的问题，加上：<br />
<br />
ftp_handler.masquerade_address = '10.146.x.188'<br />
<br />
passive_ports的范围，似乎nat也做了限制，我不规定范围了。<br />
<br />
代码改好之后，好像还是有点问题，还是有点晕，谁了解这些，可以和我说说么？期待有人和我说说。。。</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2082465.html</guid>
        <pubDate>Fri, 06 Jun 2008 06:06:07 GMT</pubDate>

      </item>

      <item>
        <title>自动部署的小利器</title>
        <link>http://xlp223.ycool.com/post.2080696.html</link>
        <description><![CDATA[<font size="3">开发用的机器做好程序后，要部署到服务端，一般手动的过程都是打包，上传，解包，重启服务等步骤，在ruby社区有个capistrano，就是自动部署用的，虽说可以独立使用，但是它的文档有一半的篇幅和ror有关，另外独立使用的文档偏少，而我现在也不怎么用ruby。所以就找了一下python社区中有无相关的工具。<br />
<br />
还真有人作了一个包，我试了试，感觉还挺简单，也就是那几个动作，作一次就会。它的地址是：<br />
http://www.nongnu.org/fab/index.html<br />
<br />
我在archlinux下安装，碰到了一些问题，需要修改几个地方：<br />
1）os.getlogin()，在gnome界面下使用，会报错，用pwd.getpwid(os.getuid())[0]来代替<br />
2）fab的程序中，exit(1)之类的，要改成sys.exit(1)<br />
<br />
保证程序不错后，还要保证paramiko这个包先安装，这个包是ssh用的，然后python setup.py install安装。<br />
<br />
使用fabric，就是简单的写fabfile文件，文件就是py文件，内容就是几个简单的函数和变量：<br />
1）变量<br />
set(<br />
&nbsp; fab_hosts = ['172.16.7.13'],<br />
&nbsp; fab_user = 'hzg'<br />
)<br />
fab_hosts是远端服务器ip，fab_user是ssh的用户<br />
<br />
2）函数<br />
def deploy():<br />
&nbsp; &quot;Build the project and deploy it to a specified environment.&quot;<br />
&nbsp; local(&quot;tar zcvf fx_analysis.tar.gz fx_analysis --exclude='*.XLS'&quot;)<br />
&nbsp; put(&quot;fx_analysis.tar.gz&quot;, &quot;/home/hzg/work/fx_analysis.tar.gz&quot;)<br />
&nbsp; run(&quot;cd /home/hzg/work/; tar zxvf fx_analysis.tar.gz&quot;)<br />
<br />
deploy函数，由fab来调用，其中它又调用了几个：<br />
local()=&gt;本地机器运行<br />
put()=&gt;上传文件到远端服务器<br />
run()=&gt;在远端服务器运行<br />
<br />
还有一些：<br />
send(), download, sudo()等之类，都很简单明了<br />
<br />
3）使用方法<br />
很简单，就一个fab，运行fab，自动会去找fabfile，deploy会显示出来。<br />
要运行deploy的步骤，也很简单，fab deploy就可以了<br />
<br />
(mypy)[hzg@myhost work]$ fab<br />
&nbsp;&nbsp; Fabric v. 0.0.5, Copyright (C) 2008 Christian Vest Hansen.<br />
&nbsp;&nbsp; Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab warranty'.<br />
&nbsp;&nbsp; This is free software, and you are welcome to redistribute it<br />
&nbsp;&nbsp; under certain conditions; type `fab license' for details.<br />
<br />
No commands given.<br />
Available commands are:<br />
&nbsp;&nbsp; deploy&nbsp;&nbsp; : Build the project and deploy it to a specified environment.<br />
&nbsp;&nbsp; help&nbsp;&nbsp;&nbsp;&nbsp; : Display Fabric usage help, or help for a given command.<br />
&nbsp;&nbsp; license&nbsp; : Display the Fabric distribution license text.<br />
&nbsp;&nbsp; list&nbsp;&nbsp;&nbsp;&nbsp; : Display a list of commands with descriptions.<br />
&nbsp;&nbsp; set&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Set a Fabric variable.<br />
&nbsp;&nbsp; shell&nbsp;&nbsp;&nbsp; : Start an interactive shell connection to the specified hosts.<br />
&nbsp;&nbsp; warranty : Display warranty information for the Fabric software.<br />
Done.<br />
<br />
(mypy)[hzg@myhost work]$ fab deploy<br />
<br />
这样就能自动远程部署了，当然可能功能上没有capistrano多，不过已经足够了。<br />
</font>...
]]></description>
        <guid isPermaLink="true">http://xlp223.ycool.com/post.2080696.html</guid>
        <pubDate>Tue, 03 Jun 2008 07:06:11 GMT</pubDate>

      </item>
    </channel>
  </rss>
