Skip to content

Instantly share code, notes, and snippets.

View hideo55's full-sized avatar

Hideaki Ohno hideo55

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Docca;
use Data::Section::Simple qw/get_data_section/;
my $docca = Docca->new(
from => { Xatena => { converter => { hatena_compatible => 1 }, }, },
to => { PDF => { bin_name => '/usr/local/bin/wkhtmltopdf', }, },
@hideo55
hideo55 / gist:1253830
Created September 30, 2011 14:02
ヴィジュアルモードの選択範囲に対してコマンドを実行
"選択範囲に対してperltidyを実行する例ですが、
noremap <buffer> ,ptv <Esc>:'<,'>! perltidy -pbp<CR>
"こんな感じでいけます。'<,'>がヴィジュアルモードでの選択範囲を表してます
"選択して ,ptv とタイプすると選択範囲が perltidy -pbp に渡され、選択範囲がperltidyの標準出力で置換されます
- var html='<script type="text/javascript" src="http****?hoge=fuga&foo=bar"><script>'
| !{html}
@hideo55
hideo55 / build.log
Created September 2, 2011 16:55
build.log of cpanm on the dotcloud
Checking if you have Pickles 0 ... No
==> Found dependencies: Pickles
Searching Pickles on cpanmetadb ...
--> Working on Pickles
Fetching http://search.cpan.org/CPAN/authors/id/D/DM/DMAKI/Pickles-0.08.tar.gz
-> OK
Unpacking Pickles-0.08.tar.gz
Entering Pickles-0.08
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.42 ... Yes (6.56)
#!/usr/bin/env perl -w
use strict;
use Text::Xslate;
use AnyEvent::JSONRPC::Lite::Server;
use Getopt::Long;
my ( $port, $template_path );
GetOptions( "port=i" => ¥$port, "path=s" => ¥$template_path );
@hideo55
hideo55 / color.pl
Created July 29, 2011 15:42
keyword coloring on terminal.
#!/usr/bin/env perl -w
use strict;
my $kw_path = shift @ARGV;
if( !defined($kw_path) || !(-e $kw_path ) ){
die <<"__USAGE__";
Usage:
# tail -f | ./color.pl keywords.pl
keywords are defined by ArrayRef such as:
[qw(error fail)];
@hideo55
hideo55 / metacpan-growler-gntp.pl
Created July 27, 2011 13:55
MetaCPAN Growler - Growl::GNTP version
#!perl
use strict;
use warnings;
use Growl::GNTP;
use AnyEvent;
use AnyEvent::HTTP;
use JSON;
use Data::MessagePack;
use Cache::LRU;
@hideo55
hideo55 / dynamic_load.pl
Created July 12, 2011 13:59
モジュールの動的ロードとメソッドの呼び出し
use strict;
use warnings;
use Class::Load qw(load_class);
my $module_name = 'MY::MODULE::NAME';
#Moose::Util::load_class()とほぼ同等、ロードに失敗すると例外を投げる
load_class($module_name);
#can()はCodeRefを返す
@hideo55
hideo55 / coerce_sample.pl
Created July 4, 2011 15:05
Moose coerce
package WWW::ImagePager;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';
use URI;
class_type 'URI';
coerce 'URI' => from 'Str' => via { URI->new(shift) };
has 'basepage' => ( is => 'rw', isa => 'URI', coerce => 1 );
@hideo55
hideo55 / io-scalar.pl
Created May 30, 2011 14:40
STDERR into scalar
use Test::More tests => 1;
use strict;
use warnings;
local *STDERR;
my $stderr;
open STDERR, '>', \$stderr or die $!;
warn 'error';