datetime input with jquery.ui.datepicker and jquery.timep...

sunnavy
2010-07-28 05:25:03 +0000

jQueryUI has a great date picker, and there is a great time picker based on jQueryUI.

Sadly, I haven't seen a great datetime picker yet, where the UI is simple and people don't need to click a dozen of times.

I'm not gonna to write a brand new one( I don't have that much of time, and I'm not a js master yet either ;), so I chose to combine the 2 js lib above, and seems that's good enough for me at least for now.

Demo is Here

Perl6之九 - cross and zip operators

sunnavy
2010-07-26 06:06:44 +0000

二者都是元运算符(metaoperator),参数均为列表。

corss的符号是X,后接一个二元运算符,操作类似于集合中的笛卡尔积。

zip的符号是Z,后接一个二元运算符,与corss的区别见例子

e.g.

 1,2 X+ 3,4     # (1+3, 1+4, 2+3, 2+4), i.e. 4, 5, 5, 6
  X~  # 'ac', 'ad', 'bc', 'bd'

 1,2 Z+ 3,4     # (1+3, 2+4), i.e. 4, 6
  Z~  # 'ac', 'bd'

Perl6之二 - sigil

sunnavy
2010-07-25 04:52:39 +0000

与Perl5很不相同的是,sigil不会变化,scalar永远是$,array永远是@,hash永远是%。

e.g.

Perl6:

 my $scalar = [1,2,3];
 $scalar[0];     # return 1
 my @array = (1,2,3);
 @array[0];      # return 1
 my %hash = ( one => 1, two => 2 );
 %hash;      # return 1, equal to %hash{'one'}

等价的Perl5:

 my $scalar = [1,2,3];
 ${$scalar}[0];     # return 1
 my @array = (1,2,3);
 $array[0];      # return 1
 my %hash = ( one => 1, two => 2 );
 $hash{one};      # return 1

同时,sigil的意思也扩展了:

@x可以绑定任何实现了Positional role的对象,%x对应Associative,%&x对应Callable,::x对应Abstraction。$x没有对应的role,所以可以绑定任何对象.

另外,Perl6还增加了secondary sigil (twigil),以用来指代不同作用域的变量:

 $.foo       # object attribute public accessor
 $^foo       # self-declared formal positional parameter
 $:foo       # self-declared formal named parameter
 $*foo       # dynamically overridable global variable
 $?foo       # compiler hint variable
 $=foo       # Pod variable
 $\      # match variable, short for $/{'foo'}
 $!foo       # object attribute private storage
 $~foo       # the foo sublanguage seen by the parser at this lexical spot

Perl6之一 - 注释

sunnavy
2010-07-25 00:12:54 +0000

除了在引号里,"#"总是意味着注释,所以不能再像Perl5一样用作分隔符:

 qq#ok#    # wrong in Perl6

Perl6增加了内嵌注释:

'#`'后跟一对括号

e.g.

 say #`( I'm a comment ) "howdy world"
 say #`(( I'm a comment too )) "howdy world"
 say #`[ I am another comment] "howdy world"
 say #`{{
    multiple line comments
 }} "howdy world"

make wireless work by updating r8192e_pci.ko

sunnavy
2010-10-24 02:21:10 +0000

I updated to ubuntu 10.10 64bit recently, and found wireless didn't work any more like it does in 32bit.

after updating r8192e_pci.ko, it works again!

It's sad that I couldn't find updated driver in realtek's official page, luckily I found one via google (thanks, johnfoshay!)

I also attached it here just in case.

here is what I did:

  • tar xvfz rtl8192e_linux_2.6.0014.0401.2010.tar.gz
  • cd rtl8192e_linux_2.6.0014.0401.2010
  • make
  • sudo cp HAL/rtl8192/r8192e_pci.ko /lib/modules/`uname -r`/kernel/drivers/staging/rtl8192e/
  • reboot

Good luck to you too!

Comments
"sunnavy" <sunnavy@gmail.com>
2011-03-29 19:22:11 +0000

if you use a samsung notebook, another way to fix this is adding ppa:voria/ppa and install samsung-wireless, which adds r8192e_pci_realtek.ko.

remember to block r8192e_pci.ko

actually, my wireless gets more stable in this way.

拼音的声调表示

sunnavy
2010-09-11 12:39:11 +0000

前几天写文章的时候突然发现不能很方便地输入拼音的声调,所以写了个小模块来干这件事。

用法很简单,下面是一个输出拼音的例子:

 use encoding 'utf8';
 use Lingua::Han::CanonicalPinYin 'canonicalize_pinyin';
 print canonicalize_pinyin( $_ ), "\n" for @ARGV;

如果输入"wen1", 就会输出"wēn",同理还可以输出"wén"(wen2),"wěn"(wen3)和"wèn"(wen4)

App::moduleshere

sunnavy
2010-04-23 21:26:25 +0000

used to copy module files(.pm) in @INC to current working directory or somewhere.

it's on CPAN

Perl第二纪

sunnavy
2010-04-21 14:35:52 +0000

昨天JT Smith发表了一篇博文: the second age of perl,宣称Perl 5的第二纪已经开始, 如下是此文的翻译.

Perl的第二纪

多少年了,人们一直在说,Perl已经死了或者说正在死。 我甚至也这么说过,虽然我的意思和字面上的并不一样。

今天我自作主张在此宣布,我们已经在Perl的第二纪了,不过这和Perl 6没有关系!

这并不是说我不喜欢Perl 6/Rakudo,实际上我很喜欢,只是现在我还并不依赖它工作。Perl 5是我们现在所依赖的,我想这种情况还将持续好些年。

我们进入第二纪其实已经有段日子了,只是没有意识到罢了。Tatsuhiko Miyagawa, Ovid, Brian Foy, Stevan Little, MST, DaveRolsky,还有好些巨人(当然,也不能忽略我们这些小人物的贡献,我是说整个社区),他们的工作(以Class::MOP, Perl::Critic, DBIx::Class, DateTime, and Moose作为开端)构成了第二纪的基础。真正带领我们进入第二纪的是在这些基础之上创造的新东西,比如Padre, Plack, MooseX,Mojolicious和Dancer,还有cpanminus,Starman和Dist::Zilla,更别说Strawberry Perl了。

我坐在这里写这篇文章的时候,脑袋里充满了我能列出来的模块和程序,但是第二纪并不只是代码。它也包括各种各样的推广比如PerlBuzz,blogs.perl.org以及Ironman Blogathon,还包括世界各地数不清的YAPC和MiniYAPC。这是Perl Mongers的再次振兴,这是新的Task::*规则,这是新的Perl 5.12的发布规则。这也是Enlightened Perl之类正在做的。

我们现在正在未来的悬崖边上,自然不能吃老本,但是可以抽点时间来赞美一下在过去这几年里我们所做出的成绩。我们成功避免了成为“过时语言”的危险,并且再次成为主流。是时候该做更多的创新了,是时候去创造一些让Ruby,Python和其他语言想抄的工具和应用了。这就是Perl的正则表达式成为事实标准的原因,也是这些语言极力想建立自己的“CPAN”的原因。让我们做更多的创新让它们去抄吧。