Skip to content

Instantly share code, notes, and snippets.

@twkang
twkang / send_tgmsg.py
Created August 17, 2021 03:21
Simple python example to send telegram message
import cx_Oracle
from telethon import TelegramClient
db_server = '1.2.3.4'
db_service = 'DBSID1'
db_id = 'dbuserid'
db_pw = 'dbpassword'
db_sql = """
select to_char(sysdate 'YYYYMMDD') from dual
"""
@twkang
twkang / lun2sol_v2.js
Created September 27, 2018 08:14
음양력변환 Open API 버전 (Google Apps Script)
/**
* 음양력변환 함수 (한국천문연구원 Open API 이용)
* 키발급: https://www.data.go.kr/dataset/15012679/openapi.do
* 발급받은 키로 __openapi_service_key__ 부분 교체
*/
/**
* 음력 10월 3일의 2013년 양력일자를 알고 싶은 경우 lun2sol("2013", "10", "03", 1) 으로 호출
* 응답으로는 '2013/11/05' 와 같이 스트링을 리턴.
* yoon (윤달구분) : 1 - 평달, 2 - 윤달
@twkang
twkang / clien.css
Created January 3, 2016 03:17
clien stylish css
.view_title h4 {
font-family: 나눔고딕;
}
body, p, td, h2, a, input, textarea {
font-family: 나눔고딕;
}
.member {
font-family: 나눔바른고딕;
@twkang
twkang / DrawSVGText.markdown
Last active August 29, 2015 14:14
DrawSVGText
@twkang
twkang / read_cert.py
Last active January 18, 2021 03:58
파이썬으로 공인인증서 파일 읽기 (추가 설치 모듈: cryptography, pyasn1)
import os
import getpass
from pyasn1.codec.der import decoder as der_decoder
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding, hashes
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.asymmetric import padding as asympad
from cryptography.hazmat.primitives.serialization import load_der_private_key
@twkang
twkang / .vimrc
Last active March 25, 2018 01:53
personal vimrc file
" git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
if has('win32')
language English_United States
endif
set langmenu=en_US.UTF-8
set encoding=utf-8
set nocompatible
filetype off
@twkang
twkang / m2crypto_aes.py
Created April 5, 2014 09:14
AES encryption example using M2Crypto module
import sys
import base64
from M2Crypto import Rand, EVP
ENC_METHOD="aes_256_cbc"
MODE_B64, MODE_BIN = 0, 1
IV_LEN = 16
def encrypt(s, key, mode=MODE_BIN):
iv = Rand.rand_bytes(IV_LEN) # can be : iv = os.urandom(IV_LEN)
@twkang
twkang / ssh_socks5.py
Last active April 13, 2017 15:56
ssh connection to server behind socks5 proxy : using socksipy(https://code.google.com/p/socksipy-branch/) and paramiko(https://github.com/paramiko/paramiko)
import time
import socket
import paramiko
import socks
SOCKS5_HOST = "nnn.nnn.nnn.nnn"
SOCKS5_PORT = 12345
SERVER_IP = "nnn.nnn.nnn.nnn"
SERVER_PORT = 54321
@twkang
twkang / lun2sol.js
Last active March 12, 2023 01:37
JavaScript: Google spreadsheet scripts to convert dates between Korean lunar calendar and solar calendar
/**
* 음력일자를 받아서 양력일자를 리턴하는 함수 (한국천문연구원 사이트를 이용)
* 음력 10월 3일의 2013년 양력일자를 알고 싶은 경우 lun2sol(2013, 10, 3, 1) 으로 호출
* 응답으로는 '2013/11/05' 와 같이 스트링을 리턴.
* yoon (윤달구분) : 1 - 평달, 2 - 윤달
*/
function lun2sol(yyyy, mm, dd, yoon) {
yyyy = parseInt(yyyy, 10); mm = parseInt(mm, 10); dd = parseInt(dd, 10);
if ((yyyy <= 1391) || (yyyy >= 2050)) {
@twkang
twkang / easy_aes.py
Last active May 19, 2021 08:27
Python: Simple AES with zlib
#!/data/local/bin/python
# AES encryption/decryption with zlib compression
from Crypto.Cipher import AES
from Crypto import Random
import hashlib
import zlib
import base64
_block_size = 16