Thursday, September 17, 2009

OpenSocialX::Shindig::Crypter long story

The long story is

we (Zorpia) were developing OpenSocial in last days. The first choice to build a opensocial container is Shindig.

unlucky, it ONLY has PHP and Java version. yeah, I do all my code in Perl, I know nothing about PHP or Java. (well, I know a little PHP now because I was writing Service package with PHP in last days, and I must say, PHP sucks.)

lucky, the Shindig author points me to an URL: Using Shindig in a non PHP or Java environment
that I can write the 'Application' section in Perl. It IS great, really very great.

so at last, I google around and wrote my last solution: OpenSocialX::Shindig::Crypter and the php lib BasicBlobCrypter.php

and now I'm happy to share it with your guys. if you have the same situation with me, you can try that module and tell me your feeling. :)

Thanks. (OK, it's not so long.)

Labels: , ,

OpenSocialX::Shindig::Crypter short story

the short story is that I released the OpenSocialX::Shindig::Crypter yesterday.

the short story is if you want to find a way that encrypt data by Perl and decrypt the encrypted data by PHP, you come to the right place.

Perl: crypt.pl
my $str = 'o=1&v=3&p=5';
my $cipher = Crypt::CBC->new( {
    'key' => 'length16length16',
    'cipher'=> 'Rijndael',
    'iv' => '1234567890abcdef',
    'literal_key' => 1,
    'padding' => 'null',
    'header' => 'none',
    keysize => 128/8
} );
my $encrypted = $cipher->encrypt($str);
print "encrypted: ".encode_base64($encrypted)."\n";
print "decrypted: ".$cipher->decrypt($encrypted)."\n";

my $hmac = Digest::SHA::hmac_sha1($encrypted, 'hmackey');
print "hmac: " . encode_base64($hmac) . "\n";
print "total: " . encode_base64($encrypted . $hmac) . "\n";
PHP: crypt.php
$str = 'o=1&v=3&p=5';
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, 'length16length16', $str, MCRYPT_ENCRYPT, '1234567890abcdef');
$decrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, 'length16length16', $encrypted, MCRYPT_DECRYPT, '1234567890abcdef');
echo "encrypted: ".base64_encode($encrypted)."\n"; 
echo "decrypted: ".$decrypted."\n"; 

$blabla = hash_hmac('sha1', $encrypted, 'hmackey', 1);
echo "hmac: " . base64_encode($blabla) . "\n";
echo "total: " . base64_encode($encrypted . $blabla) . "\n";

both of them show the same output:
# perl crypt.pl
encrypted: rgPZe6swWb3t3yIoIZFQaQ==
decrypted: o=1&v=3&p=5
hmac: WLTGeyesYTUhwg6fjVqDudrKRz0=
total: rgPZe6swWb3t3yIoIZFQaVi0xnsnrGE1IcIOn41ag7naykc9
# php crypt.php
encrypted: rgPZe6swWb3t3yIoIZFQaQ==
decrypted: o=1&v=3&p=5
hmac: WLTGeyesYTUhwg6fjVqDudrKRz0=
total: rgPZe6swWb3t3yIoIZFQaVi0xnsnrGE1IcIOn41ag7naykc9

I'll post a long story later today.

Thanks.

Labels: , ,

Saturday, July 11, 2009

a module started with O

ORDB::Unihan - An ORM for the published Unihan database

a mixin of ORLite and Unihan database. the original unihan database is txt based, and this one is sqlite.
even if you don't want to use ORLite, you still can use the Unihan.sqlite by ORDB::Unihan->sqlite_path();

bla bla, not sure how useful it is. just for fun.

Enjoy

Labels:

Wednesday, June 17, 2009

QueryLog support for Catalyst::Model::DBIC::Schema

well, I wrote Catalyst::Model::DBIC::Schema::QueryLog before. it's fine. it works.

mst released the new Catalyst::Model::DBIC::Schema today. built on top of Moose, with two traits: Caching and Replicated.
It reminds me to write Catalyst::TraitFor::Model::DBIC::Schema::QueryLog
trait is great. easy to read, configurable and sane.

Enjoy. Thanks

Labels: , ,

Tuesday, May 12, 2009

DBIx::Class::ResultSet::Void and TheSchwartz::Moosified

Big thanks to ribasushi, the new DBIx::Class::ResultSet::Void 0.04 is using
# SELECT 1 FROM item me WHERE ( me.id = ? ) LIMIT 1: '1'
# INSERT INTO item ( id, name) VALUES ( ?, ? ): '1', 'A'
instead of COUNT(*). it's much faster now.

Another big thanks to stash from socialtext, TheSchwartz::Moosified 0.04 with PostgreSQL support and bug fixes.

Enjoy!

Labels: , ,

Sunday, May 10, 2009

DBIx::Class::ResultSet::Void

some time I'm really feeling sick when I use update_or_create or find_or_create, the default DBIx::Class::ResultSet return DBIx::Class::Row object by using find.
it's useful when I need the $row object, but it's dummy if I don't care.

I wrote DBIx::Class::ResultSet::Void today. It would use count instead of find if not defined wantarray. it means when I call
$rs->find_or_create( { id => 1, name => 'A' } );
instead of
my $row = $rs->find_or_create( { id => 1, name => 'A' } );
it would generate SQLs like:
# SELECT COUNT( * ) FROM item me WHERE ( me.id = ? ): '1'
# INSERT INTO item ( id, name) VALUES ( ?, ? ): '1', 'A'
it's a little better I think.

read more on the POD and Enjoy!

Labels: ,

Tuesday, April 21, 2009

CPAN updates

I spent lots of time to write CPAN module in past two days. it's not so fun but enjoyable.

App::GitHub - 8 dists 3 days.
Dist::Zilla::Plugin::MetaResources - DEPERCATED, it will be supported in Dist::Zilla core.
Dist::Zilla::Plugin::Repository
Net::GitHub - also 8 dists 3 days.

To write a CPAN module is really not so hard. please go on and enjoy it.

Thanks.

Labels:

Sunday, April 05, 2009

Dist::Zilla::Plugin::PerlTidy

I just uploaded the Dist-Zilla-Plugin-PerlTidy to CPAN today.

Dist::Zilla is a distribution builder. with it, you can write less, maintain less files. which means less bugs.
for more information, you can check the slides: http://www.slideshare.net/rjbs/distzilla-presentation

Dist-Zilla-Plugin-PerlTidy contains two parts.
one is the App Command, Dist::Zilla::App::Command::perltidy, which let you perltidy your real code.
the other one is the Plugin, Dist::Zilla::Plugin::PerlTidy. it doesn't affect your working code, it just perltidy the code for release (which means included in the tar.gz)

the code is simple, but it's useful.

Have fun!

Labels: ,

Sunday, March 08, 2009

Net::GitHub

I just released the new http://search.cpan.org/dist/Net-GitHub/.

it's basically a Perl interface to github.com which is the most popular git host in the world. perl5's source and perl6's rakudo source are there too.

I'm starting to like git and I put my code there too.
be inspired by Net::Google::Code, I created the http://github.com/fayland/perl-net-github/tree/master
everyone is welcome to fork it then pull request back to me.

Thanks very much, Enjoy.

Labels: , ,

Monday, January 12, 2009

Google::Code::Upload

Google::Code::Upload - uploading files to a Google Code project.

see you have a google code project like http://code.google.com/p/fayland/
then you want to upload some files to Downloads section.
it's OK to upload through web interface, and if you want to upload through command line, there is a python script: http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py

I'm a Perl guy, so I decided to port it to Perl. then there comes out http://search.cpan.org/dist/Google-Code-Upload/.
mainly there is a Perl script http://search.cpan.org/dist/Google-Code-Upload/script/googlecode_upload.pl which you can just simply type:
$> googlecode_upload.pl Google-Code-Upload-0.02.tar.gz
then type project:fayland, username:fayland, password:lovekitty, summary:xxx

just Enjoy!

Labels: ,

Tuesday, December 02, 2008

MySQL::SlowLog::Filter

we are using mysqlsla to parse MySQL slow.log, but we have an issue that our slow.log is pretty huge, it contains 2 years' data. somehow I just need 3 month or half a year.

I'm searching around to find a script to do the things I want and I find http://code.google.com/p/mysql-log-filter/
it's python(php) script and I do want a Perl script.

then http://search.cpan.org/dist/MySQL-SlowLog-Filter/ is out.
and a script: http://search.cpan.org/dist/MySQL-SlowLog-Filter/script/mysql_slowlog_filter.pl

have fun

Labels: ,

Thursday, November 06, 2008

Padre committer

if you are following padre, you may find that I'm a committer now.

[fayland@alpha padre]$ svn log | perl -MData::Dumper -n -e'if (/^r\d+\s*\|\s*(\w+)\s*\|/) {$c{$1}++} END {print Dumper \%c}'
$VAR1 = {
'tsee' => 19,
'adamk' => 90,
'fayland' => 12,
'patspam' => 6,
'bricas' => 2,
'szabgab' => 538
};

mainly I'm contributing something like follows:
* Wx::Choice ->SetSelection(0);
* add test 82-plugin-manager.t and cleanup _load_plugin in PluginManager.pm
* highlight with PPI for Perl5
* remove "no output" in ack
* Limit the search_terms/replace_terms
* add main_files_pos to goto last pos for those left files.

some are trivial and some are important. I feel proud with those commit.

and I update the plugins list a lot. now I have 7 plugins for padre.
Padre-Plugin-AcmePlayCode-0.02 Acme::PlayCode Plugin for Padre
Padre-Plugin-CPAN-0.01 CPAN in Padre
Padre-Plugin-PluginHelper-0.02 make building Padre plugin easy
Padre-Plugin-TabAndSpace-0.05 convert between space and tab within Padre
Padre-Plugin-Validator-0.02 validate HTML/CSS in Padre
Padre-Plugin-ViewInBrowser-0.01 view selected doc in browser for Padre
Padre-Plugin-WordStats-0.02 Word stats for Padre

Padre-Plugin-PluginHelper is useful to develop a new plugin, it loads plugin from a local dir, and it can be reloaded after change.

so start to play with padre, and tell us what you think. :)

Thanks.

Labels: ,

Wednesday, October 29, 2008

new Locale::Country::Multilingual

Bernhard Graf is making a huge step on Locale::Country::Multilingual

0.07 10/27/2008
- added correct Unicode support (Bernhard Graf)
- updated and fixed some errors in country data files (Bernhard Graf)
- tie language data to the class, not the instance (Bernhard Graf)
- possibility to preload language files at compile time (Bernhard Graf)
- added method assert_lang() to check availability (Bernhard Graf)
- changed from hashes to arrays where possible (Bernhard Graf)
- documentation (Bernhard Graf)
- tests for new features (Bernhard Graf)

and it has its own trunk now. http://code.google.com/p/perl-locale-country-multilingual/
hope you can join us.

Thanks.

Labels:

Sunday, October 19, 2008

Acme::PlayCode and MooseX::Types::IO

I wrote Acme::PlayCode and MooseX::Types::IO and uploaded them to CPAN today.

Acme::PlayCode is just from:
learn PPI 1: double to single
Learn PPI 2: exchange in condition
I don't think it's useful now so I put it as Acme:: for fun.
Acme::PlayCode use MooseX::Object::Pluggable, so everyone can write a plugin for it.
the idea is directly from Devel::REPL. if you want to learn Moose, you should read the source. it's pretty elegant and clean. I think I'll write a plugin for it some days later.

MooseX::Types::IO is IO and IO::All type for Moose. I thought I would use it in Acme::PlayCode so I wrote it, but I didn't use it at last. hmm. but anyway, I'll use it one day later.

Have fun. Thanks.

Labels: , ,

Friday, October 10, 2008

IRC::Bot::Log::Extended

well, I do NOT want to miss the irc talk history when I go sleep. I want to store the talk into plain text, and read it when I'm free.

that's a simple and straight. IRC::Bot is good. really fast and have a logger built-in.
The only thing I don't like IRC::Bot is that it stores all talk history into one file channel.log regardless channel and day. I want to split them, to ease the reading.

so that's why IRC::Bot::Log::Extended is kicked out.
and the example script is http://fayland.googlecode.com/svn/trunk/script/web/irclog.pl

so it's logging for me. all #catalyst #dbix-class #tt #moose talk history.

Thanks.

Labels: , ,

Monday, September 29, 2008

two new CPAN modules

* Task::BeLike::FAYLAND

OK, it's not so useful for u I think. just ignore it.

* Catalyst::Plugin::CHI

mix the CHI and Catalyst. :)

Labels: ,

Friday, September 19, 2008

a busy release day today

I just kicked out 2 new modules and 1 refreshing module to CPAN.

2 new modules:
* Pod::Simple::Wiki::Googlecode
* Pod::From::GoogleWiki for http://use.perl.org/~schwern/journal/37476

and 1 refreshing module:
* Foorum

well, just enjoy!

Labels:

Thursday, December 20, 2007

CPAM modules updates