Skip to content

Instantly share code, notes, and snippets.

@pegasuskim
pegasuskim / mrz.d
Created August 6, 2024 05:04 — forked from btbytes/mrz.d
MRZ (Machine Readable Zone) checksum calculator
import std.algorithm;
import std.range;
ubyte charCode(dchar c) pure {
switch (c) {
case '<': return 0;
case 'A': .. case 'Z': return cast(ubyte)(c - 'A' + 10);
case '0': .. case '9': return cast(ubyte)(c - '0');
default: assert(0);
}
@pegasuskim
pegasuskim / postgres-cluster.yaml
Created October 20, 2021 11:33 — forked from kofemann/postgres-cluster.yaml
Running postgres in kubernetes
#
# postgres cluster in kubernetes with max 8 replicas
#
# the master is always on ${host}-0
#
#
# postgres master/slave configuration
#
@pegasuskim
pegasuskim / ecs-cluster-userdata.sh
Created September 16, 2020 04:12 — forked from wolfeidau/ecs-cluster-userdata.sh
cloudwatchlogs setup userdata script
#!/bin/bash -e
yum update -y
yum install -y aws-cfn-bootstrap git aws-cli
# Install the files and packages from the metadata
/opt/aws/bin/cfn-init -v --stack "{{ aws_stack_name }}" \
--resource ECSInstanceLaunchConfiguration \
--configsets ConfigCluster \
--region "{{ ref('AWS::Region') }}"
@pegasuskim
pegasuskim / CloudWatch-EC2-logs.md
Created September 16, 2020 04:09 — forked from danteay/CloudWatch-EC2-logs.md
Add logs from EC2 instance to CloudWatch logs

CloudWatch-EC2

Agent Config

1.- Create new Log Group in CloudWatch

2.- Download agent in EC2 instance

sudo wget http://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py
@pegasuskim
pegasuskim / linux-explorer.sh
Created August 13, 2020 07:19 — forked from chrisfu/linux-explorer.sh
Linux Explorer system information script
#!/bin/bash
##############################################################################
#
#
# FILE : linux-explorer.sh
# Last Change Date : 04-07-2016
# Author(s) : Joe Santoro
# Date Started : 15th April, 2004
# Email : linuxexplo [ at ] unix-consultants.com
# Web : http://www.unix-consultants.com/examples/scripts/linux/linux-explorer
@pegasuskim
pegasuskim / gcp_vision_api_test_code.py
Created January 8, 2020 23:40 — forked from jybaek/gcp_vision_api_test_code.py
google cloud platform (vision api)
import io
import os
# export GOOGLE_APPLICATION_CREDENTIALS=/home/oops/github/gcloud/GCP-ML-8492a87b7f32.json
# Imports the Google Cloud client library
from google.cloud import vision
# Instantiates a client
vision_client = vision.Client()
@pegasuskim
pegasuskim / docker_cheat.md
Created September 17, 2019 14:41 — forked from nacyot/docker_cheat.md
도커(Docker) 치트 시트
@pegasuskim
pegasuskim / PythonTest
Last active August 26, 2019 14:45
CodingTest01
d1 = {'만':10000, '억':100000000, '조':1000000000000, '경':10000000000000000}
d2 = {'십':10, '백':100, '천':1000}
d3 = {'일':1, '이':2, '삼':3, '사':4, '오':5, '육':6, '칠':7, '팔':8, '구':9}
# 'xxxx경', 'xxxx조', 'xxxx억', 'xxxx만', 'xxxx' 순서대로 리턴
def cut1(krw):
for u in '경조억만':
if u in krw:
if krw[0] == u:
raise Exception
@pegasuskim
pegasuskim / installHAProxy.sh
Created September 8, 2018 04:05 — forked from emgee3/installHAProxy.sh
Install HAProxy in Ubuntu 14.04 or 12.04
#!/usr/bin/env bash
#
# Install HAProxy
# Script works on Ubuntu 12.04 and 14.04 only
set -e
set -u
set -o pipefail
@pegasuskim
pegasuskim / haproxy
Created September 8, 2018 02:56 — forked from serainville/haproxy
#!/bin/sh
### BEGIN INIT INFO
# Provides: haproxy
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: fast and reliable load balancing reverse proxy
# Description: This file should be used to start and stop haproxy.
### END INIT INFO