Skip to content

Instantly share code, notes, and snippets.

@overnew
overnew / [pccp]복원하기.py
Last active September 23, 2024 05:08
[PCCP 기출문제] 4번 / 수식 복원하기
explicit_list = []
unknown_list = []
def parse(expressions: []):
for exp in expressions:
arr = exp.split(" ")
if arr[4] == "X":
unknown_list.append(arr)
else:
@overnew
overnew / pccp3robotconflict.py
Created September 22, 2024 02:56
[PCCP 기출문제] 3번 / 충돌위험 찾기
list = []
cnt = 0
g_points = []
g_routes = []
robot_pos_list = []
robot_num = 0
end_robot_check = [False for i in range(101)]
end_robot_cnt = 0
def move_cycle():
@overnew
overnew / pccp2puzzle.py
Last active September 21, 2024 14:48
[PCCP 기출문제] 2번 / 퍼즐 게임 챌린지
def solution(diffs, times, limit):
max_level = max(diffs) #최대 diff 구해두기
l = 1
r = max_level
answer = max_level #정답이 max_diff인 경우를 대비해서 answer에 넣어두기
while l < r:
level = int((l + r) /2)
time = times[0]
@overnew
overnew / lambda_example.py
Last active July 15, 2024 11:11
lambda_warmstart_example.py
import json
import urllib3
import os
# 환경 변수는 다시 가져올 필요가 없음!!! 전역에
slack_webhook_url = os.environ['SLACK_WEBHOOK_URL']
def lambda_handler(event, context):
# 매개변수의 추출은 항상 이뤄져야 함.
message = json.loads(event['Records'][0]['Sns']['Message'])
@overnew
overnew / codebuild.tf
Created July 6, 2024 14:10
codebuild.tf example
locals {
build_name = "${var.project_name}-${var.build_name}"
}
# codebuild
resource "aws_codebuild_project" "this" {
depends_on = [ data.aws_codecommit_repository.source_repository ]
name = local.build_name #"${var.project_name}-build"
build_timeout = 6
service_role = aws_iam_role.build_task_role.arn #module.iam.iam_role_arn
@overnew
overnew / awsPHPsdk_buildspec.yaml
Last active July 6, 2024 13:51
buildspec.yaml example
version: 0.2
env: # 환경변수를 정의
variables:
AWS_DEFAULT_REGION: "ap-northeast-1"
ECR_URL: "awsid.dkr.ecr.ap-northeast-1.amazonaws.com/milliapp"
IMAGE_REPO_NAME: "milliapp"
IMAGE_TAG: "appv02"
AWS_ACCOUNT_ID: "awsid"
ECS_FAMILY: "app-service"
CONTAINER_NAME: "appv02"
@overnew
overnew / task_def_otel.json
Created July 2, 2024 13:11
task_def_otel.json
{
"name": "aws-otel-collector",
"image": "851725230407.dkr.ecr.ap-northeast-1.amazonaws.com/otel:v0.39.0",
"cpu": 0,
"portMappings": [],
"essential": true,
"environment": [
{
"name": "AWS_PROMETHEUS_ENDPOINT",
"value": "https://aps-workspaces.ap-northeast-1.amazonaws.com/workspaces/ws-ddab0164-4917-44b4-9854-0abf2551f6a6/api/v1/remote_write"
@overnew
overnew / ecs_task_autoscaling.tf
Created July 2, 2024 04:35
ecs task autoscaling example
resource "aws_ecs_service" "web_service" {
name = local.web_name
cluster = aws_ecs_cluster.web_cluster.id
task_definition = aws_ecs_task_definition.web_task.arn
desired_count = 2
launch_type = "FARGATE"
scheduling_strategy = "REPLICA"
deployment_controller {
type = "CODE_DEPLOY"
@overnew
overnew / sns_lambda_slack.py
Created June 2, 2024 10:02
sns_lambda_slack.py
import json
import urllib3
import os
def lambda_handler(event, context):
# SNS 메시지 추출
message = event['Records'][0]['Sns']['Message']
# Slack Webhook URL 가져오기
slack_webhook_url = os.environ['SLACK_WEBHOOK_URL']
@overnew
overnew / web_userdata.sh
Created April 21, 2024 13:49
web_userdata
#!/bin/bash
# Nginx 설치
apt update
apt install -y nginx
index_file="/var/www/html/index.html"
cat <<EOF > $index_file