Skip to content

Instantly share code, notes, and snippets.

@sng2c
sng2c / monosami.pl
Created November 9, 2013 19:57
make multi-language smi subtitle file to mono-language
#!/usr/bin/env perl
use 5.018;
#use Encode qw(from_to);
my $smi_path = $ARGV[0];
my $want = lc $ARGV[1];
my $smi;
{
local $/;
undef $/;
open(my $smifh,'<', $smi_path);
import scala.swing._
import scala.swing.event._
object ButtonApp extends SimpleSwingApplication {
def top = new MainFrame {
title = "My Frame"
contents = new GridPanel(2, 2) {
hGap = 3
vGap = 3
contents += new Button {
@sng2c
sng2c / proxy.pl
Last active December 27, 2015 15:28
perl proxy server
#!/usr/bin/env perl
use HTTP::Proxy;
my $proxy = HTTP::Proxy->new(
host => '',
port => 8080,
maxchild=>10,
);
$proxy->start;
@sng2c
sng2c / regpat.pl
Last active December 27, 2015 01:29
컴파일된 정규표현식의 원래 입력패턴을 알아내는 법
#!/usr/bin/env perl
use re 'regexp_pattern';
my $reg = qr/(?i)abc/s;
my ($pat,$flag) = regexp_pattern $reg;
print "pat :$pat\n"
print "flag:$flag\n";
# pat :(?i)abc
# flag:is
@sng2c
sng2c / KorMailSend.pm
Created September 6, 2013 02:04
한글로 메일 보내기
package KorMailSend;
use strict;
use warnings;
use MIME::Lite;
use MIME::Base64;
use Encode qw(encode);
sub sendmail{
my ($from,$to,$subj,$cont) = @_;
my $subj2 = '=?UTF8?B?' . encode_base64($subj) .'?=';
@sng2c
sng2c / start.sh
Last active December 20, 2015 17:48
Create 'autostart' directory on a directory which startall.pl is on. Each app directory must have start.sh and put or link the app directory in autostart directory. If you launch startall.pl, all of the start.sh scripts are running within each 'screen' processes.
#!/bin/sh
# An example of start.sh
./app_pkg.pl daemon -l 'http://localhost:50005'
@sng2c
sng2c / README_VROOM_CUR.markdown
Last active December 20, 2015 16:29
vroom_cur.pl

VRoom current page viewer

You can see current editing slide page on VRoom with typing 'SS' in VIM. To activate this function, move 'vroom_cur.pl' to your path. And append below one line to .vimrc file.

map SS :w|:execute "!vroom_cur.pl '".bufname("%")."' ".line(".")

@sng2c
sng2c / detect_repetition.md
Last active March 6, 2022 10:33
detect_repetition.md

리스트에 기호들이 들어 있을 때, 연속된 기호가 일정한 거리를 두고 다시 나타나는 것을 반복이라고 하기로 하구요. 그 연속되는 기호의 단위 묶음을 반복셋이라고 하겠습니다. 같은 위치에서 시작하는 반복셋은 여러개가 있을 수 있습니다.

A B C A B C 의 경우에는

A _ _ A _ _  : offset 2
A B _ A B _  : offset 1

A B C A B C : offset 0

#!/usr/bin/env perl
use lib './lib';
use Parse::Token::Lite;
use LWP::Simple;
my $urlpat = qr@https?://[0-9a-zA-Z-_#\?=&\.\@\%:/]+@;
my %rules = (
MAIN=>[
{name=>HTML_ENTITY_VAL, re=>qr/&\S+?;/},
{name=>HTML_COMMENT, re=>qr/<!--.+?-->/ms},
{name=>TAG_START_IN, re=>qr/<\!?\w+/, state=>[qw(+TAG_IN)] },
@sng2c
sng2c / startall.pl
Last active December 19, 2015 19:29
Simple scripts starting/stopping daemons with own screen sessions. Make 'autostart' directory, and put symbolic link dirs having 'start.sh' file in it.
#!/usr/bin/env perl
use strict;
use File::pushd;
my @apps = <autostart/*>; # Make 'autostart' directory, and put symbolic link dirs having 'start.sh' file in it.
foreach my $d (@apps){
my $dir = pushd($d);
$d =~ m@([^/]+)$@;
my $name = $1;