Skip to content

Instantly share code, notes, and snippets.

View michimani's full-sized avatar
🍛
I love curry.

Yoshihiro Ito michimani

🍛
I love curry.
View GitHub Profile
@michimani
michimani / amazon-music-as-nowplay.py
Last active July 9, 2019 06:57
Convert share string that generated by Amazon Music share button to NoyPlaying string with hashtag #nowplaying .
from bs4 import BeautifulSoup
from urllib import request
import re
import sys
import traceback
if __name__ == "__main__":
args = sys.argv
if len(args) < 2:
print('At least one argument is required.')
@michimani
michimani / delete_messages.py
Last active April 18, 2022 07:56
Delete old slack messages at a specific channel.
"""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"
@michimani
michimani / draggable_block_sample.html
Created June 11, 2019 05:49
Example of placing a draggable block.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Draggable Block Test</title>
<style>
.outer-block {
position: relative;
@michimani
michimani / save_image_to_s3.py
Created June 13, 2019 08:21
Save image file from image url to S3 backet.
import boto3
from urllib import request
from urllib.request import Request, urlopen
def save_image(img_url):
"""
Save images from image url to S3 backet.
@param string img_url
"""
try:
@michimani
michimani / show-old-entry-message.js
Last active July 8, 2019 02:40
Show message in an entry generated by Hugo that notifier that entry is old.
function showInfoNotifiesOldPost() {
const nowDate = new Date();
const oldTs = 60 * 60 * 24 * 365 * 1000; // 1 year (millisecond)
const nowTs = nowDate.getTime();
const postDateElem = document.querySelector('p.post-date > time.dt-published');
if (postDateElem !== null) {
try {
const postDateStr = postDateElem.getAttribute('datetime');
const postDate = new Date(postDateStr);
const postTs = postDate.getTime();
@michimani
michimani / copy_link_of_current_page_as_md
Last active December 21, 2020 17:11
Copy current web page title and url link to clipboard as markdown link format.
@michimani
michimani / amazon_now_playing
Last active September 9, 2019 06:29
This is a bookmarklet that generates "#NowPlaying" text when playing music with Amazon Music in a web browser.
javascript:(function(){tit=document.querySelector('.trackInfoContainer .trackTitle a span').innerText;artO=document.querySelector('.trackInfoContainer .trackArtist span');if(typeof artO == 'undefined') {artO=document.querySelector('.trackInfoContainer .trackArtist span.artist');}art=artO.innerText;window.prompt('NowPlaying!', `${tit}/${art} #NowPlaying`);})();
@michimani
michimani / open_hatebu
Last active October 28, 2019 03:13
This is a bookmarklet opens Hatena Bookmark page of current page.
javascript:(function(){ if (location.href.match(/^https/)) { htb = 'https://b.hatena.ne.jp/entry/s/' + location.href.replace(/https?:\/\//g, ''); } else { htb = 'https://b.hatena.ne.jp/entry/' + location.href.replace(/https?:\/\//g, ''); } window.open(htb, '_blank');})();
@michimani
michimani / sns_to_slack_smiply.py
Created October 28, 2019 02:23
Base of Lambda function that notifies SNS message to Slack.
import json
from urllib.request import Request, urlopen
SLACK_WEBHOOK_URL = '<YOUR-SLACK-WEBHOOK-URL>'
def lambda_handler(event, context):
try:
if 'debug' in event:
event_message = event['debug']
else:
@michimani
michimani / CodeBuiildNotificationToSlack.py
Last active December 15, 2022 13:32
This is a sample of AWS Lambda function that notifies CodeBuild Notification (only state changes) to Slack via Amazon SNS.
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'