Skip to content

Instantly share code, notes, and snippets.

Shuichi Ohsawa ohsawa0515

Block or report user

Report or block ohsawa0515

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ohsawa0515
ohsawa0515 / list_all_host_google_repositories.sh
Created Jul 5, 2019
List container images that exist on all hosts.
View list_all_host_google_repositories.sh
#!/bin/bash
project=$1
hosts=("gcr.io" "us.gcr.io" "eu.gcr.io" "asia.gcr.io")
for host in ${hosts[@]}; do
gcloud container images list --repository=$host/$project --format json | jq -r ".[].name"
done
@ohsawa0515
ohsawa0515 / logging_athena_history.py
Last active Sep 23, 2018
Lambda function to upload Amazon Athena's history to S3.
View logging_athena_history.py
# coding:utf-8
from __future__ import print_function
import os, boto3, datetime, csv
s3 = boto3.resource('s3')
athena_client = boto3.client('athena')
today = datetime.datetime.today().strftime("%Y%m%d")
s3_bucket = os.environ.get('S3_BUCKET')
max_items = 50
@ohsawa0515
ohsawa0515 / Gemfile
Last active May 24, 2018 — forked from mirakui/Gemfile
AWS S3 read/write Benchmark
View Gemfile
source :gemcutter
gem 'aws-sdk', '~> 2'
View lambda_vuls_scan_1_server.log
START RequestId: 5ee997c9-e338-11e7-bc6e-832244fddbfd Version: $LATEST
time="Dec 17 14:41:32" level=info msg="Validating config..."
time="Dec 17 14:41:32" level=info msg="Detecting Server/Container OS... "
time="Dec 17 14:41:32" level=info msg="Detecting OS of servers... "
time="Dec 17 14:41:32" level=info msg="(1/1) Detected: web001: amazon 2015.09"
time="Dec 17 14:41:32" level=info msg="Detecting OS of containers... "
time="Dec 17 14:41:32" level=info msg="Checking dependencies..."
time="Dec 17 14:41:32" level=info msg="Dependencies ... Pass"
time="Dec 17 14:41:32" level=info msg="Checking sudo settings..."
@ohsawa0515
ohsawa0515 / rds_enhanced_monitoring2mackerel_host_metrics.py
Last active Apr 30, 2018
Send metrics of RDS enhanced monitoring(Cloudwatch Logs) to Mackerel host metrics using AWS Lambda.
View rds_enhanced_monitoring2mackerel_host_metrics.py
from __future__ import print_function
from base64 import b64decode
from urllib2 import Request, urlopen
import time
import json
import zlib
from datetime import datetime, timedelta
import boto3
import os
View rds_enhanced_monitoring_mackerel_graphdef.sh
#!/bin/bash
set -eu
api_key="__MACKEREL_API_KEY__"
url="https://mackerel.io/api/v0/graph-defs/create"
curl -s -S -X POST \
-H "X-Api-Key:${api_key}" \
-H 'Content-Type: application/json' \
@ohsawa0515
ohsawa0515 / codedeploy_latest_successful_revision.sh
Last active Dec 20, 2016
AWS CodeDeployでデプロイに成功した最新リビジョンを取得するbashスクリプト
View codedeploy_latest_successful_revision.sh
# To use this script, you need install jq command.
#!/bin/bash
set -u
app=$1
s3bucket=$2
s3key=$3
region=${$4:-ap-northeast-1}
View Mackerel-Webhook-Restart-Instanc_Lambda.py
import boto3, botocore, json
ec2_client = boto3.client('ec2', region_name='ap-northeast-1')
lambda_client = boto3.client('lambda', region_name='ap-northeast-1')
def validation_event(event):
if len(event) == 0:
print 'There is no Event source.'
return False
if not event.has_key("command"):
View Mackerel-Incoming-Webhook_Lambda.py
import boto3, os, json, time
from base64 import b64decode
from urllib2 import Request, urlopen
encrypted_mackerel_api_key = "ENCRYPTED_MACKEREL_API_KEY"
org_id = "ORGANIZATION_ID"
lambda_client = boto3.client('lambda', region_name='ap-northeast-1')
kms_client = boto3.client('kms')
api_key = kms_client.decrypt(CiphertextBlob=b64decode(encrypted_mackerel_api_key))['Plaintext']
@ohsawa0515
ohsawa0515 / fizzbuzz.go
Created Nov 21, 2016
Fizz Buzz golang version.
View fizzbuzz.go
package main
import "fmt"
func main() {
max := 100
for i := 1; i <= max; i++ {
if i % 3 == 0 && i % 5 == 0 {
fmt.Println("Fizz Buzz")
} else if i % 3 == 0 {
You can’t perform that action at this time.