Skip to content

Instantly share code, notes, and snippets.

View aklaswad's full-sized avatar

Akira Sawada aklaswad

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw( carp );
use Test::Base;
plan tests => 6 * blocks;
sub escape_mt_export {
my ($str) = @_;
$str =~ s/^(-+)$/$1$1$1/gm;
<mt:setvar name="mttags" value="mt:CommenterName":"mt:CommentBody":"mtApp:PageActions":"mt:IfNonEmpty":"mt:IncludeBlock":"mt:ArchiveList":"mt:AssetScoreAvg":"mt:CommentPreviewEmail":"mt:FolderHeader":"mt:PageNext":"mt:RemoteSignOutLink":"mt:IfCommentParent":"mt:HTTPContentType":"mt:PageAuthorLink":"mt:BlogLanguage":"mt:NotifyScript":"mt:SetVarBlock":"mt:WebsiteID":"mt:CommenterUserpicAsset":"mt:ArchivePrevious":"mt:EntryAuthorDisplayName":"mt:ArchiveTypeLabel":"mt:CommentScript":"mt:EntryCommentCount":"mt:SubCatIsFirst":"mt:AssetIfTagged":"mt:IfCommentsAccepted":"mt:PreviousLink":"mt:EntryKeywords":"mt:CommentPreviewBody":"mt:SetHashVar":"mt:EntryAdditionalCategories":"mt:AssetDescription":"mt:BlogParentWebsite":"mt:Authors":"mt:PageAuthorURL":"mt:BlogIfCommentsOpen":"mt:CGIPath":"mt:SubFolderRecurse":"mt:IfTypeKeyToken":"mt:AtomScript":"mt:SearchMaxResults":"mt:IfPingsAccepted":"mt:IfCurrentPage":"mt:IfMoreResults":"mt:NextLink":"mt:BlogCategoryCount":"mt:Folders":"mt:CategoryArchiveLink":"mt:PagePermalink":
#!/usr/bin/perl
package Sudoku;
use strict;
use warnings;
sub new {
my $pkg = shift;
my $self = bless {}, $pkg;
$self->load_puzzle(@_) if @_;
#!/usr/bin/perl
## In sort method, generated sub routine can't access to the lexical variables
## of outer scope...
use strict;
use warnings;
sub my_sort ($$) {
my ( $a, $b ) = @_;
my $foo = 1;
### Movable Type content viewer
use Plack::Builder;
use lib qw( lib extlib );
use Encode;
use MT;
use MT::FileMgr::Local;
use MT::WeblogPublisher;
my $mt = MT->new;
my $pub = MT::WeblogPublisher->new;
my $ContentTypes = {
#!/usr/bin/perl
# Sample for using MT registry
use strict;
use warnings;
use lib qw( lib extlib );
use MT;
use MT::Component;
use Data::Dumper;
my $c1 = MT::Component->new;
$c1->registry({
#!/usr/bin/perl
# MT registry cookbook
use strict;
use warnings;
use lib qw( lib extlib ../lib ../extlib);
use utf8;
use MT;
use MT::Component;
use Test::More;
@aklaswad
aklaswad / gist:666207
Created November 7, 2010 16:04
registry-test.t
#!/usr/bin/perl
# intro for MT::Component::registry()
use strict;
use warnings;
use lib qw( lib extlib ../lib ../extlib);
use utf8;
use MT;
use MT::Component;
use Test::More;
@aklaswad
aklaswad / gist:807368
Created February 2, 2011 07:30
Sample Response of list query
{
"error" : null,
"result" : {
"messages" : [],
"count" : "158",
"page" : "1",
"page_max" : 4,
"columns" : "id,title,author_name,category_id,authored_on,modified_on,comment_count,ping_count",
"id" : "_allpass"
"filters" : [
@aklaswad
aklaswad / gist:844870
Created February 26, 2011 02:28
search with meta column
#!/usr/bin/perl
use strict;
use warnings;
use lib qw( lib extlib );
use MT;
MT->new;
use Data::ObjectDriver;
$Data::ObjectDriver::DEBUG = 1;
MT->model('blog')->load(