Skip to content

Instantly share code, notes, and snippets.

View quiver's full-sized avatar

George Yoshida quiver

View GitHub Profile
@quiver
quiver / coros_get_activity_list.py
Last active January 8, 2023 15:33
Python Script to get data from COROS Training Hub
'''
Python PoC to interact with COROS Training Hub.
URL : https://training.coros.com/
This script retrieves COROS's activity list for 2022/12.
$ python3 coros_activity_list.py
date,name,sportType,totalTime,distance,calorie,trainingLoad
20221230,Foo Run,100,9538,14651.11,1266085,117
@quiver
quiver / 00.txt
Last active January 9, 2023 10:00
Check Canyon Bikes Availability
Canyonバイクで、注文可能なモデルをすぐに注文したい
https://www.canyon.com/en-de/orderable-bikes/?prefn1=masterAvailabilityFlag&prefn2=pc_geschlecht&prefn3=pc_rahmengroesse&prefn4=pc_welt&prefv1=1&prefv2=Unisex&prefv3=XS&prefv4=Road
@quiver
quiver / set-retention-for-lambda-at-edge-logs.sh
Created May 9, 2020 19:16
Bash Script to set retention periods for Lambda@Edge CloudWatch Logs in all regions.
#!/bin/bash
# L@E logs are displayed or stored in the Region closest to the location where the function executed.
# This Bash script sets retention periods for CloudWatch Log in all regions.
FUNCTION_NAME=LambdaAtEdgeFunctionName
LOG_GROUP=/aws/lambda/us-east-1.${FUNCTION_NAME}
# Possible Values: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653.
RETENTION_IN_DAYS=30
@quiver
quiver / boto3_cloudfront_create_invalidation.py
Created March 14, 2020 12:31
Sample script to create CloudFront invalidation
'''
Invalidate Amazon CloudFront paths
API
- https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudfront.html#CloudFront.Client.create_invalidation
'''
import random
import time
import boto3
@quiver
quiver / cloudformation-template-for-aws-backup-thin-backups.yaml
Created July 20, 2019 17:18
CloudFormation template to configure thin backup rules for AWS Backup
AWSTemplateFormatVersion: "2010-09-09"
Description: "Backup Plan template for thin backups"
Resources:
BackupVaultWithThinBackups:
Type: "AWS::Backup::BackupVault"
Properties:
BackupVaultName: "BackupVaultWithThinBackups"
BackupPlanWithThinBackups:
Type: "AWS::Backup::BackupPlan"
@quiver
quiver / eic-cli.sh
Last active June 15, 2022 21:23
simple shell script to demonstrate how EC2 Instance Connect CLI is implemented
#!/bin/bash
# simple shell script to demonstrate how EC2 Instance Connect CLI is implemented.
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
#
# Usage
# $ bash eic-cli.sh i-1234
if [ $# -ne 1 ]; then
echo "Usage"
echo "$ bash eic-cli.sh i-1234"
@quiver
quiver / iam-policy.json
Last active October 17, 2023 14:21
How to connect to Amazon RDS PostgreSQL with IAM credentials
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:region:account-id:dbuser:dbi-resource-id/database-user-name"
@quiver
quiver / athena.py
Last active August 19, 2022 11:19
query SQL to Amazon Athena and save its results from Amazon S3 Raw
#!/usr/bin/env python
# vim: set fileencoding=utf8 :
```
$ pip install -U boto3 retrying
$ export AWS_DEFAULT_PROFILE=test
$ cat foo.sql
select count(*)
from bar
$ python athena.py foo.sql
$ ls -1
@quiver
quiver / kinesis-stream-state-diagram.dot
Last active May 8, 2016 05:03
AWS Kinesis Stream Status Diagram created with Graphviz
// $ dot -Tpng kinesis-stream-state-diagram.dot -o kinesis-stream-state-diagram.png
digraph kinesis_stream_status {
labelloc="t";
label="AWS Kinesis Streams : Stream State Diagram";
CreateStream[shape=box];
DeleteStream[shape=box];
MergeShards[shape=box];
SplitShards[shape=box];
IncreaseStreamRetentionPeriod[shape=box];
@quiver
quiver / sample-output-of-describe-auto-scaling-groups.json
Created February 28, 2016 16:53
aws : autoscaling waiters based on aws/aws-sdk-ruby
{
"AutoScalingGroups": [
{
"AutoScalingGroupARN": "arn:aws:autoscaling:ap-northeast-1:123456789012:autoScalingGroup:aaaaaaaa-35cb-4f11-bf21-258b69e3c42d:autoScalingGroupName/bar",
"HealthCheckGracePeriod": 300,
"SuspendedProcesses": [],
"DesiredCapacity": 0,
"Tags": [],
"EnabledMetrics": [],
"LoadBalancerNames": [],