Skip to content

Instantly share code, notes, and snippets.

Avatar

Takuya Hashimoto hassaku63

View GitHub Profile
@hassaku63
hassaku63 / main.go
Created December 25, 2022 10:42
AWS SDK for Go 使ってみる
View main.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式(整数の四則演算だけ)を字句解析する
View tokenizer.py
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
View main.go
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 を要素に持つリストをソートする例
View main.go
package main
import (
"encoding/json"
"fmt"
"log"
"sort"
)
type Person struct {
@hassaku63
hassaku63 / main.rs
Created July 18, 2022 07:48
ユーザー定義の構造体をいい感じに print できるように fmt トレイトを実装する
View main.rs
use std::fmt;
struct Circle {
radius: u32
}
impl Circle {
fn diameter(&self) -> u32 {
self.radius * 2
}
@hassaku63
hassaku63 / handler.py
Created May 2, 2022 16:08
example lambda (python) handler processing subscribed CloudWatch Logs log event (via kinesis data stream)
View handler.py
import json
import gzip
import logging
from base64 import b64decode
log = logging.getLogger(__name__)
def handler(event, context):
@hassaku63
hassaku63 / serverless.yml
Created May 2, 2022 16:00
Example using subscription filter for StateMachine execution fail (delivery to kinesis data stream)
View serverless.yml
resources:
Resouces:
SmSubscription:
Type: AWS::Logs::SubscriptionFilter
Properties:
LogGroupName: !Ref StateMachineLogGroup
FilterPattern: ExecutionFailed
DestinationArn: !GetAtt [JobFailureEventStream, Arn]
RoleArn: !GetAtt [KinesisSubscriptionRole, Arn]
JobFailureEventStream:
@hassaku63
hassaku63 / send-get-request-to-opensearch-using-curl-with-sigv4.sh
Last active September 2, 2022 03:10
Send GET request to OpenSearch Domain using curl with sig4 signature
View send-get-request-to-opensearch-using-curl-with-sigv4.sh
aws_region='ap-northeast-1'
endpoint="https://DOMAIN_NAME.${aws_region}.es.amazonaws.com/"
AWS_ACCESS_KEY_ID='foo'
AWS_SECRET_ACCESS_KEY='bar'
curl $endpoint --verbose --aws-sigv4 "aws:amz:${aws_region}:es" --user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}"
@hassaku63
hassaku63 / vimrc
Created November 2, 2021 19:08
minimum
View vimrc
syntax on
set ts=4
set sm
set number
inoremap <silent> jj <ESC>
@hassaku63
hassaku63 / main.go
Created October 24, 2021 08:32
sample http server using template
View main.go
package main
import (
"log"
"net/http"
"sync"
"text/template"
"path/filepath"
)