Skip to content

Instantly share code, notes, and snippets.

View hassaku63's full-sized avatar

Takuya Hashimoto hassaku63

View GitHub Profile
import functools
class Hook(object):
def init(self, event, context):
print(f'hook init: {event} {context}')
def before(self, event, context, record):
print(f'hook before: {event} {context} {record}')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from dotenv import load_dotenv
from pathlib import Path
from botocore.exceptions import ClientError
import boto3
import json
@hassaku63
hassaku63 / template.yml
Created December 29, 2020 18:02
AWS Cloud Map sample template
AWSTemplateFormatVersion: "2010-09-09"
Description: The AWS CloudFormation template for this Serverless application
Resources:
# Application resource
MyQueue:
Type: AWS::SQS::Queue
Properties:
Tags:
- Key: Name
@hassaku63
hassaku63 / make-pypkg-dir
Last active January 25, 2021 11:00
a shell function that is shortcut of making python-package directory
#
# CC0 license
#
function make-pypkg-dir () {
curdir=$(pwd);
created_dir=$(dirname $1)/$(basename $1);
mkdir $1 \
&& touch ${created_dir}/__init__.py \
&& echo "${created_dir}/__init__.py is created."
@hassaku63
hassaku63 / logs.py
Created February 25, 2021 01:59
JSON Logger example
import os
import json
import logging
from unittest.mock import Mock
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'DEBUG').upper()
if not (LOG_LEVEL in ('DEBUG', 'INFO', 'WARN', 'WARNING', 'ERROR', 'CRITICAL', 'FATAL')):
@hassaku63
hassaku63 / serverless.yml
Last active October 4, 2021 07:27
serverless.yml example
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
@hassaku63
hassaku63 / main.go
Created October 24, 2021 08:32
sample http server using template
package main
import (
"log"
"net/http"
"sync"
"text/template"
"path/filepath"
)
@hassaku63
hassaku63 / vimrc
Created November 2, 2021 19:08
minimum
syntax on
set ts=4
set sm
set number
inoremap <silent> jj <ESC>
@hassaku63
hassaku63 / login.vue
Created April 2, 2019 00:27
vuetify-snippet-login-card.vue
<v-container fuild fill-height>
<v-layout justify-center>
<v-flex xs12 sm8 md4>
<!-- login view -->
<v-card>
<v-toolbar dark flat>
<v-toolbar-title>Login Form</v-toolbar-title>
</v-toolbar>
<v-card-text>
<!-- login form -->
@hassaku63
hassaku63 / serverless.yml
Created May 2, 2022 16:00
Example using subscription filter for StateMachine execution fail (delivery to kinesis data stream)
resources:
Resouces:
SmSubscription:
Type: AWS::Logs::SubscriptionFilter
Properties:
LogGroupName: !Ref StateMachineLogGroup
FilterPattern: ExecutionFailed
DestinationArn: !GetAtt [JobFailureEventStream, Arn]
RoleArn: !GetAtt [KinesisSubscriptionRole, Arn]
JobFailureEventStream: