Skip to content

Instantly share code, notes, and snippets.

View aklaswad's full-sized avatar

Akira Sawada aklaswad

View GitHub Profile
@aklaswad
aklaswad / server.pl
Last active August 29, 2015 14:15
Perl-JS compatible webserver
#!/usr/bin/env perl
1 // <<HACK;
/*
HACK
use strict;
use warnings;
use Plack::Runner;
my $js = do { local $/; <DATA> };
@aklaswad
aklaswad / script.js
Last active August 29, 2015 14:15
JavaScript editable/runnable perl server script
1 // <<HACK;
/*
HACK
use strict;
use warnings;
use Plack::Runner;
my $js = do { local $/; <DATA> };
my $html = <<'HTML';
#!/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;