Skip to content

Instantly share code, notes, and snippets.

@zeraf29
zeraf29 / td-agent-ssl.md
Last active May 16, 2023 02:15
Setting SSL verification for Fluentd on Windows(td-agent) with security network

Setting SSL verification for Fluentd on Windows(td-agent) with security network

Normaly you don't have to set this contents.
But if you install Fluentd on Windows(td-agent) with security network like company network, you will meet ssl verification error.
These are setting ways for that situation.
  1. get your security network's ssl verfication file (pem, crt, cer ...)
    • if you don't have pem file, change from crt or cer to pem. (you can find a way on google)
@zeraf29
zeraf29 / IsEmptyOrNull.kt
Created March 23, 2022 12:28
Coursera-kotlin extension function lexture
fun main(args: Array<String>) {
val s1: String? = null
val s2: String? = ""
s1.isEmptyOrNull() eq true
s2.isEmptyOrNull() eq true
val s3 = " "
s3.isEmptyOrNull() eq false
}
@zeraf29
zeraf29 / TimeGap.js
Last active January 31, 2022 15:14
NOMAD_CODER_CleanCode_Practice1
class TimeGap{
constructor(day, hour, min, secs){
this.day = day;
this.hour = hour;
this.min = min;
this.secs = secs;
};
getTimeGapValues = () => `${this.stringWithPad(this.day)}d, ${this.stringWithPad(this.hour)}h, ${this.stringWithPad(this.min)}m, ${this.stringWithPad(this.secs)}s`;
@zeraf29
zeraf29 / twoSum.java
Created January 8, 2020 07:47
Find value's indexes which each number's sum is same "sum" parameter value
static void twoSumValue(int[] nums, int sum) {
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
for(int i=0; i<nums.length; i++){
int target = sum - num[i];
if(map.containsKey(target)){
System.out.println((map.get(target)+" "+(i)));
break;
}
map.put(cost[i],i);
}
@zeraf29
zeraf29 / getGcdLcm.java
Created December 6, 2019 07:24
find numbers which can be divided by integers of array A and can divide evenly into integers of array B.
private static int getGcd(int num1, int num2) {
int temp = 0;
while(num2>0){
temp = num1 % num2;
num1 = num2;
num2 = temp;
}
return num1;
}
private static int getLcm(int num1, int num2) {
@zeraf29
zeraf29 / findMaxNumberOfElementsInList.java
Created November 1, 2019 08:59
Find max number of elements in list using stream
// find max number of elements in list like below example
// ex) in beloew list, elements '3' has max number of elements(max count how many exist in list)
// List<Integer> arr = Arrays.asList(1, 2, 3, 4, 5, 4, 3, 2, 1, 3, 4);
// elements '3' and '4' have frequency 4 in this list.
// but '3' is smaller than '4', So elements '3' is max number of elements.
// Complete the migratoryBirds function below.
static int migratoryBirds(List<Integer> arr) {
//return arr.stream().filter(i -> Collections.frequency(arr, i) > 1).max(Integer::compare).get();
// get Frequency each elements -> return Map
@zeraf29
zeraf29 / BotClean_whileAndSubString.java
Created August 29, 2019 05:27
BotClean - while문 및 subString 사용
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static void next_move(int posr, int posc, String[] board){
//add logic here
@zeraf29
zeraf29 / BotClean_forAndIndexOf.java
Created August 29, 2019 05:25
BotClean - for문 및 indexOf(Str, fromIndeX) 활용
public class Solution {
static void next_move(int posr, int posc, String[] board){
//add logic here
int targetX = 0, targetY = 0, tempX = 0, gap = 10, fromIndex = 0;
for(int i=0; i<board.length; i++) {
if(board[i].indexOf('d',fromIndex)>-1) {
tempX = board[i].indexOf('d',fromIndex);
if(Math.abs(posc-tempX)+Math.abs(posr-i)<gap ) {
gap = Math.abs(posc-tempX)+Math.abs(posr-i);
@zeraf29
zeraf29 / plusMinus.java
Created May 8, 2019 05:40
파라미터로 넘어온 배열 안의 값의 양수,음수, 0의 %비율(소수점 6자리까지)
// Complete the plusMinus function below.
static void plusMinus(int[] arr) {
int result = 0;
for(int i=0; i<arr.length; i++){
result += ( (arr[i]>0) ? (arr.length+1) : ( (arr[i]<0) ? (1) : 0 ) );
}
//plus number
System.out.println(String.format( "%.6f",(result/(arr.length+1))/(double)(arr.length)));
//minus number
System.out.println( String.format( "%.6f",(result%(arr.length+1))/(double)(arr.length)));
@zeraf29
zeraf29 / CompareTriplets.java
Created April 19, 2019 04:49
// Comparing value at same index between List "a" and List "b"
import java.util.Arrays;
import java.util.List;
public class Solution {
// Comparing value at same index between List "a" and List "b"
static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
//First. Using if condition
//if List "a"' value is bigger than List "b"
//, adding 1 point at List "resultList" 's index 0 value.