Skip to content

Instantly share code, notes, and snippets.

View rivernews's full-sized avatar
🌵

River News rivernews

🌵
View GitHub Profile
@rivernews
rivernews / cloudSettings
Last active June 7, 2022 04:52
(Primary Please Only Use This) VSCode Settings
{"lastUpload":"2022-03-26T06:56:39.315Z","extensionVersion":"v3.4.3"}
# terraform doc: https://www.terraform.io/docs/providers/kubernetes/r/deployment.html
resource "kubernetes_deployment" "app" {
metadata {
name = "my-postgres-deployment"
namespace = "my-postgres-namespace"
labels = {
app = "postgres"
}
}
# the following config is based on digitalocean doc
# https://www.digitalocean.com/docs/kubernetes/how-to/add-volumes/
#
# other cloud provider may have different convention, i.e., needing to create a `kubernetes_persistent_volume` before creating a claim
#
#
# tf doc: https://www.terraform.io/docs/providers/kubernetes/r/persistent_volume_claim.html
resource "kubernetes_persistent_volume_claim" "app_digitalocean_pvc" {
metadata {
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/32 trust
# IPv6 local connections:
host all all ::0/128 trust
# CONNECTION
listen_addresses = '*'
# REPLICATION
wal_level = logical # minimal, archive, hot_standby, or logical (change requires restart)
max_wal_senders = 4 # max number of walsender processes (change requires restart)
#wal_keep_segments = 4 # in logfile segments, 16MB each; 0 disables
#wal_sender_timeout = 60s # in milliseconds; 0 disables
max_replication_slots = 4 # max number of replication slots (change requires restart)
FROM postgres:11.5
ENV PGDATA=$DATA_VOLUME_MOUNT/pgdata
COPY ./docker-entrypoint-initdb.d/. /docker-entrypoint-initdb.d/
RUN mkdir $DATA_VOLUME_MOUNT
COPY pg_hba.conf $DATA_VOLUME_MOUNT/pg_hba.conf
COPY postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample
@rivernews
rivernews / ec2_instances.tf
Created February 28, 2019 02:00
Security group that protects EC2 instances behind Application Load Balancer.
...
resource "aws_security_group" "behind_alb_sg" {
name = "${var.project_name}_ec2_behind_alb"
description = "Protect EC2 instances from public traffic and set them behind Application Load Balancer."
vpc_id = "${var.vpc_id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
...
resource "aws_alb_target_group" "http" {
name = "${var.project_name}-alb-tg-http"
port = 80
protocol = "HTTP"
vpc_id = "${var.vpc_id}"
health_check {
@rivernews
rivernews / Dockerfile
Created February 27, 2019 22:32
Node.js
FROM node:8-alpine
EXPOSE 3000
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN npm i
CMD [ "node", "src/server.js" ]
@rivernews
rivernews / tech_ch_ai.html
Last active February 11, 2018 01:17
Integer String Sum
{% extends 'base/html5_base.html' %}
{% load staticfiles %}
{% block content %}
<md-content data-ng-controller="techChController">
<md-card >
<md-card-content>
<a class="md-headline">Integer Sum from String</a><br>
<a> This page demostrates our solution to the task for the Academic Innovation Summer Internship Program.<br>
User will input some arbitrary text. If there is any number within the text, the numbers will be extracted and sum together.<br>