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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / textbox-overlay-by-whitespace.html
Created February 6, 2019 01:45
Add overlay to a word separated by whitespace inputted at a textbox.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Textbox Overlay Style by White Space</title>
<style type="text/css">
#overlay-sample {
margin: 30px;
font-family: inherit;
}