Skip to content

Instantly share code, notes, and snippets.

View kyupid's full-sized avatar
🏃‍♂️

Yeonwoo Kim kyupid

🏃‍♂️
View GitHub Profile
@kyupid
kyupid / main.c
Created December 10, 2023 07:50
double linked list
#include <stdio.h>
#include <string.h>
#include <malloc/_malloc.h>
typedef struct NODE {
char szData[64];
int index;
struct NODE *prev;
struct NODE *next;
@kyupid
kyupid / StreamController.java
Created July 27, 2023 13:36
stream flush response test
@RestController
public class StreamController {
@GetMapping("/stream")
public ResponseEntity<StreamingResponseBody> streamData() {
StreamingResponseBody responseBody = out -> {
for (int i = 0; i < 1000; i++) {
out.write(("Data " + i + "\n").getBytes());
out.flush();
try {
@kyupid
kyupid / AsyncConfig.java
Created March 23, 2022 06:22
스프링 이메일 비동기 처리
@Configuration
@EnableAsync
public class AsyncConfig extends AsyncConfigurerSupport {
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2); // 실행 대기 중인 Thread 개수
executor.setMaxPoolSize(10); // 동시에 동작하는 최대 Thread 개수
executor.setQueueCapacity(500);// CorePool이 초과될때 Queue에 저장했다가 꺼내서 실행된다. (500개까지 저장함)
// 단, MaxPoolSize가 초과되면 Thread 생성에 실패할 수 있음.
@kyupid
kyupid / invokedPageFromHistoryBack.js
Created March 22, 2022 05:24
뒤로가기 이벤트를 감지하는 이벤트
// history.back()을 통해 이 페이지가 호출되었을때 테스트!!! 를 확인가능
window.onpageshow = function (event) {
if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
alert("테스트!!!");
}
}
@kyupid
kyupid / 쿼리스트링_to_JSON.js
Last active March 21, 2022 09:21
쿼리스트링 to JSON
function QueryStringToJSON(qs) {
//파라메터별 분리
var pairs = qs.split('&');
var result = {};//json 빈 객체
//각 파라메터별 key/val 처리
pairs.forEach(function(pair) {
pair = pair.split('=');//key=val 분리
result[pair[0]] = decodeURIComponent(pair[1] || "");
@kyupid
kyupid / foo.java
Created March 2, 2022 13:26
SPRING_SECURITY_CONTEXT 유저 ROLE 변경
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
List<Role> roles = new ArrayList<>();
roles.add(Role.USER);
List<GrantedAuthority> actualAuthorities = roles.stream().map(role -> new
SimpleGrantedAuthority(role.getKey())).collect(Collectors.toList());
Authentication newAuth = new
UsernamePasswordAuthenticationToken(auth.getPrincipal(), auth.getCredentials(), actualAuthorities);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(newAuth);
@kyupid
kyupid / RoleConverter.java
Created March 2, 2022 12:20
JPA enum property value 디비에 넣기
public class RoleConverter implements AttributeConverter<Role, String> {
@Override
public String convertToDatabaseColumn(Role attribute) {
return attribute.getKey();
}
@Override
public Role convertToEntityAttribute(String dbData) {
return EnumSet.allOf(Role.class).stream()
@kyupid
kyupid / profile.md
Last active May 17, 2025 03:44
Skills

profile

@kyupid
kyupid / AttrWrapper.java
Created February 25, 2022 09:56
특정 세션 attribute만 타임아웃 설정하기
class AttrWrapper<T extends Serializable> {
public final T value;
public final long timeoutMs;
private long lastAccess = System.currentTimeMillis();
public AttrWrapper(T value, long timeoutMs) {
this.value = value;
this.timeoutMs = timeoutMs;
}
public boolean isValid() {
@kyupid
kyupid / timer.html
Last active February 25, 2022 09:22
자바스크립트 타이머
<body>
<div id="demo"></div>
</body>