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 / AddElementBeforeHeader.js
Last active March 2, 2018 00:35
Add a specific element before heading in Hatena blog article.
if (location.href.match(/michinoeki-mania\.com\/entry/)) { // Replace this with your blog domain
var j=new Date();
var f=j.getTime();
var g="";
switch (f%5) {
case 0:
g="Something 1";
break;
case 1:
g="Something 2";
@michimani
michimani / MoveToHeader.js
Last active March 2, 2018 00:33
Smooth movement from the table of contents in the Hatena blog article to the heading using jQuery.
$(document).ready(function(){
// 見出しタグにclass追加
$(".entry-content h1").addClass("content-h");
$(".entry-content h2").addClass("content-h");
$(".entry-content h3").addClass("content-h");
$(".entry-content h4").addClass("content-h");
$(".entry-content h5").addClass("content-h");
// 「目次」表示
@michimani
michimani / hatena_sp_comment.css
Last active December 28, 2017 05:08
comment area style for Hatena Blog on mobile page.
.entry-comment {
border: solid 3px #000;
border-radius: 10px;
margin: 20px 0px 10px 0px;
padding: 10px 10px 5px 10px;
}
p.comment-user-name {
z-index: 999;
margin-top:-30px;
@michimani
michimani / change_default_icon.js
Last active March 2, 2018 00:32
Replace the icon image of Hatena blog with another image.
var icon = 'https://path-to-icon';
var hatenaid = 'michimani';
var toc = 200;
var tos = 900;
var p = document.getElementsByClassName('profile-icon');
for (var n = 0; n < p.length; n++){
p[n].src = icon;
}
window.onload = function(){
setTimeout(function(){
@michimani
michimani / set_bg_color.php
Last active March 2, 2018 00:30
Fill the transparent part of transparent PNG with a solid color.
<?php
$fpath = $argv[1];
$o = new Bg();
$o->setBgColor($fpath);
class Bg
{
@michimani
michimani / rand_cowsay.php
Last active March 2, 2018 00:29
Run "cowsay -f" command randomly on 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 / .bash_profile
Created March 2, 2018 00:28
Coloring text and displaying git branch for bash prompt
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 / put-process-status.sh
Created May 23, 2018 01:34
Put linux process status to Amazon CloudWatch.
###################################################################################
# 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 / sns_to_slack.py
Created December 20, 2018 05:56
Notify CloudWatch Alarm to Slack via SNS.
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 / 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;
}