Skip to content

Instantly share code, notes, and snippets.

View geunho's full-sized avatar
๐ŸŽฏ
Focusing

Geunho Kim 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)