Skip to content

Instantly share code, notes, and snippets.

View DPS0340's full-sized avatar

Jiho Lee DPS0340

View GitHub Profile
@DPS0340
DPS0340 / etq.sol
Last active February 24, 2022 13:26
etq v2
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
import "@openzeppelin/[email protected]/utils/math/SafeMath.sol";
contract Etiquette is ERC20, Ownable {
using SafeMath for uint256;
@DPS0340
DPS0340 / etq.sol
Last active February 24, 2022 13:16
etq v1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
import "@openzeppelin/[email protected]/utils/math/SafeMath.sol";
contract Etiquette is ERC20, Ownable {
using SafeMath for uint256;
@DPS0340
DPS0340 / main.py
Last active August 7, 2021 21:20
non-blocking model with python async / await
import asyncio
import time
async def async_wrapper(func):
loop = asyncio.get_event_loop()
return await loop.run_in_executor(None, func)
found = False
def consumer():
// useState 사용
const [[diagram, feature, warning, vitalState], setDogInfo] = useState([
"강아지 다이어그램",
"강아지 특징",
"강아지 주의사항",
"Vital State",
]);
// setDogInfo 사용
// feature를 업데이트 한다고 하면..
@DPS0340
DPS0340 / main.py
Created March 15, 2021 10:21
google image search crawler - low quality image only
import requests
from pyquery import PyQuery as PQ
from urllib.request import urlretrieve
from urllib.parse import quote, unquote
import imagehash
from PIL import Image
import os
UA = r"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
@DPS0340
DPS0340 / main.py
Created March 14, 2021 08:42
fish name crawler
import requests
from pyquery import PyQuery as PQ
import re
import random
import csv
max_length = 100
url = r'https://namu.wiki/w/%EB%B6%84%EB%A5%98:%EC%83%9D%EC%84%A0'
appendix = ['', '?namespace=문서&cfrom=붉돔']
filename = 'result.csv'
@DPS0340
DPS0340 / install-install.sh
Last active March 12, 2021 11:12
install .deb package without sudo permission
prev_dir=$(pwd)
mkdir -p install
cd install
wget https://gist.githubusercontent.com/DPS0340/1fff66d8a34c2d1b97e22a0b29fae169/raw/3c792d12a317836389f72c0690e068d5ad0c66db/install.sh
chmod +x install.sh
echo "PATH=$(pwd):\$PATH" >> ~/.bashrc
source ~/.bashrc
cd $prev_dir
# segment tree library
# MIT License, 2021 jiho lee
class SegTree:
def __init__(self, original: list, n: int) -> None:
len_original = len(original)
self.tree = [0 for i in range(len_original * 4)]
# it uses reference
self.original = original
self.init(1, 0, n)
@DPS0340
DPS0340 / executor.py
Created November 14, 2020 09:53
eval() considered harmful. really.
s = '''
def convert(k):
res = []
while k:
rem = k % 36
if rem >= 10:
rem = chr((rem - 10) + ord('a'))
else:
rem = chr(rem + ord('0'))
Python 3 hrs 14 mins ███████░░░░░░░░░░░░░░ 33.9%
Other 2 hrs 21 mins █████▏░░░░░░░░░░░░░░░ 24.6%
Text 1 hr 6 mins ██▍░░░░░░░░░░░░░░░░░░ 11.7%
Java 1 hr 4 mins ██▎░░░░░░░░░░░░░░░░░░ 11.2%
YAML 40 mins █▍░░░░░░░░░░░░░░░░░░░ 7.1%