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 / 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 / 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 / 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 / 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 / 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 / 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 / checkHttpStatus.py
Created September 28, 2019 08:19
checkHttpStatus.py
from urllib.request import urlopen
from urllib.error import HTTPError
def checkHttpStatus(URL):
try:
res = urlopen(URL)
return res.status
except HTTPError as e:
code = e.getcode()
@seunggabi
seunggabi / [Github] close change files by jQuery
Last active March 9, 2020 07:49
[Github] close change files by jQuery
$$('.btn-octicon.js-details-target').forEach(a => a.click())
$$('.js-reviewed-checkbox:checked').forEach(a => a.click())
@seunggabi
seunggabi / reverseString.js
Created September 17, 2019 10:25
reverseString.js
function reverse(str) {
return str.split('').reserve().join('')
}
@seunggabi
seunggabi / getDateTime.java
Created September 3, 2019 07:27
getDateTime.java
public static String getDateTime() {
Date from = new Date();
SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return transFormat.format(from);
}