Skip to content

Instantly share code, notes, and snippets.

@sanggiChoi
sanggiChoi / MyLogger.py
Created August 19, 2022 02:22 — forked from huklee/MyLogger.py
python Logger using example with Singleton Pattern
# -*- coding: utf-8 -*-
import logging
import os
import datetime
import time
class SingletonType(type):
_instances = {}
@sanggiChoi
sanggiChoi / ssm_parameter_store.py
Created August 27, 2020 07:59 — forked from nqbao/ssm_parameter_store.py
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@sanggiChoi
sanggiChoi / S3-Static-Sites.md
Created August 26, 2020 02:05 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

@sanggiChoi
sanggiChoi / aws.md
Created July 31, 2020 08:35 — forked from colinvh/aws.md
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

@sanggiChoi
sanggiChoi / stress_test.py
Created January 14, 2019 09:49 — forked from mda590/stress_test.py
Python script useful for stress testing systems
"""
Produces load on all available CPU cores.
Requires system environment var STRESS_MINS to be set.
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
import time
import os
2019/01/04 12:49:26 [INFO] Terraform version: 0.11.11 ac4fff416318bf0915a0ab80e062a99ef3724334
2019/01/04 12:49:26 [INFO] Go runtime version: go1.11.1
2019/01/04 12:49:26 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2019/01/04 12:49:26 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2019/01/04 12:49:26 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/01/04 12:49:26 [INFO] CLI command args: []string{"apply"}
2019/01/04 12:49:26 [TRACE] module source: "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=master"
2019/01/04 12:49:27 [TRACE] module source: "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master"
2019/01/04 12:49:27 [TRACE] module source: "git::https://github.com/cloudposse/terraform-aws-ec2-autoscale-group.git?ref=master"
2019/01/04 12:49:27 [TRACE] module source: "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3"

HOWTO: Installing Vault On AWS Linux

This is quick howto for installing vault on AWS Linux, mostly to remind myself. At the end of this tutorial, you'll have a working vault server, using s3 for the backend, self signed certificates for tls, and supervisord to ensure that the vault server is always running, and starts on reboot.

Setting up S3

First things first, let's set up an s3 bucket to use as the storage backend for our s3 instance.

  1. From the AWS Mangement Console, go to the S3 console.

  2. Click on the Create Bucket button

#!/usr/bin/python
import sys
import random
import string
def random_string(length):
pool = string.letters + string.digits
return (''.join(random.choice(pool) for i in xrange(length))).lower()
@sanggiChoi
sanggiChoi / install_jq.sh
Created October 29, 2018 05:21 — forked from kamermans/install_jq.sh
Install jq (JSON Command Line processor)
#!/bin/bash -e
# This scripts installs jq: http://stedolan.github.io/jq/
JQ=/usr/bin/jq
curl https://stedolan.github.io/jq/download/linux64/jq > $JQ && chmod +x $JQ
ls -la $JQ
@sanggiChoi
sanggiChoi / pyenv+direnv on OSX.md
Created October 1, 2018 00:31 — forked from alexhayes/ pyenv+direnv on OSX.md
Awesomely easy virtualenvs on OSX using pyenv and direnv

Awesomely easy virtualenvs on OSX using pyenv and direnv

Never forget to activate that virtualenv or set that environment variable ever again...

Install

  1. Install pyenv

     brew install pyenv