Skip to content

Instantly share code, notes, and snippets.

View takenoko-str's full-sized avatar
🎯
Focusing

takenoko-str takenoko-str

🎯
Focusing
  • 35.07103745548258, 135.29974566562086
View GitHub Profile
@kawasima
kawasima / sevens.ts
Created March 26, 2024 12:56
7並べのモデル Domain Modeling Made Functional風味
import z from "zod";
const Suit = z.enum(["Spade", "Heart", "Diamond", "Club"]);
const Rank = z.enum(["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]);
const Card = z.object({
suit: Suit,
rank: Rank,
});
type Card = z.infer<typeof Card>;
// 手札
@j5ik2o
j5ik2o / event_persistence_gatway.rs
Last active June 24, 2023 14:00
RustでのステートレスなEvent Sourcingの実装
// ここでいうステートレスというのはアプリケーションに状態があるのではなく、DBに状態があることを意味しています。
// 逆にAkka Clusterで実装されるEvent Sourcingシステムでは、アプリケーションの状態はアプリケーションが保持しており、
// DBはバックアップログを持つストレージの役割になります。
pub struct EventPersistenceGateway<'a> {
journal_table_name: String,
snapshot_table_name: String,
client: &'a Client,
}
@codesenju
codesenju / ecs-exec.md
Created April 4, 2023 12:04
ECS EXEC A GUIDE

Ecs Exec A Guide

Prerequisite

[+] Install SessonManager on local machine, alternatively you can use AWS CloudShell. [+] IAM permissions required for ECS Exec, see[2].

export cluster_name=**
export private_subnet_one=**
export private_subnet_two=**
export container_security_group=**
@matheushent
matheushent / stack.py
Created October 20, 2021 00:30
CDK stack example for build WAF rules against CloudFront distribution
#CDK python WAF with CloudFront and regex and ip set rules (v1.102.0 of CDK and above)
from aws_cdk import (
core as cdk,
aws_cloudfront as cloudfront,
aws_cloudfront_origins as cloudfront_origins,
aws_s3 as s3,
aws_certificatemanager as acm,
aws_route53 as route53,
aws_wafv2 as wafv2,
@rnag
rnag / my_stack.py
Last active May 18, 2023 02:35
AWS CDK - AWS Lambda Asset
# from pathlib import Path # Optional
# Using CDK v2
from aws_cdk import Duration
from aws_cdk.aws_lambda import Function, Runtime
from aws_cdk_lambda_asset.zip_asset_code import ZipAssetCode
# NOTE: Only example usage below (needs some modification)
from __future__ import annotations
import typing as t
import dataclasses
import json
@dataclasses.dataclass
class Person:
name: str
age: int
@inoh
inoh / cdk.py
Last active February 27, 2022 17:46
bucket = s3.Bucket(self,
'S3',
bucket_name='diary.ino-h.com',
website_index_document='index.html',
removal_policy=core.RemovalPolicy.DESTROY,
)
s3_deployment.BucketDeployment(self,
'Deployment',
sources=[s3_deployment.Source.asset('build')],
async startCommitWorkflow({ base64, author, skipTest }: { base64: string; author: string; skipTest: boolean }) {
await axios.post(
'https://api.github.com/repos/{{owner}}/{{repository}}/actions/workflows/string-modification.yml/dispatches',
{
ref: 'master',
inputs: {
values: base64,
author: author || 'Bot',
skipTest: skipTest ? 'true' : 'false',
},
@scottnixonjr
scottnixonjr / full_attribute_based_policy.json
Created April 16, 2020 17:38
Flexible Attribute based Access Control for creating EC2 Instances for Solution 3 in Developer Sandboxes - https://github.com/stelligent/developer-sandboxes
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "arn:aws:ec2:*:*:instance/*",
"Condition": {
"StringEqualsIgnoreCase": {
@frodo821
frodo821 / email_validator.py
Last active October 18, 2021 21:46
A ReDoS proof email address validation
from re import match
def validateEmail(email):
valid = 'abcdefghijklmnopqrstuvwxyz1234567890!#$%&\'*+-/=?^_`{}|~'
if not email:
return False
email = email.lower()
if email.startswith('"'):
i = 1
while i < min(64, len(email)):