Skip to content

Instantly share code, notes, and snippets.

@bluesid
bluesid / copy_log_batch.bat
Last active January 27, 2019 04:12
여러대 윈도우 서버의 로그 파일 복사하기 #dos #batch #xcopy
@ECHO OFF
IF "%1" == "" GOTO END_A
IF "%2" == "" GOTO END_A
ECHO 파일 복사 및 생성을 시작합니다. 각 웹서버에 네트워크 연결이 되어 있어야 합니다.
@ECHO ON
@ECHO OFF
SET TODAY=%date:~-10,4%%date:~-5,2%%date:~-2,2%
@bluesid
bluesid / curl_get_sample
Last active January 27, 2019 04:13
#curl
--기본
curl http://openapi.seoul.go.kr:8088/sample/json/ForecastWarningUltrafineParticleOfDustService/1/5/
--헤더 추가
curl -H 'Content-Type: application/json' http://openapi.seoul.go.kr:8088/sample/json/ForecastWarningUltrafineParticleOfDustService/1/5/
@bluesid
bluesid / api_call_test.cmd
Last active January 27, 2019 04:12
#dos #batch #wget #api #test
@rem hosts file backup
xcopy "%systemroot%\system32\drivers\etc\hosts" ".\" /s /y
echo 192.168.0.1 openapi.seoul.go.kr #testserver-01 > "%systemroot%\system32\drivers\etc\hosts"
ipconfig /flushdns
wget -O result01.txt "http://openapi.seoul.go.kr:8088/sample/json/ForecastWarningUltrafineParticleOfDustService/1/5/"
echo 192.168.0.2 openapi.seoul.go.kr #testserver-02 > "%systemroot%\system32\drivers\etc\hosts"
ipconfig /flushdns
wget -O result02.txt "http://openapi.seoul.go.kr:8088/sample/json/ForecastWarningUltrafineParticleOfDustService/1/5/"
extension NSDate
{
func hour() -> Int
{
//Get Hour
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(.Hour, fromDate: self)
let hour = components.hour
//Return Hour
extension String
{
func replace(target: String, withString: String) -> String
{
return self.replacingOccurrences(of: target, with: withString, options: NSString.CompareOptions.literal, range: nil)
}
}
extension String
{
func replace(target: String, withString: String) -> String
{
return self.stringByReplacingOccurrencesOfString(target, withString: withString, options: NSStringCompareOptions.LiteralSearch, range: nil)
}
}
extension Date
{
func hour() -> Int
{
//Get Hour
let calendar = Calendar.current
let hour = calendar.component(.hour, from: Date())
//Return Hour
return hour
@bluesid
bluesid / py_service.py
Created January 31, 2017 05:24
python service on windows
### Run Python scripts as a service example (ryrobes.com)
### Usage : python aservice.py install (or / then start, stop, remove)
import win32service
import win32serviceutil
import win32api
import win32con
import win32event
import win32evtlogutil
import os, sys, string, time
@bluesid
bluesid / ObjectMapper_PrettyJson.java
Last active January 27, 2019 04:10
ObjectMapper를 이용하여 JSON을 이쁘게... #java #objectmapper #json #prettyjson
/*
mapper의 writeValueAsString()
*/
ObjectMapper mapper = new ObjectMapper();
System.out.println(mapper.writeValueAsString(jsonString));
{"attributes":[{"nm":"ACCOUNT","lv":[{"v":{"Id":null,"State":null},"vt":"java.util.Map","cn":1}],"vt":"java.util.Map","status":"SUCCESS","lmd":13585},{"nm":"PROFILE","lv":[{"v":{"Party":null,"Ads":null},"vt":"java.util.Map","cn":2}],"vt":"java.util.Map","status":"SUCCESS","lmd":41962}]}
/*
mapper의 defaultPrettyPrintingWriter().writeValueAsString()
@bluesid
bluesid / inspect_test.py
Last active January 27, 2019 04:08
python inspect모듈 활용 filename, line no, function name, source view #python #inspect #currentframe #getframeinfo
# -*- coding: utf-8 -*-
import inspect
from inspect import currentframe, getframeinfo
import dis
def test():
frame_info = getframeinfo(currentframe())
print 'file name :', frame_info.filename
print 'line no :' , frame_info.lineno
print 'function name :', frame_info.function