Skip to content

Instantly share code, notes, and snippets.

View geunho's full-sized avatar
🎯
Focusing

geunho geunho

🎯
Focusing
View GitHub Profile
@geunho
geunho / grep_tips.sh
Last active May 7, 2020 08:49
grep tips 💫
# grep string with unicodes
grep -aP "abc\001\002"
# grep only matched word and sort unique value
cat $FILE | grep -o "\w*15864\w*" | sort -u
# grep nfs mountpoints
cat /proc/mounts | grep nfs
# count numbers in line
@geunho
geunho / awk_tips.sh
Created April 14, 2020 09:53
awk tips 💫
# $OTHER_VAR이 숫자 형식의 문자일 경우 -v 옵션으로 awk 내 변수 지정을 해줘야 정상적인 산술 연산이 수행됨 😄
# 두 번째 항목이 $OTHER_VAR 보다 크거나 같은 라인을 찾는다.
awk -v t=$OTHER_VAR '$2 >= t' $FILE_PATH
@geunho
geunho / cloudSettings
Last active April 20, 2020 08:21
VS Code Settings ⚙️
{"lastUpload":"2020-04-20T08:20:59.745Z","extensionVersion":"v3.4.3"}
@geunho
geunho / kubectl_cheat_sheet.sh
Last active March 29, 2023 11:36
kubectl cheat sheet 💫
# 이미지 확인을 위해 임시로 /bin/bash pod 띄우기
kubectl run $POD_NAME --rm -i --tty --restart=Never --image=$IMAGE:$TAG --command -- /bin/bash
# pod 상태 변경시 출력하기 - OOMKill 등 확인시 사용
kubectl get pod -w
# pvc 용량 증설 (변경 저장 후 물고있는 pod 재시작해야함)
kubectl edit pvc $PVC_NAME
# statefulset pod 재시작
@geunho
geunho / find_tips.sh
Created January 26, 2021 01:39
find tips 💫
# 특정 단어가 포함된 파일 찾기
find $FILE_PATH_TO_FIND -type f -print | xargs grep $WORD_TO_FIND
@geunho
geunho / offset_rewind.sh
Last active September 12, 2021 12:52
kafka consumer group offset rewind
./kafka-consumer-groups \
--bootstrap-server $BROKER_LIST \
--group $CONSUMER_GROUP \
--topic $TOPIC \
--reset-offsets \
--to-datetime 2021-04-20T15:00:00.000 \
--execute
def string2hex(str: String): String = str.toSeq.map(_.toInt.toHexString).mkString(" ")
val contents = "문자열 base64 인코딩/디코딩 테스트."
val encoded = java.util.Base64.getEncoder.encode(contents.getBytes)
val decoded = java.util.Base64.getDecoder.decode(encoded)
val result = new String(decoded)
assert(contents == result)
@geunho
geunho / pg_stat_activity.sql
Created May 2, 2022 09:56
실행중인, blocking된 쿼리 목록 조회
select pid,
usename,
pg_blocking_pids(pid) as blocked_by,
query as blocked_query
from pg_stat_activity
import rg.apache.commons.codec.digest.DigestUtils
val origin = "test text"
val hash = DigestUtils.md5Hex(origin)
println(hash)