View generate_api_key.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# != 2 ] || [ $1 = "" ] || [ $2 = "" ]; then | |
echo "Two parameters are required" | |
echo "" | |
echo "1st : string for API Key name (ex. user1)" | |
echo "2nd : string for Usage Plan ID (ex. abc123)" | |
echo "" | |
echo "example command" | |
echo "\t$ sh ./generate_api_key.sh user1 abc123" |
View delete_messages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Delete old Slack messages at specific channel.""" | |
from datetime import datetime | |
from time import sleep | |
import json | |
import re | |
import sys | |
import urllib.parse | |
import urllib.request | |
DELETE_URL = "https://slack.com/api/chat.delete" |
View CodeBuiildNotificationToSlack.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import traceback | |
from datetime import datetime, timezone, timedelta | |
from urllib.request import Request, urlopen | |
SLACK_WEBHOOK_URL = '<your-slack-incomming-webhook-url>' | |
SLACK_CHANNEL = '<your-slack-channel>' | |
TEST_EVENT_FILE = './sample__CodeBuild.json' |
View count-github-stargazers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
from urllib.request import Request, urlopen | |
import argparse | |
import json | |
import traceback | |
GITHUB_REPOS_API = 'https://api.github.com/users/{user_name}/repos?per_page=100&page={page}' | |
PRINT_LINE = '{repo_name: <40}:{star_cnt: >6}' | |
p = argparse.ArgumentParser() |
View api-usage-plan.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: "API Gateway - usage plan template." | |
Parameters: | |
TargetApiId: | |
Type: String | |
Resources: | |
UsagePlan: | |
Type: "AWS::ApiGateway::UsagePlan" |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function () { | |
const _d = document; | |
const imgElemList = _d.querySelectorAll('ol.pg-photo__webImageList 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('?')); |
View cf2_for_hugo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handler(event) { | |
var host = '<REPLARE_TO_YOUR_HOST>'; // e.g. https://michimani.net | |
var request = event.request; | |
var requestUri = request.uri; | |
// do not anything when requesting to top page | |
if (requestUri == '' || requestUri == '/') { | |
return request; | |
} |
View lambda_edge_hugo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.handler = (event, context, callback) => { | |
const host = '<REPLARE_TO_YOUR_HOST>'; // e.g. https://michimani.net | |
// Extract the request from the CloudFront event that is sent to Lambda@Edge | |
var request = event.Records[0].cf.request; | |
// Extract the URI from the request | |
var requestUri = request.uri; |
View organize_mac_screen_captures.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import re | |
FILE_TYPE = 'png' | |
NEW_FILE_PATTERN = r'.*(\d{4})-(\d{2})-(\d{2})_\d{5,6}([^\/]+)?\.' + FILE_TYPE | |
SC_DIR = '/Users/hoge/Pictures/_ScreenCaptureTmp' | |
SC_OUT_DIR = '/Users/hoge/Pictures/ScreenCaptures' | |
DIR_TYPE = 'MONTH' # "DAY" or "MONTH" |
View main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
_ "embed" | |
"encoding/json" | |
"fmt" | |
"time" | |
"github.com/aws/aws-sdk-go-v2/aws" |
NewerOlder