Skip to content

Instantly share code, notes, and snippets.

Akira Sawada aklaswad

Block or report user

Report or block aklaswad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Data::ObjectDriver forksafe-mysql.t
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Data::ObjectDriver::Driver::DBI;
use Parallel::ForkManager;
sub main {
# Init dbh and make sure it was connected by parent process
my $driver = Data::ObjectDriver::Driver::DBI->new(
View d:od fork safe test
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 10;
use Data::ObjectDriver::Driver::DBI;
use Parallel::ForkManager;
sub main {
# Init dbh and make sure it was connected in parent process
my $driver = Data::ObjectDriver::Driver::DBI->new(
@aklaswad
aklaswad / script.js
Last active Aug 29, 2015
JavaScript editable/runnable perl server script
View script.js
1 // <<HACK;
/*
HACK
use strict;
use warnings;
use Plack::Runner;
my $js = do { local $/; <DATA> };
my $html = <<'HTML';
@aklaswad
aklaswad / server.pl
Last active Aug 29, 2015
Perl-JS compatible webserver
View server.pl
#!/usr/bin/env perl
1 // <<HACK;
/*
HACK
use strict;
use warnings;
use Plack::Runner;
my $js = do { local $/; <DATA> };
View gist:7836191
use strict;
use warnings;
# find the most greater value in range of less or equal to given target.
# returns the index of that value.
# array must be ascend sorted.
sub idx_of_max_in {
my ( $array, $head, $tail, $target ) = @_;
return $tail if $array->[$tail] <= $target;
return $head if $array->[$head] == $target;
View gist:7821286
use strict;
use warnings;
my $PRICE_MAX = 1_000_000;
my $PRICE_MIN = 10;
my $ALGORITHM_SWITCH_THRESHOLD = 1000; # TODO: 適当に決めるな馬鹿
my @lines = split "\n", do { local $/; <> };
my ( $num_products, undef ) = split( " ", shift(@lines) );
my @prices = splice( @lines, 0, $num_products );
View gist:7819657
use strict;
use warnings;
my $PRICE_MAX = 1_000_000;
my @lines = split "\n", do { local $/; <> };
my ( $num_products, undef ) = split( " ", shift(@lines) );
my @prices = splice( @lines, 0, $num_products );
my @hist;
View gist:5787844
var async_task = function (msg, delay) {
var dfd = $.Deferred();
setTimeout( function () {
if ( msg !== 'l' ) {
dfd.resolve('resolved:' + msg);
}
else {
dfd.reject('rejected:' + msg);
}
@aklaswad
aklaswad / gist:4117045
Created Nov 20, 2012
fullscreen api wrapper draft
View gist:4117045
(function ($) {
var venderApis = {
'fullscreenEnabled': {
request: 'requestFullscreen'
, exit: 'exitFullscreen'
, element: 'fullscreenElement'
}
, 'mozFullScreenEnabled': {
request: 'mozRequestFullScreen'
View gist:2644637
#!/usr/bin/env perl
1 // <<X;
/*
X
use strict;
use warnings;
use 5.10.0;
# # # # # # # # # # # # # # # # # # # # # # # # # # # #
# perl and node dual executable script. #
You can’t perform that action at this time.