Skip to content

Instantly share code, notes, and snippets.

View 2minchul's full-sized avatar
😀

Colin (MinChul Lee) 2minchul

😀
View GitHub Profile
# coding=utf-8
import re
import requests
from bs4 import BeautifulSoup, Tag
weather_pattern = re.compile(
r'''(?P<name>[^<>]+?) # name group
\s*?:\s*? # split by ':'
(?P<value> # value group
@2minchul
2minchul / main.go
Created April 16, 2019 05:55
golang http client using specific network adapter
package main
import (
"context"
"fmt"
"io/ioutil"
"net"
"net/http"
)
@2minchul
2minchul / firewallcmd-drop-client.sh
Last active May 27, 2019 02:34 — forked from lesstif/firewallcmd-drop-client.sh
firewall 에서 ip를 차단하기 위한 script
#!/bin/bash
ZONE="service"
function usage {
echo "USAGE: $0 param"
echo ""
echo "$0 -i block-ip1,block-ip2"
echo "$0 -f block-ip-file"
exit 1
}
@2minchul
2minchul / make_models.py
Created June 4, 2019 08:28
sqlacodegen을 python으로 실행하여 models.py 만들기
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import MetaData
from sqlacodegen.codegen import CodeGenerator
url = 'mysql+pymysql://user:password@localhost/dbname'
engine = create_engine(url)
metadata = MetaData(engine)
metadata.reflect(engine)
# https://www.acmicpc.net/problem/16283
def solution(a, b, n, w):
no_result = '-1'
if a == b:
if a + b == w and n == 2:
return '1 1'
else:
return no_result
import cv2 # pip install opencv-python
def find_contained_image(image_path, target_path, min_accuracy=0.8):
img = cv2.imread(image_path, 0)
template = cv2.imread(target_path, 0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
top_left = max_loc
@2minchul
2minchul / proxy.py
Created October 29, 2019 07:48
Python HTTPS proxy server with asyncio streams
import asyncio
import re
from asyncio.streams import StreamReader, StreamWriter
from contextlib import closing
from typing import Tuple, Optional
import async_timeout
StreamPair = Tuple[StreamReader, StreamWriter]
@2minchul
2minchul / pub.py
Created October 30, 2019 14:48
ZeroMQ pubsub with pyzmq asyncio
import asyncio
import datetime
import zmq
import zmq.asyncio
context = zmq.asyncio.Context()
async def run_server(host, port):
@2minchul
2minchul / main.go
Created December 4, 2019 05:06
Cancellation for http request using NewRequestWithContext in Golang
package main
import (
"context"
"net/http"
"time"
)
func main() {
ctx := context.Background()
@2minchul
2minchul / readme.md
Last active April 14, 2020 06:30
install mysql5.7 on Amazon Linux 2

add MySQL Yum Repository

sudo amazon-linux-extras install epel
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum localinstall mysql80-community-release-el7-3.noarch.rpm

yum repolist enabled | grep "mysql.*-community.*" to check default mysql version

enable mysql5.7