Skip to content

Instantly share code, notes, and snippets.

View ebongzzang's full-sized avatar

Sangbong Lee ebongzzang

View GitHub Profile
@ebongzzang
ebongzzang / copy-vault-recursive.sh
Created February 14, 2024 07:23
Copy all vault secrets under secret backend A into B recursively
#!/usr/bin/env bash
set -e
SOURCE_KV=$1
TARGET_KV=$2
results=()
list_secrets() {
local path=$1
# List secrets at the current path
secrets=$(vault kv list -format=json "${SOURCE_KV}/${path}" 2>/dev/null)
@ebongzzang
ebongzzang / tableEnv.kt
Created November 16, 2023 09:05
Flink tableenv
private val tableEnv: StreamTableEnvironment by lazy {
val tableEnvConfigMap = mapOf(
"lookup.cache" to "PARTIAL",
"lookup.partial-cache.max-rows" to "50000",
"lokup.partial-cache.expire-after-access" to "60min"
)
val tableEnvSetting = EnvironmentSettings.Builder()
.withConfiguration(Configuration.fromMap(tableEnvConfigMap))
.build()
@ebongzzang
ebongzzang / date.sh
Last active February 5, 2020 10:48
print all dates string between startdate and enddate in mac os
#!/bin/bash
startdate=$1
enddate=$2
function print_formatted() {
res=`date -j -f %Y-%m-%d $1 +%Y-%m-%d`
echo $res
}
@ebongzzang
ebongzzang / lua-csv.lua
Created June 25, 2018 09:00
wrc lua script with csv
local csv = require("csv")
local f = csv.open("device-table2.csv", {['header'] = true})
local columns = {"id", "free_storage_in_byte", "used_storage_in_byte"}
local parameters = {}
local counter = 0
for fields in f:lines() do
perRowCondition = {}
for index, value in pairs(fields) do
for _,v in pairs(columns) do
@ebongzzang
ebongzzang / boto3_list.py
Last active November 5, 2019 09:50
get_object_list_from_bucket using boto3
import json
import re
from io import BytesIO, StringIO
from typing import List
import requests
import bs4
import boto3
s3 = boto3.client('s3')
@ebongzzang
ebongzzang / admin.py
Created October 7, 2019 06:26
django-admin
# Register your models here.
import inspect
import sys
from cytoolz import *
from django.contrib import admin
from guardian.admin import GuardedModelAdmin
from .models import *
@ebongzzang
ebongzzang / main.py
Created October 21, 2019 13:38
mp example
from itertools import chain
import numpy as np
from collections import Counter
from multiprocessing import cpu_count, Pool
def a(weights):
w_sum = np.sum(weights)
value = np.random.randint(w_sum, size=1)[0]
@ContextConfiguration
@DataJpaTest
class DbunitWithGenesisTest extends Specification {
private static Logger log = LoggerFactory.getLogger(DbunitWithGenesisTest.class)
def hi = 1L..10L
// testEntityManager는 persistence context 테스트 목적으로 사용된다.
// 즉, 실제 데이터베이스에 적용할수는 없다
@Autowired
@ebongzzang
ebongzzang / plasma.py
Created December 12, 2018 08:59
pyarrow insert_df_to_plasma
import numpy as np
import pandas as pd
import pyarrow as pa
from pyarrow import plasma
def insert_df_to_plasma(client, df: pd.DataFrame, key=plasma.ObjectID(np.random.bytes(20))) -> plasma.ObjectID:
record_batch = pa.RecordBatch.from_pandas(df)
object_id = key
@ebongzzang
ebongzzang / ecr-cronjob.yaml
Created February 22, 2019 08:54
kubernetes ecr token refresh script (all namespace)
# before apply below script, run command
# kubectl create clusterrolebinding ecr-cluster-rule --clusterrole=cluster-admin --serviceaccount=default:default
apiVersion: batch/v1beta1
kind: CronJob # Tell kuber' that this is a cronjob
metadata:
name: ecr-puller # Name of the job ,can be anything
namespace: default
spec:
concurrencyPolicy: Allow