purl in your heart
2012年2月26日 星期日
2012年1月19日 星期四
Split inside specific column and expend to key-value extractor
{
perl -F\\t -lane 'BEGIN{ $i=shift; @h=split q(,), shift; print STDERR join qq(\t), @h } %k=map { @{[split(q(:), $_)]}[0,1] } split q(, ), $F[$i]; print join qq(\t), map { $k{$_} } @h' $*
} $ echo 2010Q1:H, 2007:Y, 2009:Y| col2kv 0 2006,2007,2008,2009,2010Q1,2010Q2 2>&1| row2col
2006
2007 Y
2008
2009 Y
2010Q1 H
2010Q2
2012年1月6日 星期五
How to make group_by_in_perl?
group_by_in_perl ()
{
perl -F\\t -lane 'BEGIN{$group_by=shift; $sum_by=shift} END { print for map{ join qq(\t), $_, $sum{$_}} keys %sum } $sum{join qq(\t), @F[eval($group_by)]} += $F[eval($sum_by)]' $*
}
2011年12月27日 星期二
xml-table-maker for Windows
perl -e "use Win32::Clipboard; use DBIx::XHTML_Table; Win32::Clipboard::Set(DBIx::XHTML_Table->new(q(dbi:Oracle),qq(@ARGV))->exec_query(eval <STDIN>)->modify(table=>{border=>1, bordercolor=> q(#888888), cellspacing=>0})->output())"
2011年11月29日 星期二
PDC: 圣经说,爱是个习惯
| ||
The Bible Says Love Is a Habit 圣经说,爱是个习惯 | ||
“If you love those who love you, what credit is that to you? Even sinners love those who love them.” (Luke 6:32 NIV) 你们若单爱那爱你们的人,有什么可酬谢的呢?就是罪人也爱那爱他们的人。路加福音 6:32 If you only love on and off like a light switch, you do not love others like God wants you to love. Jesus said, “If you only love those who love you, what credit is that to you?” (Luke 6:32a NIV) 如果你的爱像电灯一样时开时关,那么你就没有按照神的心意去(活出�的)爱了。所以,耶稣这样说:“你们若单爱那爱你们的人,有什么可酬谢的呢?”(路加福音 6:32) His point is this: All of us can love those who love us back. Becoming a master lover means you learn to love the unlovable � when you love people who don’t love you, when you love people who irritate you, when you love people who stab you in the back or gossip about you. 他的意思是:我们每个人都能做的,就是爱那些知恩图报的人。而你若想要成为一个有博爱之心的人,就得学着去爱那些不可爱的人。也就是,去爱那些不爱你的人,包括那些常常触怒你的人,或是那些在你背后指指点点、说长道短的人。 This may seem like an impossible task, and it is � that’s why we need God’s love in us, so we can then love others: “We know and rely on the love God has for us” (1 John 4:16a NIV). 如果这听上去有点象天方夜谭,那你其实是清醒的。因为,无私的付出爱,并且一味的坚持,这真的需要神的爱先充满我们的心。所以,圣经这样说:“神爱我们的心,我们也知道也信”(约翰一书 4:16)。 When you realize how much God loves you � with an extravagant, irresistible, unconditional love � then his love will change your entire focus on life. If we don’t receive God’s love for us, we’ll have a hard time loving other people. I’m talking about loving people who are unlovely, difficult, irritable, and those who are different or demanding. 当你认识到神对自己的爱有多么丰盛、多么的坚忍、多么的无私,那么�的爱就能改变你对生命的关注点。如果我们不去接受神给我们的爱,那么关爱他人就是一件太难太难的事。注意,这里我们说的仍然是爱那些不可爱的、满是困难的、易于激怒人的、与常人迥异的、常常不满足的人。 You can’t do that until you have God’s love coming through you. You need to know God’s love so it can overflow out of your life into others. 没有神的爱在你心里运行,这些就真的太难了。你必须去认识神的爱,这样你的心里才能充满�的爱,直到这爱开始满溢,涌流出来,进入他人的生命中。 |
2011年11月6日 星期日
Psalm 16:7
2011年10月25日 星期二
po4a for the translation of Perldoc
To make a translation of perldoc, use the tool named po4a
[jjiang@fedora14 ~]$ pmvers Locale::Po4a::TransTractor
0.41
[jjiang@fedora14 ~]$ po4a-gettextize --help-format
List of valid formats:
- dia: uncompressed Dia diagrams.
- docbook: DocBook XML.
- guide: Gentoo Linux's XML documentation format.
- ini: INI format.
- kernelhelp: Help messages of each kernel compilation option.
- latex: LaTeX format.
- man: Good old manual page format.
- pod: Perl Online Documentation format.
- sgml: either DebianDoc or DocBook DTD.
- texinfo: The info page format.
- tex: generic TeX documents (see also latex).
- text: simple text document.
- wml: WML documents.
- xhtml: XHTML documents.
- xml: generic XML documents (see also docbook).
[jjiang@fedora14 ~]$ perldoc -l perlretut
/usr/share/perl5/pod/perlretut.pod
[jjiang@fedora14 ~]$ po4a-gettextize -f pod -m $(perldoc -l perlretut) | tee perlretut.po | wc -l
5155
[jjiang@fedora14 ~]$ vim perlretut.po
…
#. type: =head1
#: /usr/share/perl5/pod/perlretut.pod:1
msgid "NAME"
msgstr "名称"
#. type: textblock
#: /usr/share/perl5/pod/perlretut.pod:3
msgid "perlretut - Perl regular expressions tutorial"
msgstr "perlretut - Perl 正则表达式指南"
#. type: =head1
#: /usr/share/perl5/pod/perlretut.pod:5
msgid "DESCRIPTION"
msgstr "简介"
#. type: textblock
#: /usr/share/perl5/pod/perlretut.pod:7
msgid ""
"This page provides a basic tutorial on understanding, creating and using "
"regular expressions in Perl. It serves as a complement to the reference "
"page on regular expressions L<perlre>. Regular expressions are an integral "
"part of the C<m//>, C<s///>, C<qr//> and C<split> operators and so this "
"tutorial also overlaps with L<perlop/\"Regexp Quote-Like Operators\"> and "
"L<perlfunc/split>."
msgstr ""
"这篇文章用来介绍 Perl 正则表达式的解读、编写和使用方面的基础知识。相对于 L<perlre> 中的介绍来说,这篇文章更加侧重于提供一些增补知识。正则表达式,它是 C<m//>, C<s///>, C<qr//> 和 C<split> 这些操作符的主要兴趣所在,因此L<perlop/\"Regexp Quote-Like Operators\"> 和 L<perlfunc/split> 里面也有许多相关的描述。"
…
[jjiang@fedora14 ~]$ po4a-translate -k 0 -f pod -m $(perldoc -l perlretut) -p perlretut.po | less
2011年10月20日 星期四
Non-stop debugging of perl programs
Package -e.
in @=main::abc(0) from -e:1
out @=main::abc(0) from -e:1
list context return from main::abc:
0 1
in @=main::abc(3) from -e:1
out @=main::abc(3) from -e:1
list context return from main::abc:
0 4
1 4
2011年10月19日 星期三
PDC:慷慨也是信心的表现
| ||
Generosity is a Matter of Faith慷慨也是信心的表现 | ||
A generous man will prosper and he who refreshes others will himself be refreshed. Proverbs 11:25 (NIV) When you share with others, God shares with you. 当你与他人分享的时候,神也会与你分享。 The world says, “Get everything you can and you will be financially secure.” The Bible says share with others in need and you’ll sow what you reap: “Give and it will be given to you.” (Luke 6:38 NIV) 这个世界的逻辑是“尽可能的攫取,这样你就会富有”,而圣经的原则是要尽可能的与他人分享,这样你就会有丰厚的回报:“你们要给人,就必有给你们的”(路加福音 6:38) God says that when you give to somebody else, you're not throwing it away. It’s an investment in the lives of others. God says the one who gives will gain even more: “He who is kind to the poor, lends to the Lord and He will reward him for what he has done.” (Proverbs 19:17 NIV) 在神的眼中,当你给予别人的时候,并不是在舍弃什么,而是对其他人的生命进行投资。神会对那些慷慨付出的人给予更多回报:“怜悯贫穷的,就是借给耶和华。他的善行,耶和华必偿还”(箴言 19:17) When you see people in need and you give to them, God looks at this as if it were a loan to Him. He says, “I will reward back.” 所以,当你向那些需要的人伸出援手的时候,神会把这看成是对�自己的一次借贷。�就这样想:“我必须偿还他”。 God is always going to take care of you and your needs. Do you believe that is true? Generosity is a matter of faith. Will you take God at his Word? 神总是想要帮助你,满足你的需要。你相信这个道理么?慷慨也是信心的一种表现。你要不要在这个方面顺服神的吩咐呢? |
2011年10月11日 星期二
2011年9月29日 星期四
2011年9月25日 星期日
Script to find the root directory usage, on system with lots of mounts
sudo perl -MList::MoreUtils=any -lne 'BEGIN{@m=map {@F=split; qq(^$F[2])} map {$1 if m{(.*)}} qx{mount|tail --line=+2}; open STDIN, q(find / -maxdepth 3 -mindepth 1 |)} $p=$_; do {print join qq(\t), qx(du -s "$_")=~m{(.*)}} unless any {$p=~m{$_} or $_=~m{$p}} @m' | sort -k1 -nrg | head
2011年9月23日 星期五
SQLite related 2 utilities, to fix the book & chapter names problems of Blackberry YouVersion bible reader
SQLite.pl
#!/usr/bin/perl -w
use strict;
use DBI;
my @r;
my $d=DBI->connect(qq(dbi:SQLite:dbname=@{[shift]}), q(), q());
my $s=$d->prepare_cached(join q(),<STDIN>);
$s->execute(@ARGV);
$,=qq(\t); $\=qq(\n);
print STDERR @{$s->{NAME}}; print @r while @r=$s->fetchrow_array;
$s->finish; $d->disconnect;
Do-SQLite-for.pl
#!/usr/bin/perl -w
use strict;
use DBI;
my $d=DBI->connect(qq(dbi:SQLite:dbname=@{[shift]}), q(), q());
my $s= $d->prepare_cached(do { open(SQL, q(<), shift); join(q(),<SQL>) });
$,=qq(\t); $\=qq(\n);
while(<>) {
chomp;
my @F = split(qq(\t), $_, -1);
$s->execute(@F);
}
$s->finish; $d->disconnect; close SQL;
2011年9月15日 星期四
2011年9月13日 星期二
Sample of XML::Dumper, working with xslt
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/perldata/hashref">
<html>
<body>
<table border="1">
<tr>
<th>Key</th>
<th>Value</th>
</tr>
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="@key"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
$ perl -MXML::Dumper -le 'print pl2xml(\%INC)' | xsltproc perlhash.xsl - | w3m -T text/html
2011年9月10日 星期六
pipeline for top 100 repeated word list in article/book
perl -MList::MoreUtils=natatime -lane ’END{ $it = natatime 100, sort {$cnt{$b} <=> $cnt{$a}} keys %cnt; print for map {join qq(\t), $_, $cnt{$_}} $it->() } $cnt{$_}++ for @F’
2011年9月8日 星期四
Using this to find the depending module in a quick and dirty way
{
pmpath $* | perl -MList::MoreUtils=uniq -lne 'BEGIN{$m=shift} print for sort map {($_)=$_=~m{(.*)}} uniq grep {!m{$m}} qx(grep -h ^use.*:: @{[s{\.pm$}{} && $_]}/*.pm)' $*
} $ basedon XML::XSH2
use File::Spec;
use File::Temp qw(tempfile tempdir);
use Filter::Simple;
use IO::File;
use Module::Compile -base;
use Parse::RecDescent;
use Scalar::Util;
use Tie::Scalar;
use URI::file;
use XML::LibXML::Iterator;
use XML::LibXML::NodeList;
use XML::LibXML;
use base qw(XML::LibXML::Iterator);$ basedon XML::LibXML
use IO::File;
use XML::SAX::Base;
use base qw(XML::SAX::Base);
2011年9月1日 星期四
2011年8月30日 星期二
get unique content from duplicated *.tar.gz contents
#!/usr/bin/perl -wln
$fn = $_;
do{ @F=split; $uniq{join qq(\t), @F[3,4,2]}||= join qq(\t), $fn, $F[5] } for grep {!m{^d}} map{ m{(.*)} } qx(zcat $_ | tar -tv);
END{ print join qq(\t), $_, $uniq{$_} for sort keys %uniq }
2011年8月27日 星期六
Ezekiel 3:10
2011年8月23日 星期二
Mark 11:23
2011年8月21日 星期日
HTML::Table in one-liner
2011年8月19日 星期五
Mark 8:36
2011年8月2日 星期二
2011年7月26日 星期二
nohup-tee-tail-mail.pl
#!/usr/bin/perl
use POSIX;
BEGIN{($cmd, $out, $mail, $append)=@ARGV}
my $child=fork;
die $! unless defined $child;
exit 0 if $child;
setsid;
close STDIN; #, q(<), q(/dev/null);
open STDERR, q(>&), STDERR;
open STDOUT, q(|-), qq(tee @{[$append && q(-a )]}$out|tail|mail -s $out $mail);
exec $cmd;




