Skip to content

Instantly share code, notes, and snippets.

View sangheonhan's full-sized avatar
🤔
Minimalizing...

Sangheon Han sangheonhan

🤔
Minimalizing...
View GitHub Profile
@sangheonhan
sangheonhan / splip.php
Created January 11, 2019 07:07
SplType을 이용해 SplIp 타입을 만드는 예제
<?php
class SplIp extends SplType
{
const __default = 0;
public function __construct($initial_value = '0.0.0.0', $strict = true)
{
if ($strict && ip2long($initial_value) === false) {
throw new Exception('Invalid IP');
}
@sangheonhan
sangheonhan / hrtime.php
Created January 11, 2019 07:09
나노초 단위 시간 측정을 위한 HRTime 익스텐션 예제 코드
<?php
$c = new HRTime\StopWatch;
$c->start();
/* do some interesting stuff*/
$c->stop();
$elapsed0 = $c->getLastElapsedTime(HRTime\Unit::NANOSECOND);
/* do something else */
@sangheonhan
sangheonhan / 256colors.pl
Created January 11, 2019 07:09
터미널 256색 출력 (Perl)
#! /usr/bin/env perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@sangheonhan
sangheonhan / cleaver-firefox.css
Created January 11, 2019 07:09
firefox에서 cleaver의 <strong>, <b>가 볼드로 처리되지 않는 문제를 수정하는 CSS
strong, b {
font-weight: bold;
}
@sangheonhan
sangheonhan / echo.php
Created January 11, 2019 07:09
React Echo Server Example
<?php
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
$connector = new React\SocketClient\Connector($loop, $dns);
@sangheonhan
sangheonhan / dumpgit.pl
Created January 11, 2019 07:09
특정 디렉토리 안의 git 저장소들을 덤프하는 펄 스크립트
#! /usr/bin/perl
use strict;
use warnings;
if ( $#ARGV < 1 ) {
print "Usage : dumpgit.pl <git upper dir> <target dir>\n";
exit 1;
}
@sangheonhan
sangheonhan / brewservice.pl
Created January 11, 2019 07:09
Homebrew로 설치한 서비스 실행/중지 스크립트
#! /usr/bin/env perl
use strict;
use warnings;
our %services = (
'nginx' => '~/Library/LaunchAgents/homebrew.mxcl.nginx.plist',
'php55' => '~/Library/LaunchAgents/homebrew.mxcl.php55.plist',
'gearman' => '~/Library/LaunchAgents/homebrew.mxcl.gearman.plist',
'memcached' => '~/Library/LaunchAgents/homebrew.mxcl.memcached.plist',
@sangheonhan
sangheonhan / standard_deviation.pl
Created January 11, 2019 07:09
숫자들의 표준 편차를 구하는 스크립트
#! /usr/bin/perl
use strict;
use warnings;
use POSIX qw/floor ceil/;
my @data;
while ( <> ) {
chomp;
@sangheonhan
sangheonhan / terminal-color.sh
Created January 11, 2019 07:09
터미널 256색 출력 (bash)
#! /bin/bash
COLUMNS=15
x=`tput op`
y=`printf %$((${COLUMNS}-6))s`
for i in {0..256}
do
o=00$i
echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x
done
@sangheonhan
sangheonhan / dumpsvn.pl
Created January 11, 2019 07:09
특정 디렉토리 안의 svn 저장소들을 덤프하는 펄 스크립트
#! /usr/bin/perl
use strict;
use warnings;
if ( $#ARGV < 0 ) {
print "Usage : dumpsvn.pl <svn root dir>\n";
exit 1;
}