Skip to content

Instantly share code, notes, and snippets.

Avatar

aero aero

  • Seoul, Republic of Korea
View GitHub Profile
@aero
aero / misskorea.pl
Created Jun 29, 2012
2012 미스코리아 수영복사진 긁기
View misskorea.pl
#!/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 / reference_dereference.md
Created Dec 31, 2011
Perl reference dereference
View reference_dereference.md
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 / namespace-autoclean.pl
Created Dec 10, 2011
Understanding use namespace::autoclean;
View namespace-autoclean.pl
#!/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 / remote_wmi.pl
Created Oct 4, 2011
Query remote serverinfo via Windows WMI
View remote_wmi.pl
#!/usr/bin/env perl
#How to use
#> perl remote_wmi.pl hostname Win32_ComputerSystem
#> perl remote_wmi.pl hostname Win32_PerfFormattedData_PerfOS_System | findstr SystemUpTime
# Here's a list of a few Helpful classes to get you started.
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084%28v=vs.85%29.aspx
# Win32_ComputerSystem
# Win32_Processor
# Win32_TimeZone
# ...
@aero
aero / remote_exe.vbs
Created Sep 29, 2011
Create process via Windows WMI
View remote_exe.vbs
'How to use -> cscript remote_exe.vbs hostname "cmd /c dir"
strComputer = Wscript.Arguments(0)
strCommand = Wscript.Arguments(1)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create( strCommand , Null, Null, intProcessID )
Select Case errReturn
Case 0 WScript.Echo "Command successfully completed " & "Process ID: " & intProcessID
Case 2 WScript.Echo "Access Denied"
Case 3 WScript.Echo "INsufficient Privilege"
@aero
aero / remote_exe.pl
Created Sep 29, 2011
Create process via Windows WMI
View remote_exe.pl
#!/usr/bin/env perl
#How to use -> perl remote_exe.pl hostname "cmd /c dir"
use 5.010;
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
my ($strComputer, $strCommand) = @ARGV;
my $objWMIService = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate,(security)}//$strComputer\\root\\cimv2:Win32_Process");
@aero
aero / Perl_OOP_benchmark.pl
Created Sep 15, 2011
Moose vs Mouse vs Moo vs Mo
View Perl_OOP_benchmark.pl
* Bo.pm
package Bo;
sub new {
my ($class) = @_;
return bless { buff => 0 }, $class;
}
sub buff {
@aero
aero / koreanspeller.py
Created Jan 16, 2011
koreanspeller.py
View koreanspeller.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import re
class KoreanSpeller:
def __init__(self, text):
self.text = text
View gist:729778
#!/usr/bin/env perl
# Usage: twit2irc.pl irc.example.com 6667 nickname '#channel1' '#channel2' '#channel3'
use strict;
use warnings;
use Encode qw/encode decode/;
use URI::Escape;
use utf8;
use String::IRC;
use AnyEvent::IRC::Client;
#use AnyEvent::Socket;
View dcinside_racinggirl_scraper
# UNIX
perl -MLWP::Simple -e 'foreach my $n (227180..227196){ my @imgs = (my $t=get("http://gall.dcinside.com/list.php?id=racinggirl&no=$n")) =~ m!(http://dcimg1.dcinside.com/viewimage.php[^'"'"']+)!g; foreach (0..$#imgs) { print "Getting -> $imgs[$_]\n"; getstore($imgs[$_], $n."_".$_.".jpg") } }'
# Windows
perl -MLWP::Simple -e "foreach my $n (227180..227196){ my @imgs = (my $t=get(qq{http://gall.dcinside.com/list.php?id=racinggirl&no=$n})) =~ m!(http://dcimg1.dcinside.com/viewimage.php[^']+)!g; foreach (0..$#imgs) { print qq/Getting -> $imgs[$_]\n/; getstore($imgs[$_], $n.'_'.$_.'.jpg') } }"
You can’t perform that action at this time.