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 / demacboogi.pl
Created July 25, 2011 07:44
Rename MacOS X NFD hangule to NFC
#!/usr/bin/env perl
# 사용법
# perl demacboogi.pl *.zip #zip파일만 변환
# perl demacboogi.pl #모든파일 변환
use 5.010;
use strict;
use warnings;
use Encode qw/encode decode/;
use Unicode::Normalize qw/compose/;
use File::Copy;
@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 / remote_exe.vbs
Created September 29, 2011 08:20
Create process via Windows WMI
'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 / group5.pl
Created December 11, 2016 00:35
5개씩 묶기
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
my @m = 1..17;
my @m5;
my $step = 5;
@aero
aero / autoinstall2.pl
Last active November 20, 2016 11:24
Automatically install all dependence modules through cpanminus within core Perl distribution.
#!/usr/bin/env perl
BEGIN {
require FindBin;
require lib;
my $locallib_path = "$FindBin::RealBin/locallib/$^V";
lib->import("$locallib_path/lib/perl5");
my $cpanm;
@aero
aero / autoinstall.pl
Last active November 20, 2016 11:23
Automatically install all dependence modules through cpanminus within core Perl distribution.
#!/usr/bin/env perl
BEGIN {
my @REQ_MODULES = qw/
Mojolicious
Text::CSV_XS
/;
require FindBin;
require lib;
@aero
aero / parse.pl
Created January 21, 2016 02:54
text section parsing
#!/usr/bin/env perl
use strict;
use warnings;
my $s = do { local $/; <DATA> };
my %section = $s =~ m/
^{{{(.*?)}}}-+$
\n(.*?)
(?=\n{{{.*?}}}-+$|\Z)
@aero
aero / mojo_mysql_reconnect.pl
Last active December 23, 2015 08:46
Solving Mojolicious fork-based multi-processes daemon(eg. hypnotoad) Mojo::mysql connection timeout close issue.
use Mojolicious::Lite;
use Mojo::mysql;
helper db => sub {
state $db = Mojo::mysql->new('mysql://user:pass@/task')->db;
if (! $db->ping ) {
$db->dbh( $db->dbh->clone() ) or die "cannot connect to db";
}
return $db;
};
@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 / 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;