Skip to content

Instantly share code, notes, and snippets.

View seunggabi's full-sized avatar
🎯
Focusing

Seunggabi Kim seunggabi

🎯
Focusing
View GitHub Profile
@seunggabi
seunggabi / check_restart_tomcat.py
Last active November 4, 2019 07:01
check_restart_tomcat.py
# 5 * * * * python3 /home1/irteam/check_restart_tomcat.py
from urllib.request import urlopen
from urllib.error import HTTPError
import os
import time
URL = ""
TOMCAT_PATH = "/home/user/apps/tomcat/bin/"
@seunggabi
seunggabi / byte2string.py
Created October 16, 2019 15:08
byte2string.py
from pyparsing import unicode
from bs4 import BeautifulSoup
path = ""
binary_filename = "binary.txt"
i = open(binary_filename, "rb")
input = i.read()
input = unicode(input, errors='ignore')
@seunggabi
seunggabi / sendEmail.java
Last active November 9, 2019 14:17
sendEmail.java
public static void sendEmail(String emailString, String subject, String message, File file) {
String[] emails = StringUtils.split(emailString, ",");
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "localhost");
Session session = Session.getDefaultInstance(props);
MimeMessage msg = new MimeMessage(session);
try {
@seunggabi
seunggabi / makeFile.java
Last active November 9, 2019 12:53
makeFile.java
private static File makeFile(List<String> lines) throws IOException {
File temp = File.createTempFile(FILENAME, "");
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp, true), StandardCharsets.UTF_8));
for(String line : lines) {
bw.write(line + "\n");
}
bw.close();
return temp;
@seunggabi
seunggabi / FileUtils.java
Created November 8, 2019 12:41
FileUtils.java
public class FileUtils {
public static void joinFiles(File destination, File[] sources) throws IOException {
OutputStream output = null;
try {
output = createAppendableStream(destination);
for (File source : sources) {
appendFile(output, source);
}
} finally {
IOUtils.closeQuietly(output);
@seunggabi
seunggabi / isNowBetweenTime.java
Created November 26, 2019 06:01
isNowBetweenTime.java
// if(DateUtils.isNowBetweenTime("2019-11-26 15:20:00.0", "2019-12-25 23:59:59.0")) {
public static boolean isNowBetweenTime(String start, String end) {
long now = System.currentTimeMillis();
long startTime = (start == null) ? now : Timestamp.valueOf(start).getTime();
long endTime = (end == null) ? now : Timestamp.valueOf(end).getTime();
return startTime <= now && now <= endTime;
}
@seunggabi
seunggabi / proxy.py
Last active January 27, 2020 12:43
proxy.py
# reference: https://wkdtjsgur100.github.io/selenium-change-ip/
# brew install geckodriver
# brew install tor
# brew services restart tor
from selenium import webdriver
from bs4 import BeautifulSoup
import os
@seunggabi
seunggabi / io.py
Created January 27, 2020 12:51
io.py
import time
import os
class IO:
def __init__(self, path, name):
if not os.path.exists(path):
os.makedirs(path)
self.path = path
@seunggabi
seunggabi / stringUtils.py
Created January 27, 2020 12:51
stringUtils.py
import re
class StringUtils:
@staticmethod
def removeTags(contents):
contents = re.sub("<\/?[\w\?\"\.\=\-\ ]*>", "", contents)
contents = re.sub("(\\n\\t*\\n)+", "\\n", contents)
return contents
@seunggabi
seunggabi / print_access_log.sh
Created March 2, 2020 16:29
print_access_log.sh
#!/bin/sh
# ./print_access_log.sh keyword 20200302 server_list.txt
### server_list.txt ###
a
b
c
#######################
keyword=$1