Skip to content

Instantly share code, notes, and snippets.

:octocat:
so sleepy...

Yoshihiro Ito michimani

:octocat:
so sleepy...
Block or report user

Report or block michimani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@michimani
michimani / save_image_to_s3.py
Created Jun 13, 2019
Save image file from image url to S3 backet.
View save_image_to_s3.py
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 Jun 11, 2019
Example of placing a draggable block.
View draggable_block_sample.html
<!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 May 9, 2019
Delete old slack messages at a specific channel.
View delete_messages.py
"""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
Created Apr 25, 2019
Convert share string that generated by Amazon Music share button to NoyPlaying string with hashtag #nowplaying .
View amazon-music-as-nowplay.py
import re
import sys
if __name__ == "__main__":
args = sys.argv
if len(args) < 2:
print('At least one argument is required.')
else:
print(re.sub(r'Amazon Musicで見つけた(.+)(.+)を紹介します。',
r'\2/\1 #nowplaying', args[1]))
@michimani
michimani / textbox-overlay-by-whitespace.html
Created Feb 6, 2019
Add overlay to a word separated by whitespace inputted at a textbox.
View textbox-overlay-by-whitespace.html
<!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;
}
@michimani
michimani / sns_to_slack.py
Created Dec 20, 2018
Notify CloudWatch Alarm to Slack via SNS.
View sns_to_slack.py
import boto3
import json
import logging
import os
from base64 import b64decode
from urllib.error import URLError, HTTPError
from urllib.request import Request, urlopen
SLACK_CHANNEL = os.environ['slackChannel']
@michimani
michimani / put-process-status.sh
Created May 23, 2018
Put linux process status to Amazon CloudWatch.
View put-process-status.sh
###################################################################################
# check process aliving (count process number)
# return integer 1 (process is running) or 0 (process is dead) or 9 (some error)
###################################################################################
function is_process_alive() {
count=`ps awux | grep -v grep | grep -v "$0" | grep -w "$1" | wc -l`
if [[ $count =~ ^[0-9]+$ ]]; then
if [ $count != 0 ]; then
echo 1
else
@michimani
michimani / .bash_profile
Created Mar 2, 2018
Coloring text and displaying git branch for bash prompt
View .bash_profile
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
function promps {
local BLUE="\[\e[34m\]"
local RED="\[\e[31m\]"
local GREEN="\[\e[32m\]"
local WHITE="\[\e[00m\]"
local GRAY="\[\e[37m\]"
local MAGENTA="\[\e[35m\]"
@michimani
michimani / rand_cowsay.php
Last active Mar 2, 2018
Run "cowsay -f" command randomly on PHP.
View rand_cowsay.php
<?php
if (count($argv) < 2)
{
echo 'parameter not enough.'."\n";
return false;
}
exec('which cowsay 2>&1', $cmd_t);
if (!isset($cmd_t[0]) || $cmd_t[0] == '')
@michimani
michimani / set_bg_color.php
Last active Mar 2, 2018
Fill the transparent part of transparent PNG with a solid color.
View set_bg_color.php
<?php
$fpath = $argv[1];
$o = new Bg();
$o->setBgColor($fpath);
class Bg
{
You can’t perform that action at this time.