Skip to content

Instantly share code, notes, and snippets.

View joonahn's full-sized avatar

Seokjoon Ahn joonahn

  • POSTECH
  • Pohang
View GitHub Profile
import inspect
def get_caller_source_lines(cls, num_of_prev_functions=1):
# num_of_prev_functions
frame = inspect.stack()[1 + num_of_prev_functions]
_, linenum, _, _, _ = inspect.getframeinfo(frame)
return linenum
import logging.config
import pkg_resources
resource_package = __name__
resource_path = '../logging.conf'
conf_file = pkg_resources.resource_filename(resource_package, resource_path)
print(conf_file)
logging.config.fileConfig(resource_path)
mylog = logging.getLogger("dev")
@joonahn
joonahn / firefox_ibkbizware.js
Last active February 6, 2018 07:19
IBKbizware 가 windows 64bit firefox에서 동작하지 않는 문제를 브라우저 수준에서 해결
// ==UserScript==
// @name bizware login script
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://www.ibkbizware.co.kr/*
// @grant none
// ==/UserScript== eElement.insertBefore(newFirstElement, eElement.firstChild);
@joonahn
joonahn / inject.js
Created February 6, 2018 07:10
inject script with tampermonkey
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://targetsite.com/*
// @grant none
// ==/UserScript==
@joonahn
joonahn / get_price.py
Created January 3, 2018 02:11
Get price of ripple
from urllib.request import urlopen, Request
from urllib.parse import urlencode
import json
import datetime
currency = 'xrp'
data = urlopen('https://api.coinone.co.kr/ticker/?currency=' + currency).read()
jsondata = json.loads(data)
time = datetime.datetime.fromtimestamp(int(jsondata["timestamp"])).strftime("%H:%M:%S")
@joonahn
joonahn / remove_unused_docker_volume.sh
Created October 20, 2017 07:01
Remove unused docker volumes
#!/bin/bash
sudo find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
docker ps -aq | xargs docker inspect | jq -r '.[] | .Mounts | .[] | .Name | select(.)'
) | sudo xargs -r rm -fr
@joonahn
joonahn / monitor_cpu.py
Created October 19, 2017 09:37
CPU usage of one minute per process
import psutil
def monitor_cpu(pid):
p = psutil.Process(pid)
for i in range(0, 60):
print p.cpu_percent(interval=1)

ElasticSearch Java API

ElasticSearch에 쿼리할 내용을 만들고 쿼리한 뒤 결과까지 반환해 주는 Helper API입니다.

Builder 생성자

Index, StartTime, endTime 만 추가하면 알아서 indexlist string 만들어 줌

    Builder(String, Long, Long); // 범위 내 날짜 index에서 검색
    Builder(String, Long); // 지정한 날짜부터 지금까지의 index 검색
    Builder(String); // 처음부터 끝까지 모든 index 검색