Skip to content

Instantly share code, notes, and snippets.

Avatar
🍛
I like curry.

Yoshihiro Ito michimani

🍛
I like curry.
View GitHub Profile
@michimani
michimani / main.go
Created Feb 19, 2021
This is a script using the AWS SDK for Go V2 and Go 1.16. Measure the time it takes to launch AWS Fargate for ECS.
View main.go
package main
import (
"context"
_ "embed"
"encoding/json"
"fmt"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
@michimani
michimani / issue-acm-certificate.sh
Last active Dec 23, 2020
This is a shell script for issuing SSL certificates with ACM (Amazon Certificate Manager).
View issue-acm-certificate.sh
#!/bin/bash
set -e
if [ $# != 3 ] || [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then
echo -e "Three parameters are required
1st - string: Hosted Domain Name on Route 53 (e.g. example.com)
2nd - string: Domain Name for Certificate (e.g. sub.mexample.com)
3rd - string: Target Region (e.g. us-east-1)
example command
@michimani
michimani / translate_by_deepl.js
Last active Nov 23, 2020
A bookmarklet for translating web pages using DeepL.
View translate_by_deepl.js
javascript: (function () {
var API_KEY = '<your_deel_api_key>';
var DEEPL_TRANSLATE_EP = 'https://api.deepl.com/v2/translate';
var TARGET_LANBG = 'JA';
var bodyHtml = document.getElementsByTagName('body')[0].innerHTML;
var params = {
'auth_key': API_KEY,
'text': bodyHtml,
'target_lang': TARGET_LANBG,
'tag_handling': 'xml'
@michimani
michimani / show_only_images_in_modelpress
Created Nov 16, 2020
This is a bookmarklet shows only images in a modelpress page, for example https://mdpr.jp/photo/detail/8869191.
View show_only_images_in_modelpress
javascript: (function () {const _d = document;const imgElemList = _d.querySelectorAll('.list-photo figure.square a img');if (imgElemList.length == 0) {alert('Images not found.');return;}imgElemList.forEach((e,i) => {let imgSrc = e.getAttribute('src');imgSrc = imgSrc.slice(0, imgSrc.indexOf('?'));_d.write(`<img src="${imgSrc}">`);});_d.close();})()
@michimani
michimani / detect_smash_bros_sp_power_v2.py
Last active Nov 23, 2020
Use Amazon Rekognition to detect world strength from captured images of Smash Bros SPECIAL. (part 2) DETAIL: https://michimani.net/post/aws-extract-value-of-smash-blos-sp-power-by-rekognition-2/
View detect_smash_bros_sp_power_v2.py
import boto3
import cv2
import datetime
import hashlib
import json
import os
import re
import sys
import time
@michimani
michimani / detect_smash_bros_sp_power.py
Last active Aug 29, 2020
Use Amazon Rekognition to detect world strength from captured images of Smash Bros SPECIAL. DETAIL: https://michimani.net/post/aws-extract-value-of-smash-blos-sp-power-by-rekognition/
View detect_smash_bros_sp_power.py
import boto3
import sys
reko = boto3.client('rekognition')
target_area = {
'A': {'X': 0.785039062, 'Y': 0.639347222},
'B': {'X': 0.950203125, 'Y': 0.639347222},
'C': {'X': 0.950203125, 'Y': 0.737263889},
'D': {'X': 0.785039062, 'Y': 0.737263889},
@michimani
michimani / set_slack_status.js
Created Jun 12, 2020
Sample Google Apps Script that set Slack status emoji and message.
View set_slack_status.js
const slackUserId = 'XXXXXXXX'; // your user ID
const slackApiToken = 'xoxp-******-*******-******'; // your API token
const slackSetStatusUrl = 'https://slack.com/api/users.profile.set';
function changeSlackStatus(emoji, message) {
const headers = {
'Authorization': 'Bearer ' + slackApiToken,
'X-Slack-User': slackUserId,
'COntent-Type': 'application/json; charset=utf-8'
};
@michimani
michimani / display_cstimer_results
Created Jun 8, 2020
This is a bookmarklet displays the solve results measured by csTimer.
View display_cstimer_results
javascript:(function(){const statsSelector="#stats div.statc table.sumtable.table tr";var stats=document.querySelectorAll(statsSelector),statsTitle="",statsValue="";stats.forEach(t=>{let e=t.querySelector("th").innerText;if(""!=e){"time"==e&&(e="1"),""!=statsTitle&&(statsTitle+="/"),statsTitle+=e;let s=t.querySelectorAll("td")[1].innerText;""!=statsValue&&(statsValue+="/"),statsValue+=s}});alert(`${statsTitle} = ${statsValue}`);})();
@michimani
michimani / lambda_at_1st_day__main.go
Created Jun 3, 2020
Sample of AWS Lambda function that runs at the 1st day of month in Japanese time.
View lambda_at_1st_day__main.go
package main
import (
"context"
"time"
)
// IsFirstDay is function to check today is the 1st day of month in JST
func IsFirstDay() bool {
var isFirstDay bool = false
@michimani
michimani / main.go
Created May 18, 2020
Sample script to scan DynamoDB table via AWS SDK for Go.
View main.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"