<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>嘻嘻哈哈的部落格(blog) &#187; tips</title>
	<atom:link href="http://www.haw-haw.org/taxonomy/tags/tips/feed" rel="self" type="application/rss+xml" />
	<link>http://www.haw-haw.org</link>
	<description>天天部落格，天天向上</description>
	<lastBuildDate>Thu, 05 Jan 2012 08:26:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>一个匹配质数的perl正则表达式的分析</title>
		<link>http://www.haw-haw.org/post/1883</link>
		<comments>http://www.haw-haw.org/post/1883#comments</comments>
		<pubDate>Thu, 05 Jan 2012 07:14:31 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[prime number]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1883</guid>
		<description><![CDATA[　　网上有个牛人老外，用perl写了个匹配质数的正则表达式，就像这样： perl -lne '(1x$_) =~ /^1?$&#124;^(11+?)\1+$/ &#124;&#124; print &#34;$_ is prime&#34;' ，这是个交互式的东东，运行后得你手工输入数值，脚本判断是否是质数，是就打印说啥啥是质数。这句简单的代码我仔细分析了下，终于大概弄懂了。首先，是把你输入的数，转换成输入数值个１的字串，然后进行匹配，匹配不上，则输入的数为质数。匹配的正则表达式又是两个表达式的合集(两个表达式是或的关系)。 　　第一个正则匹配表达式很简单：“ ^1?$ ”，就是用来匹配０个或１个”1&#8243;，也就是这两个数(0和１不是质数)，关键在于第二个正则表达式： ^&#40;11+?&#41;\1+$ ，显然3(字串是111)、5(字串是11111)匹配不了，是质数；４(爱传是1111)和6(字串是111111)能匹配上，是合数。至于其中寻找质数的逻辑，我也大概弄明白了，比如说，数字7，字串是1111111，匹配11(11)+匹配不了，尝试111(111)+也不行，1111(1111)+也不行，所以是质数；同理，数字９，字串是111111111，匹配11(11)+匹配不上，但是匹配111(111)+可以，所以9是质数。 相关文章2011-09-14 -- apache里用cgi方式执行perl程序，其CGI模块会影响apache的charset (0)2011-09-13 -- 关于rackmonkey的支持中文 (0)2010-11-27 -- 改了一个nagios plugin:check_mem.pl (0)2010-05-31 -- 用perl模块儿HTML::TreeBuilder::XPath从网页上抓数据 (0)2010-04-20 -- 强制CGIProxy支持SSL (0)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1883/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>好东西vyatta，可以用来做内网上网的网关</title>
		<link>http://www.haw-haw.org/post/1879</link>
		<comments>http://www.haw-haw.org/post/1879#comments</comments>
		<pubDate>Sun, 01 Jan 2012 09:51:38 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1879</guid>
		<description><![CDATA[官网在这里 或者是用来做各个idc之间打洞。 先mark一下， 以后有空应用时再来详细研究研究。 没有相关文章。下面是随机文章2006-12-04 -- 一个巨酷的站点http://youos.com (0)2008-04-11 -- 搜狗输入法新版本3.3预览版发布，欢迎大家试用！ (0)2007-07-17 -- apache的NameVirtualHost参数导致的问题 (0)2006-01-12 -- 一个好的学习站点：IBM developerWorks (0)2008-07-22 -- oom-killer on Fedora Core 3 (3)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1879/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow in your teminal(圣诞礼物：终端上下雪)</title>
		<link>http://www.haw-haw.org/post/1876</link>
		<comments>http://www.haw-haw.org/post/1876#comments</comments>
		<pubDate>Sun, 25 Dec 2011 03:59:23 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[snow]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1876</guid>
		<description><![CDATA[原文来自：http://climagic.org/coolstuff/let-it-snow.html 第一段脚本： clear while : do echo $LINES $COLUMNS $&#40;&#40;$RANDOM%$COLUMNS&#41;&#41; sleep 0.1 done &#124; gawk '{ a[$3]=0 for(x in a) { o=a[x] a[x]=a[x]+1 printf &#34;\033[%s;%sH &#34;,o,x printf &#34;\033[%s;%sH*\033[0;0H&#34;,a[x],x } }' 执行上面这段脚本之前，需要手工设置COLUMNS LINES或执行： export COLUMNS LINES 第二段脚本： &#160; 原文来自：http://climagic.org/coolstuff/let-it-snow.html 相关文章2011-12-22 -- Matrix Effect on teminal using bash(用bash在终端上显示matrix效果) (0)2010-08-22 -- 学习commandlinefu的命令行：echo “foo” > /dev/tcp/192.168.1.1/25 (0)2010-08-21 -- commandlinefu的命令行学习：&#8217;ALT+.&#8217; [...]]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1876/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matrix Effect on teminal using bash(用bash在终端上显示matrix效果)</title>
		<link>http://www.haw-haw.org/post/1869</link>
		<comments>http://www.haw-haw.org/post/1869#comments</comments>
		<pubDate>Thu, 22 Dec 2011 02:21:40 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Matrix]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1869</guid>
		<description><![CDATA[原文来自http://www.climagic.org/coolstuff/matrix-effect.html echo -e &#34;\e[1;40m&#34; clear while : do echo $LINES $COLUMNS $&#40;&#40; $RANDOM % $COLUMNS&#41;&#41; $&#40;&#40; $RANDOM % 72 &#41;&#41; sleep 0.05 done &#124; gawk '{ letters=&#34;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&#38;*()&#34; c=$4 letter=substr(letters,c,1) a[$3]=0 for (x in a) { o=a[x] a[x]=a[x]+1 printf &#34;\033[%s;%sH\033[2;32m%s&#34;,o,x,letter; printf &#34;\033[%s;%sH\033[1;37m%s\033[0;0H&#34;,a[x],x,letter if (a[x] &#62;= $1) { a[x]=0; } } }' 这一段在我的Linux(centos5和centos6)上跑都没问题，但是在我的mbp(Macbook pro)上不行，因为没有gawk。 第二个脚本： echo -e [...]]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1869/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cacti里图上title中显示中文的问题</title>
		<link>http://www.haw-haw.org/post/1864</link>
		<comments>http://www.haw-haw.org/post/1864#comments</comments>
		<pubDate>Wed, 21 Dec 2011 02:56:14 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<category><![CDATA[escapeshellarg]]></category>
		<category><![CDATA[LC_CTYPE]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[setlocale]]></category>
		<category><![CDATA[中文]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1864</guid>
		<description><![CDATA[系统环境：centos6+cacti0.8.7g 用Aggregate做了几个聚合图，方法前面有提到。 在创建新的图的时候，在title里有中文字符，存取数据库都没有问题，但是在显示的图上，中文字符没有了，原本以为是rrdtool不支持中文导致，打开debug模式一看，才知道，原来在执行生成图的rrdtool的”&#8211;title”参数里，中文字符就没有了，这显然不是rrdtool的问题了，而应该是cacti的问题。翻了下cacti的代码，在文件lib/rrd.php里，有一句： &#34;--title=&#34; . cacti_escapeshellarg&#40;$graph&#91;&#34;title_cache&#34;&#93;&#41; . RRD_NL . ，而在lib/functions.php里关于cacti_escapeshellarg函数的定义里，将其直接用函数escapeshellarg函数替代(因为 $config&#91;&#34;cacti_server_os&#34;&#93; == &#34;unix&#34; 成立) 于是又着重找了找php函数escapeshellarg过滤中文字符的资料，果然有说法，说是LC_CTYPE是缺省值”C”导致，也提了解决方法，就是在文件lib/functions.php中的最前方，显式的将LC_CTYPE设置正确。具体的解决办法如下： 在文件lib/functions.php的最前面，添加一句代码： setlocale&#40;LC_CTYPE, &#34;UTF8&#34;, &#34;en_US.UTF-8&#34;&#41;; 保存，再一刷页面，OK了。 相关文章2011-11-02 -- graphviz画图输出png格式时中文不能显示的问题 (0)2011-10-16 -- centos6下cacti设置ldap认证的问题及解决 (0)2011-09-14 -- apache里用cgi方式执行perl程序，其CGI模块会影响apache的charset (0)2011-09-13 -- 关于rackmonkey的支持中文 (0)2011-06-01 -- dokuwiki的php代码高亮的问题 (1)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1864/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tracks for android提交内容乱码的解决</title>
		<link>http://www.haw-haw.org/post/1857</link>
		<comments>http://www.haw-haw.org/post/1857#comments</comments>
		<pubDate>Mon, 21 Nov 2011 13:47:39 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[TroubleShooting]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1857</guid>
		<description><![CDATA[前面提到tracks for android在修改了内容或者提交一个新的action的时候，中文内容会乱码。最新消息，现在已经解决了。因为tracks for android的作者开放了源码，我直接取了一份，在会java的同事的提点下，最终找到了编码的地方，小改两行代码，问题解决。 编辑文件src/ca/xvx/tracks/util/HttpConnection.java，将其105行和118行的内容： StringEntity ent = new StringEntity&#40;content&#41;; 改成 StringEntity ent = new StringEntity&#40;content, &#34;UTF-8&#34;&#41;; 即可。 没有相关文章。下面是随机文章2008-06-20 -- configure时找不到kde header的错误 (0)2011-07-14 -- 有需要google+邀请的请给我留言 (7)2010-12-15 -- 经历“断电”事件 (1)2007-01-23 -- proftpd实现虚拟用户和quota(不用数据库) (0)2009-03-26 -- httpd2.2.x和httpd2.0.x下php的content-type不一样！ (0)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1857/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>migrate openldap from 2.3.x to 2.4.x</title>
		<link>http://www.haw-haw.org/post/1853</link>
		<comments>http://www.haw-haw.org/post/1853#comments</comments>
		<pubDate>Thu, 17 Nov 2011 09:49:03 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1853</guid>
		<description><![CDATA[　　centos5的机器，openldap是2.3.x的；另外一台centos6的机器，openldap是2.4.x的，现在需要把数据从2.3.x上迁移到2.4.x上去（其实最初的需求是2.3.x和2.4.x之间主从同步的，后来需求才降低到数据迁移）。 　　折腾了一整天，终于搞好了，赶紧做个记录。 　　首先，在centos5(openldap2.3.x)上备份数据 slapcat -l data.ldif 　　然后，将centos5上的data.ldif和/etc/openldap/slapd.conf拷贝到centos6(openldap2.4.x)上 　　接着，重要的操作来了： cp /usr/share/doc/openldap-servers-2.4.x/DB_CONFIG.example /var/lib/ldap/DB_CONFIG chown ldap:ldap /var/lib/ldap/DB_CONFIG slapadd -l data.ldif -f slapd_2.3.conf slaptest -f slapd_2.3.conf -F /etc/openldap/slapd.d/ chown -R ldap:ldap /etc/openldap/slapd.d chown -R ldap:ldap /var/lib/ldap/* /etc/rc.d/init.d/slapd start 　　以上：第一步拷贝DB_CONFIG貌似不是必需的，不过没做的话会老报警告信息。这里假设复制过来的slapd.conf的文件名为slapd_2.3.conf 没有相关文章。下面是随机文章2009-03-30 -- gmail中被merge过的英文名的contact，不能被修改 (1)2005-10-24 -- 用cpan来安装perl的模块儿 (0)2010-10-30 -- 源代码编译apache时libapr的问题 (1)2009-09-29 -- market在家里不能adsl下载软件，但gprs可以下 (0)2007-12-12 -- Writing UNION statements in MySQL 3.x [...]]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1853/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Defining the email address which Nagios sends emails from</title>
		<link>http://www.haw-haw.org/post/1843</link>
		<comments>http://www.haw-haw.org/post/1843#comments</comments>
		<pubDate>Sun, 06 Nov 2011 21:38:21 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mailx]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[nail]]></category>
		<category><![CDATA[sender]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1843</guid>
		<description><![CDATA[　　首先，说明一下：题目是摘抄的。但是问题是通的，用过nagios的都知道，nagios是用程序mail来发报警邮件的，而mail命令不支持命令行直接指定发件人的邮件地址，而且缺省的发件人地址是调用mail的用户@服务器的主机名，所以基本上用nagios的人都有需求修改发件人的邮件地址，解决方法也五花八门。 　　网上大都是改mailrc文件来修改发件人地址的，我不推荐这样做主要是因为如果有别的程序再调mail发邮件，发件人也会是这个修改后的邮件地址，我这里用的算是一种比较简便的方法：使用nail替代nagios原来用的mail来发邮件。因为nail命令直接就支持”-r”参数来设置发件人的邮件地址。在centos5下，直接 yum install nail 即可，如果在centos6下，nail和mail是一个软件包，所以有mail的话，都不用安装，nail就有了，直接用就好了。 相关文章2010-12-22 -- Disable the mail alert send by cron (0)2010-11-27 -- 改了一个nagios plugin:check_mem.pl (0)2010-08-28 -- ubuntu server下的nrpe的配置 (0)2010-08-03 -- 为nagios的web页面添加声音报警 (0)2009-04-13 -- nagio下监控多个hosts下的同一service的简单配法 (0)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1843/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RackTables里添加FireWall设备类型</title>
		<link>http://www.haw-haw.org/post/1845</link>
		<comments>http://www.haw-haw.org/post/1845#comments</comments>
		<pubDate>Sun, 06 Nov 2011 07:56:54 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[FireWall]]></category>
		<category><![CDATA[RackTables]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1845</guid>
		<description><![CDATA[　　RackTables是一款非常棒的it资产管理系统，他自带了好多的设备类型，但是遗憾，没有防火墙设备（也许他认为防火墙设备完全可以直接归到server里，其实我也认可这种看法：），但我还是想添加一种新的设备类型：防火墙，而且RackTables超强的可定制性使之成其了可能。 Main page&#8211;&#62;Configuration&#8211;&#62;Dictionary&#8211;&#62;RackObjectType 点击Edit这个tab 在框里输入FireWall，再点击输入框前面或后面的加号(“+”) 　　这样，FireWall这个object type就建成了。但这样的话还有问题，object id是这个的object，没法设置其ip地址，要解决这个问题，也简单： Main page&#8211;&#62;Configuration&#8211;&#62;User interface 再点击Change这个tab 找到”List source: IPv4-enabled objects”，并在后面的框里的最后加上” or {$typeid_11111}”（11111为FireWall的object type id） 　　至此，就一切搞定了。 没有相关文章。下面是随机文章2010-09-26 -- 在debian5下整合apache2+tomcat5.5+mysql5.0.x (0)2010-01-20 -- 在京xx籍人士团拜会 (0)2006-04-08 -- lighttpd的新洞洞 (0)2008-06-20 -- ./configure时出错”configure: error: Can&#8217;t find X includes” (0)2009-06-03 -- vconfig添加vlan出”error: Invalid argument”错的问题 (0)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1845/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>graphviz画图输出png格式时中文不能显示的问题</title>
		<link>http://www.haw-haw.org/post/1839</link>
		<comments>http://www.haw-haw.org/post/1839#comments</comments>
		<pubDate>Wed, 02 Nov 2011 09:20:18 +0000</pubDate>
		<dc:creator>哈哈</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[graphviz]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[中文]]></category>

		<guid isPermaLink="false">http://www.haw-haw.org/?p=1839</guid>
		<description><![CDATA[用svg格式输出没有问题。 网上解释，据说有两个问题要解决： dot文件需要为utf8编码 需要指定fontname 对于我来讲，第一点不成问题，我缺省编码就是utf8 那么关键就是第二个问题了 centos5.x下 yum install fonts-chinese centos6.x下 yum install cjkuni-ukai-fonts 然后在.dot文件中指出： node &#91; fontname = &#34;AR PL ZenKai Uni&#34; &#93;; (centos6.x用 node &#91; fontname = &#34;AR PL UKai CN&#34; &#93;; ) 再输出成png格式也能显示中文了。 相关文章2011-12-21 -- cacti里图上title中显示中文的问题 (0)2011-09-14 -- apache里用cgi方式执行perl程序，其CGI模块会影响apache的charset (0)2011-09-13 -- 关于rackmonkey的支持中文 (0)2010-01-23 -- 用OptiPNG来优化(压缩)web上的图片 (0)2009-12-28 -- 初用gnuplot来画图碰到的问题 (0)]]></description>
		<wfw:commentRss>http://www.haw-haw.org/post/1839/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

