Skip to content

Instantly share code, notes, and snippets.

@swnim
swnim / pr_to_local.md
Last active September 9, 2021 09:21
Checkout Github PR to local repository
## Install Github CLI
brew install gh

## Login Github
gh auth login

## Checkout Github PR
gh pr checkout  126  # pr no.
class DotMap(dict):
"""Dot.Notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
@swnim
swnim / getter_and_setter.py
Created February 4, 2020 09:44 — forked from luhn/getter_and_setter.py
Using getters and setters with SQLAlchemy
class Table(Base):
id = Column(Integer, primary_key=True)
_name = Column('name', String(24))
@property
def name(self):
return self._name;
@name.setter
def name(self, value):
@swnim
swnim / S3-Static-Sites.md
Created January 30, 2020 04:28 — 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

# List all tables:
select db_id, id, name, sum(rows) as mysum
from stv_tbl_perm where db_id = 100546
group by db_id, id, name order by mysum desc;
# list all running processes:
select pid, query from stv_recents where status = 'Running';
# describe table
select * from PG_TABLE_DEF where tablename='audit_trail';
@swnim
swnim / build.sh
Created August 8, 2018 01:58
AWS EB Golang Build Script
#!/bin/bash -xe
GOPATH="/tmp/go"
APP_BUILD_DIR="$GOPATH/src/project" # We will build the app here
APP_STAGING_DIR=$(pwd) # Current directory
DEP_VERSION="v0.5.0" # Use specific version for stability
# Install dep, a Go dependency management tool, if not already installed or if
# the version does not match.
if ! hash dep 2> /dev/null || [[ $(dep version | awk 'NR==2{print $3}') != "$DEP_VERSION" ]]; then
curl -L -s https://github.com/golang/dep/releases/download/$DEP_VERSION/dep-linux-amd64 -o /usr/local/bin/dep
@swnim
swnim / .vimrc
Created February 12, 2018 07:45
set nocompatible "오리지날 VI와 호환하지 않음
set cindent "C 프로그래밍용 자동 들여쓰기
set smartindent "스마트한 들여쓰기
set lbr
set wrap
set number "행번호 표시, set nu 도 가능
set nowrapscan "검색할 때 문서의 끝에서 처음으로 안돌아감
set nobackup "백업 파일을 안만듬
set visualbell "키를 잘못눌렀을 때 화면 프레시
set ruler "화면 우측 하단에 현재 커서의 위치(줄,칸) 표시
@swnim
swnim / 0_reuse_code.js
Created July 19, 2017 01:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@swnim
swnim / install_pyenv.sh
Last active July 25, 2017 05:31 — forked from ysaotome/install_pyenv.sh
pyenv install for CentOS 6.5 x86_64
#!/bin/zsh
# pyenv install for CentOS 6.5 x86_64
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"