Skip to content

Instantly share code, notes, and snippets.

@rudty
rudty / a.java
Created January 6, 2025 14:22
Spring getBeanClass only
public static Class<?> getBeanClass(ConfigurableListableBeanFactory factory, Class<?> requiredType) throws Exception {
String[] candidateNames = factory.getBeanNamesForType(requiredType);
if (candidateNames.length != 1) {
throw new IllegalStateException("type: " + requiredType + " expected single bean but found " + candidateNames.length);
}
String candidateName = candidateNames[0];
BeanDefinition mergedBeanDefinition = factory.getMergedBeanDefinition(candidateName);
@rudty
rudty / JavaSystem.cs
Last active December 20, 2025 07:22
C# System.nanoTime()
class JavaSystem
{
private const long NanosecsPerSec = 1_000_000_000L;
private static readonly long Frequency = Stopwatch.Frequency;
private static readonly bool IsHighResolution = Frequency == NanosecsPerSec;
private static readonly double NanosPerCount = (double)NanosecsPerSec / Frequency;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long NanoTime()
{
const foo = (e) => {
// 대충 매우 오래걸리는 작업
// IO 없이 동기로만 계산
return 1;
};
const { Worker, isMainThread, parentPort } = require("worker_threads");
if (isMainThread) {
const worker = new Worker(__filename);
worker.on("message", (v) => {
@rudty
rudty / gugu.c
Created June 25, 2020 14:56
누가 구구단을 C언어로 만들어달라고함
#include <stdio.h>
const char* GUGU = "%d x %d = %d\n";
const int NEW_LINE = '\n';
int main() {
__asm {
mov ebx, 1;
FOR_I:
cmp ebx, 9;
jg END_FOR_I;
mov ecx, 1;
@rudty
rudty / test.js
Created September 7, 2019 17:56
node error 10.16.0
const sleep =(t) => new Promise(resolve => {
setTimeout(resolve, t);
});
const interval = (timeout, timerHandler, ...param) => {
const k = { run: true };
(async () => {
while (k.run) {
try {
const s = sleep(timeout);
await timerHandler(...param);
@rudty
rudty / list.go
Created May 7, 2017 17:20
go/linkedlist
// test
package main
import (
"fmt"
)
type ListNode struct {
prev *ListNode
next *ListNode
@rudty
rudty / list
Created May 5, 2017 14:34
C/linked list
#pragma once
#define TRUE 1
#define FALSE 0
#define BOOL int
#define OUT
#define NotNull
#define Nullable
#ifdef _MSC_VER
#include <iostream>
//
// xoptional.h
// clang
//
// Created by d on 2017. 4. 30..
// Copyright © 2017년 d. All rights reserved.
//
#ifndef xoptional_h
#define xoptional_h
// ChattServer.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include "Socket.h"
#include "ServerSocket.h"
#include "SQLServerConnection.h"
#include "NetworkStream.h"
#include "MyThreadPool.h"
#include "Serializer.h"
#include "stdafx.h"
#include "ServerSocket.h"
#include "NetworkStream.h"
#include "ReferenceObject.h"
class ServerBase{
//버퍼의 길이는 30정도... 테스트용으로... 작게..
static const int BUFFER_SIZE = 30;
static const int MAX_SUPPORT_CONTENTS = 512;
ServerSocket mServerSocket;