Skip to content

Instantly share code, notes, and snippets.

View jeongho's full-sized avatar

Jeongho Park jeongho

  • Deception Island, Antarctica
View GitHub Profile
@jeongho
jeongho / haproxy_ssl_termination_springboot_backend.cfg
Last active October 27, 2021 10:12
HAProxy SSL Termination CORS
# haproxy -v
# HA-Proxy version 2.3.14-83c5b44 2021/09/07 - https://haproxy.org/
# Status: stable branch - will stop receiving fixes around Q1 2022.
# Known bugs: http://www.haproxy.org/bugs/bugs-2.3.14.html
# Self-signed SSL certificate
# https://gridscale.io/en/community/tutorials/haproxy-ssl/
# openssl req -nodes -x509 -newkey rsa:2048 -keyout /etc/ssl/private/test.key -out /etc/ssl/private/test.crt -days 3650
# writing new private key to '/etc/ssl/private/test.key'
# -----
@jeongho
jeongho / postgres-scalable-sequence.sql
Created January 22, 2021 02:00
postgres-scalable-sequence.sql
--# postgresql 12 high availability cookbook ch14: creating a scalable nextval replacement
--## this example has 2048 shards (schemas) and 2048 unique values per millisecond (seq % 2048)
--# ref: [Sharding & IDs at Instagram](https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c)
CREATE SCHEMA shard;
CREATE SEQUENCE shard.table_id_seq;
CREATE OR REPLACE FUNCTION shard.next_unique_id(
shard_id INT
)
@jeongho
jeongho / fix_catalina_java.sh
Created August 8, 2020 10:21
Cannot generate native image using GRAALVM in OS X Catalina
#https://stackoverflow.com/questions/59717111/cannot-generate-native-image-using-graalvm-in-os-x-catalina
sudo xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.1.0
@jeongho
jeongho / ref_color_map.ipynb
Created April 21, 2020 05:38
Named colors in matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeongho
jeongho / convert_to_utf8.sh
Last active November 13, 2019 01:50
convert euc-kr to utf-8
#!/usr/bin/env bash
#sudo apt install uchardet
#sed -i 's/\r$//' convert_to_utf8.sh
#bash ./convert_to_utf8.sh ./t3series-common
[ $# -eq 0 ] && { echo "Usage: bash $0 target_directory (eg. ./t3series-common)"; exit 1; }
[ ! -d $1 ] && { echo "Directory $1 not exists"; exit 1; }
pushd "$1"
@jeongho
jeongho / dig_axfr.sh
Created January 11, 2019 18:50
digging dns with a zone transfer
dig axfr aa05.penguin.antarcticatec.com | grep -v ob | sort | sed -n -E "s/(.*)[0-9]{3,}.aa05.*$/\1/gp" | grep -E "(^ul|^dt)" |sort -u |grep -v CNAME
@jeongho
jeongho / jq_flatten_solr_metrics.sh
Last active December 11, 2018 06:07
jq flattening solr metrics json
curl -sS --retry 5 --retry-delay 5 -m 60 "http://localhost:8983/solr/admin/metrics" | jq -r '.metrics | tostream
| select(length==2)
| (.[0] | map(tostring) | join(".")) as $k
| .[1] as $v
| "\"\($k)\" = \"\($v)\";"' \
| sed "s/\"//g;s/ms$//g;s/\;$//g;s/ = / /g;s/\//_/g;s/\._/\./g;s/'//g;s/-/./g;s/:/./g;s/\.shard[0-9]*\.replica[^\.]*//g" \
| tr [:upper:] [:lower:] | egrep -v "(rate|ms) " | egrep -v "(\.duration\.|http\.__|handlerstart)" \
| awk '/ -?[0-9]*\.?[0-9]*$/ { if ($1 in keys) { keys[$1] += $2 } else { keys[$1] = $2 } } END { for (key in keys) { printf("%s %s ms\n", key, keys[key]) } }' \
| egrep "^solr.jetty|^solr.jvm|^solr.node|^solr.core.*\.deleteddocs|^solr.core.*\.maxdoc|^solr.core.*\.numdocs" \
| head -n 20
@jeongho
jeongho / tmux-cheatsheet.markdown
Created October 25, 2018 18:03 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jeongho
jeongho / gcp_adding_or_resize_persistent_disks.sh
Created March 20, 2018 19:11
GCP Adding or Resizing Persistent Disks
#https://cloud.google.com/compute/docs/disks/add-persistent-disk
#Formatting and mounting a persistent disk
sudo lsblk
sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/[DEVICE_ID]
sudo mkdir -p /mnt/disks/[MNT_DIR]
sudo mount -o discard,defaults /dev/[DEVICE_ID] /mnt/disks/[MNT_DIR]
sudo chmod a+w /mnt/disks/[MNT_DIR]
sudo cp /etc/fstab /etc/fstab.backup
sudo blkid /dev/[DEVICE_ID]
echo UUID=`sudo blkid -s UUID -o value /dev/sdb` /mnt/disks/disk-1 ext4 discard,defaults,nofail 0 2 | sudo tee -a /etc/fstab
@jeongho
jeongho / random hyperparmeter search and roadmap.md
Last active February 27, 2018 22:26
h2o.ai Hyperparameter Optimization in H2O : A guide to Grid Search and Random Search in H2O.

Hyperparameter Optimization in H2O: Grid Search, Random Search and the Future

"Good, better, best. Never let it rest. 'Til your good is better and your better is best." - St. Jerome

Overview

H2O now has random hyperparameter search with time- and metric-based early stopping. Bergstra and Bengio[^1] write on p. 281:

Compared with neural networks configured by a pure grid search, we find that random search over the same domain is able to find models that are as good or better within a small fraction of the computation time.