Skip to content

Instantly share code, notes, and snippets.

View aero's full-sized avatar

aero aero

  • Seoul, Republic of Korea
View GitHub Profile
@aero
aero / namespace-autoclean.pl
Created December 10, 2011 03:03
Understanding use namespace::autoclean;
#!/usr/bin/env perl
use 5.010;
my $aref = [];
{
package My;
use List::Util qw/max/;
use namespace::autoclean; # 렉시컬 영역이 끝나면 이 이전에 import된 함수는 패키지에서 제거
use Scalar::Util qw/reftype/;
@aero
aero / reference_dereference.md
Created December 31, 2011 00:35
Perl reference dereference
www.perlmania.or.kr에서 본인이 답변한 내용정리


차례대로 정리를 해보면 perl에서 reference를 dereference 할때는 [sigil]{}연산자를
사용합니다. 여기서 sigil은 결과로 어떤 데이터 타입을 가질것인가를 결정하는거죠.

@array = ( "one", "two", "three", "four", [10, 20, 30, 40, 50] );
$arrayref = \@array;
인 상태에서 $arrayref 안의 one을 가져오려면 해당값은 scalar이므로 sigil은 $가 되고
@aero
aero / gist:2514726
Created April 28, 2012 00:48
Moose vs Mouse vs Moo vs Mo (Loading/Object Creation/Getter/Setter) benchmark
Date: 2012-04-28
Moose 2.0403
Mouse 0.97
Moo 0.091 + Class::XSAccessor 1.13
Mo 0.31
* Loading
time perl -e 'use Moose;'
@aero
aero / misskorea.pl
Created June 29, 2012 06:55
2012 미스코리아 수영복사진 긁기
#!/usr/bin/env perl
use Encode;
use LWP::Simple;
my $c = get('http://eyenews.hankooki.com/mm_theme_view.php?gisa_id=00119568&cate_code=0402');
my %imgs = ( $c =~ m{content:"(.*?)<br>.*?(http://photo.hankooki.com/gisaphoto/inews/2012/06/29/0629.*?\.jpg)"}g );
foreach my $name ( keys %imgs ) {
my $new_name = Encode::encode('cp949', $name); # 윈도우 일때
#my $new_name = Encode::encode('utf8', $name); # 리눅스 utf8 환경일때
@aero
aero / Inline_bench.pl
Last active December 14, 2015 07:59
Pure Perl vs Inline::C, simple function and complex function
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Benchmark;
use Data::Dumper;
timethese(1000000, {
perl => sub { sub_perl(100) },
c => sub { sub_c(100) },
@aero
aero / patch.diff
Created March 30, 2013 15:30
Mojolicious::Plugin::Directory patch for different user local locale (ex. Korean Windows cp949)
--- Directory.pm.org 2012-11-12 13:38:22.000000000 +0900
+++ Directory.pm 2013-03-31 00:23:52.000000000 +0900
@@ -5,6 +5,7 @@
use Cwd ();
use Encode ();
+use Encode::Locale;
use DirHandle;
use Mojo::Base qw{ Mojolicious::Plugin };
use Mojolicious::Types;
@aero
aero / bench.pl
Created July 22, 2013 02:15
p5-mop-redux benchmark
#!/usr/bin/env perl
use 5.012;
use warnings;
use blib;
use Benchmark qw/cmpthese/;
use mop; # 2013-07-22
{
package Raw;
@aero
aero / readline_ev.cpp
Created March 12, 2015 09:12
Example: Integrating readline with libev eventloop.
// g++ -o readline_ev -g readline_ev.cpp -g -lreadline -lev
//
#include <stdlib.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <ev.h>
#include <fcntl.h>
@aero
aero / json_ordered.pl
Last active August 29, 2015 14:20 — forked from olegwtf/json_ordered.pl
json을 읽어 원래 json 필드 순서 유지
use strict;
use Tie::IxHash;
use JSON::PP;
# magic start
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
$obj_parser_sub->(\%obj);
# Rexfile
use Expect;
set connection => "OpenSSH";
my $expect_timeout = 5;
my $git_password = 'f00b4r';
my $sudo_password = 'test';