Skip to content

Instantly share code, notes, and snippets.

View tkatochin's full-sized avatar

かとちん tkatochin

View GitHub Profile
@tkatochin
tkatochin / add-tkatochin-japanese.json
Last active June 8, 2018 03:14
macで英字キーボードのコマンドキーだけで英数←→かなをトグルで切り替える ref: https://qiita.com/tkatochin/items/049f02d3552382f15b75
{
"title": "For Japanese (日本語環境向けの設定) by tkatochin",
"rules": [
{
"description": "コマンドキー(左右どちらでも)を単体で押したときに、英数・かなをトグルで切り替える。",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@tkatochin
tkatochin / file0.txt
Last active July 25, 2018 08:41
Promiseへの翻訳コードでasync/awaitの挙動を理解する ref: https://qiita.com/tkatochin/items/4603c4ec06fc6eb4f371
function hoge() {
// なんかかんか
var foo = ...
var bar = ...
if (foo < ...) {
return foo+bar;
}
var result = innerHoge(foo, bar);
var lastResult = ... // result使ってごにょごにょ
return lastResult;
@tkatochin
tkatochin / backgroundCaller.js
Last active June 6, 2018 06:22
Content ScriptからBackground Script内の関数を直接呼びだす(ように見せる) ref: https://qiita.com/tkatochin/items/30e077f7a8f94d39d714
/**
* バックグラウンドにRPCする呼び出し側の実装(manifestのcontent_scriptsに記述して配備すること)
*/
'use strict';
(function(){
function createAsyncRpcFunction(methodName) {
return async function() {
const req = {
method: methodName,
@tkatochin
tkatochin / taputsukimasen.css
Last active June 3, 2016 08:45
はてなブログのデザインCSSのバックアップ
/* <system section="theme" selected="bordeaux"> */
@import "http://blog.hatena.ne.jp/css/theme/bordeaux/bordeaux.css";
/* </system> */
/* <system section="background" selected="bg17"> */
body{
background-color:#1a2637; background-image:url('/images/theme/backgrounds/theme17.png'); background-repeat:no-repeat; background-attachment:scroll; background-position:right top;
}
/* </system> */
/*
@tkatochin
tkatochin / git-dir-all
Created April 22, 2016 06:04
カレントディレクトリの直下のディレクトリから.gitを持つディレクトリをリストアップし、パラメータで渡したコマンドを各ディレクトリ内で実行する。
#!/bin/sh
for dir in `find . -maxdepth 1 -type d`; do
if [ -d $dir/.git ]; then
pushd . > /dev/null 2>&1
cd $dir
echo "======== ${dir##*/} ========"
$*
popd > /dev/null 2>&1
fi
@tkatochin
tkatochin / is_last_commit_in_other_branch.sh
Last active April 22, 2016 05:53
あるブランチの最後のコミットが、別のブランチにマージ済みかを判定するコマンド
#!/bin/sh
if [ $# != 2 -o "$1" = "$2" ]; then
echo "Usage ${0##*/} branch1 branch2"
echo ""
echo "branch2の中に、branch1の最後のコミットが含まれているか(マージ済みか)を判定します。"
echo "以下はリモートのdevelopブランチにローカルのdevelopブランチの最後のコミットが含まれているかを判定する例です。"
echo "例) ${0##*/} develop origin/develop"
echo ""
echo "実行直後、\$? で判定結果が得られます。"
@tkatochin
tkatochin / pf2gwtcnst.sh
Created December 28, 2015 07:00
Create java file for constants interface for GWT from property file
#!/bin/sh
allargs=$@
extendsType=com.google.gwt.i18n.client.Constants
if [[ $allargs == *"--extends="* ]]; then
echo " --extends=constants-class-name Constantsの拡張クラスを指定できます。指定がない場合はConstantsになります。"
extendsType=`echo $allargs | sed -e "s/.*--extends=\\([a-zA-Z0-9_.]*\\).*/\\1/g"`
allargs=`echo $allargs | sed -e "s/\\(.*\\)\\(--extends=[a-zA-Z0-9_.]*\\)\\(.*\\)/\\1\\3/g"`
fi
@tkatochin
tkatochin / mvn
Created October 8, 2015 07:09
プロジェクトごとにローカルリポジトリを切り替えられることができるようにしたmvn
#!/bin/sh
export repo_path=
export ancestor=.
while [ "/" != "`cd $ancestor;pwd`" -a ! -d $ancestor/.m2/repository ]; do
export ancestor=../${ancestor}
done
if [ -d $ancestor/.m2/repository ]; then
export repo_path=`cd $ancestor/.m2/repository;pwd`
else
@tkatochin
tkatochin / install_appengine-java-sdk.sh
Last active February 3, 2016 11:58
GAEのSDKを自動ダウンロードして展開するスクリプト (Mac)
#!/bin/sh
if [ -z $1 ]; then
echo パラメータに appengine sdkのバージョンを指定してね!
exit 1
fi
DRYRUN=
if [ $1 = --dry-run ]; then
shift
DRYRUN=on
fi
@tkatochin
tkatochin / working-summary.py
Last active September 30, 2015 03:43
Macのキーとマウスのログから日々の稼働開始〜終了時間を出力する
#!/usr/bin/python
# -*- coding: utf-8 -*-
# こちら↓の成果のログから稼働開始〜終了時間を出力する
# http://qiita.com/edvakf@github/items/721afa8d2e69c556ba64
import sys
import os
import glob
import datetime
from datetime import datetime, timedelta