Skip to content

Instantly share code, notes, and snippets.

Shinichiro Aska s-aska

Block or report user

Report or block s-aska

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
@s-aska
s-aska / mail_header_get.pl
Created Nov 16, 2010
Mail Header Fast Get
View mail_header_get.pl
my $header;
my $buf;
my $term = "\n\n";
my $term_buf = '';
open($fh, $path) || die "$path $!";
while (read($fh, $buf, 4096)) {
$buf=~tr/\r//;
my $pos = index($term_buf . $buf, $term);
if ($pos >= 0) {
my $pos2 = $pos - length($term_buf);
@s-aska
s-aska / Dispatcher
Created Dec 8, 2010
よく使うDispatcher
View Dispatcher
package MasterSpark::Web::Dispatcher;
use strict;
use warnings;
use Amon2::Web::Dispatcher::RouterSimple;
connect '/{action}' => { controller => 'Root' };
connect '/{controller}/{action}' => {}, {
on_match => sub {
View simple-app.psgi
use lib qw(lib);
use Plack::Request;
use Plack::Builder;
use Plack::Session::Store::File;
use Plack::Session::State::Cookie;
use String::Urandom;
my $secure = 1; # use SSL
my $httponly = 1; # only HTTP
@s-aska
s-aska / app.psgi
Created Feb 18, 2011
Markdown Reader
View app.psgi
use strict;
use Data::Section::Simple;
use Encode;
use JSON;
use Path::Class;
use Plack::Builder;
use Plack::Request;
use Text::Markdown;
use Text::Xslate;
@s-aska
s-aska / Model.pm
Created Feb 28, 2011
reconnect and datetime auto Model.pm
View Model.pm
package Hamburger::Model;
use parent 'Teng';
use DateTime;
sub dbh {
my $self = shift;
$self->SUPER::dbh;
$self->connect unless $self->{dbh};
$self->{dbh};
View get_tweet_count
#!/usr/bin/env perl
use WebService::Simple;
print WebService::Simple->new(
base_url => 'http://urls.api.twitter.com/1/urls/count.json',
response_parser => 'JSON'
)->get( { url => shift } )->parse_response->{count}, "\n";
@s-aska
s-aska / find_and_install.pl
Created Mar 24, 2011
module auto install.
View find_and_install.pl
find lib -type f | sed -e 's|^lib/||g; s|\.pm$||g; s|/|::|g' > modules.lst
perl -I lib -Mlib::xi -e 'eval "use $_";die $@ if $@' -n modules.lst
View base64.pl
#!/usr/bin/env perl
use strict;
use MIME::Base64;
my $base64 = encode_base64(join('', <>));
$base64=~s|\s*||g;
print $base64, "\n";
# base64
@s-aska
s-aska / manifest skip
Created Apr 22, 2011
add file manifest skip
View manifest skip
echo .foo | perl -ne 'chomp;print "^", quotemeta($_), "\$\n"' >> MANIFEST.SKIP
@s-aska
s-aska / screenshot.pl
Created May 4, 2011
スクリーンショットを取るコマンド
View screenshot.pl
#!/usr/bin/env perl
# get screenshot
# screenshot.pl URL filename
#
# ubuntu
# sudo apt-get install xvfb chromium-browser imagemagick
#
# Japanese Font
# sudo apt-get install ttf-takao
You can’t perform that action at this time.