Skip to content

Instantly share code, notes, and snippets.

View hassaku63's full-sized avatar

Takuya Hashimoto hassaku63

View GitHub Profile
@hassaku63
hassaku63 / dotenv-to-json.sh
Created September 25, 2024 10:37
Expand dotenv to JSON array of name/value object (like ECS task-def)
# blog(jp): https://zenn.dev/hassaku63/articles/b026266e5a82b4
alias jq-dotenv="jq -R 'split(\"\n\") | map(split(\"=\")) | flatten | {\"name\": .[0], \"value\": .[1]}'"
function dotenv-to-json () {
filename=$1
grep -v '^\s*#' ${filename} |grep -v '^\s*$' | \
jq -R 'split("\n") | map(split("=")) | flatten | {"name": .[0], "value": .[1]}'
}
@hassaku63
hassaku63 / app.ts
Last active September 17, 2024 08:13
CDK app example impl. (set RemovalPolicy = "DELETE" if performing deployment to 'dev' stage)
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { IConstruct } from 'constructs';
import { MyStack } from '../lib/my-stack';
const app = new cdk.App();
const availableStages = ['dev', 'stg', 'prod'] as const;
type Stage = typeof availableStages[number];
@hassaku63
hassaku63 / commands.template
Last active September 13, 2024 16:46
simple python string.Template example
aws ecr get-login-password --region ${aws_region} | docker login --username AWS --password-stdin ${aws_account_id}.dkr.ecr.$aws_region.amazonaws.com
docker build -t ${image_name} .
docker tag ${image_name}:$image_tag ${aws_account_id}.dkr.ecr.$aws_region.amazonaws.com/${image_name}:$image_tag
docker push ${aws_account_id}.dkr.ecr.${aws_region}.amazonaws.com/${image_name}:$image_tag
@hassaku63
hassaku63 / 0512-iam-oidc-provider-l2-use-native-cfn-resource.md
Created July 22, 2024 20:32
AWS CDK aws-cdk-rfcs issue#512 に関する書きかけ RFC の供養

IAM OIDC Provider L2 Construct: use CfnOIDCProvider

  • Original Author(s):: @hassaku63
  • Tracking Issue: #512
  • API Bar Raiser: -

Allow the OpenIdConnectProvider construct to internally use the native CloudFormation Resource AWS::IAM::OIDCProvider.

Working Backwards

@hassaku63
hassaku63 / codepipeline-start-pipeline-execution-sampe.ts
Created June 19, 2023 12:35
AWS SDK for Node.js (v3) で CodePipeline StartPipelineExecution API を実行するサンプル
import {
CodePipelineClient,
StartPipelineExecutionCommand,
StartPipelineExecutionCommandOutput,
ConflictException,
} from "@aws-sdk/client-codepipeline";
type StartPipelineExecutionResultFailed = {
success: false,
error: Error,
@hassaku63
hassaku63 / SECCON Beginners CTF 2023.md
Last active June 4, 2023 05:29
SECCON Beginners CTF 2023

URL: https://score.beginners.seccon.jp/

今回 CTF 初挑戦だったので、やってたこと、考えてたことなどを雑にメモっていく場所。

マジで何もわかっていないで書いてるので、(これを見てしまった人向けに)正解にたどり着きたい人、参考情報を得たい人が見るような「資料」じゃないことを予め断っておく。

自分が何考えてたのかをある程度 dump したものであって、バックグラウンドを理解して書いてるものではない。

競技日程

@hassaku63
hassaku63 / main.go
Created December 25, 2022 10:42
AWS SDK for Go 使ってみる
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/aws/aws-sdk-go/service/sts"
)
func main() {
@hassaku63
hassaku63 / tokenizer.py
Created November 6, 2022 16:20
Python で S式(整数の四則演算だけ)を字句解析する
from enum import Enum
from functools import wraps
def assert_simgle_char(f):
@wraps(f)
def inner(c: str):
if len(c) != 1:
raise ValueError(c)
return f(c)
@hassaku63
hassaku63 / main.go
Last active November 6, 2022 13:57
Type switch
package main
import (
"fmt"
"time"
)
func main() {
typeSwitch := func(v interface{}) {
switch v.(type) {
@hassaku63
hassaku63 / main.go
Last active July 27, 2022 18:30
[Golang] map, struct を要素に持つリストをソートする例
package main
import (
"encoding/json"
"fmt"
"log"
"sort"
)
type Person struct {