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 / code-to-md.php
Created January 5, 2021 01:02
Markdownify가 변환하지 못하고 남긴 <pre><code> 블럭을 Makrdown으로 변환
<?php
function markdownFiles(string $directory) : \Generator
{
$recurDirIter = new RecursiveDirectoryIterator("./posts/");
$recurIterIter = new RecursiveIteratorIterator($recurDirIter);
$regexIter = new RegexIterator($recurIterIter, '/^.+\.md$/', \RecursiveRegexIterator::GET_MATCH);
foreach ($regexIter as $filePath) {
yield $filePath[0];
@sangheonhan
sangheonhan / docker-compose.yml
Created September 9, 2019 06:18
GUI 실행을 위한 Docker Compose 설정
version: "3.4"
services:
ubuntu:
image: ubuntu:18.04
container_name: ubuntu
command:
- sleep
- infinity
volumes:
- /run/user/1000:/run/user/1000
@sangheonhan
sangheonhan / localhost
Created January 11, 2019 07:09
수정 없이 여러 도메인의 사이트를 작업하기 위한 nginx 설정입니다. 간단한 개발이나 테스트 목적으로 만들었습니다.
server {
listen 80;
server_name localhost;
root /home/bookworm/Sites;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
@sangheonhan
sangheonhan / DateTimeExtra.php
Created January 11, 2019 07:09
월의 몇 번째 주차인지를 구하는 weekofmonth 메소드를 추가한 DateTimeExtra 클래스
<?php
class DateTimeExtra extends DateTime {
public function weekofmonth() {
$thursday = $this->thursday();
if ( $thursday->format('n') != $this->format('n') ) {
$date = $thursday;
}
else {
@sangheonhan
sangheonhan / rhombus.pl
Created January 11, 2019 07:09
DEVON 2013 텍스트큐브 부스에서 낸 마름모꼴을 그리는 문제 풀이. 조건은 소스 코드가 150 자(byte) 이내여야 한다.
$_="5
5
41
33
25
0070
25
33
41
5
@sangheonhan
sangheonhan / telgen.php
Created January 11, 2019 07:09
전화번호 수집 방지
<?php
$digitTable = array(
0 => array('0', '○', 'О'),
1 => array('① ', '⑴ ', '1'),
2 => array('② ', '⑵ ', '2'),
3 => array('③ ', '⑶ ', '3'),
4 => array('④ ', '⑷ ', '4'),
5 => array('⑤ ', '⑸ ', '5'),
6 => array('⑥ ', '⑹ ', '6'),
@sangheonhan
sangheonhan / SplObserver.php
Created January 11, 2019 07:09
SplObjserver 예제
<?php
class Channel implements Splsubject
{
private $members;
private $name;
private $teller;
private $message;
public function __construct($name)
@sangheonhan
sangheonhan / rootpath.conf
Created January 11, 2019 07:09
도메인에 따른 nginx의 동적 root 설정을 위한 map 설정
map $http_host $rootpath {
~^(?<domain>.+)\.dev$ $domain;
default /;
}
@sangheonhan
sangheonhan / convutf8.sh
Created January 11, 2019 07:09
php, c, cc, h, cpp, README*, Makefile 파일을 UHC에서 UTF-8로 인코딩을 바꾸는 스크립트
#!/bin/sh
for i in $( find . -iregex ".*\.\(php\|c\|cc\|h\|cpp\)$" ); do
if [ -f $i ]; then
iconv -c -f UHC -t utf-8 -o $i.tmp $i
mv -f $i $i.bak
mv -f $i.tmp $i
echo $i
fi
done
@sangheonhan
sangheonhan / tintin
Created January 11, 2019 07:09
KIT, MSD, EVE 머드에서 사용하던 틴틴++(TinTin++) 이동 앨리어스
#nop
#nop Auto Walk commands
#nop
#alias {vpath} {#alias {2*}}
#nop
#nop From midgard
#alias {2ring} {#2 s;#6 w;s;e;n;n;w;w;#5 n;e;l ring}
#alias {2build} {s;s;#2 e;#2 s}
#alias {2shire} {2edge;w;s;e;#2 n}
#alias {2west} {2edge;#3 n;#3 e;#2 n;e;#7 n}